Build a real-time market data app with ClickHouse and Massive
A real-time tick data app can stream stock trades and quotes from Massive (formerly Polygon.io) over WebSockets straight into ClickHouse, with a Node.js backend and a React frontend for live visualization. Trades and quotes go into separate MergeTree tables ordered by symbol and a one-minute time bucket. A single client batches synchronous inserts (flush at 1,000 rows or every 2 seconds, with bounded buffers) rather than using async inserts or Kafka. SQL queries using argMax/argMin over (timestamp, sequence) tuples power a live quote table and candlestick charts, with stated caveats about data loss, decimal types and trade-condition handling.
Related posts
- Building StockHouse: Real-time market analytics with ClickHouse
ClickHouse mediumAdept
StockHouse is a reference streaming analytics app that ingests live stock and crypto ticks from Massive's WebSocket APIs through a Go ingester into ClickHouse and renders them in a Vue dashboard built on Perspective. The ingester batches records and writes over ClickHouse's Native binary columnar protocol for maximum insert throughput. A Node.js backend keeps a pooled connection to ClickHouse and streams results as Apache Arrow straight into Perspective's WebAssembly engine, avoiding JSON parsing. Materialized views with AggregateFunction states (argMin/argMax/sum/max) pre-aggregate daily per-pair prices at insert time, so dashboard queries run in milliseconds while raw data stays available for ad hoc analysis.
- How Bullet uses ClickHouse Cloud to give DeFi's fastest exchange real-time analytics
ClickHouse mediumAdept
Bullet, a Rust-based DeFi perpetuals exchange running as an app-specific rollup on Solana with ~500μs p50 order processing, indexes 150M+ rows per hour of sequencer events into ClickHouse Cloud for trade history, real-time analytics and monitoring. Events flow from a Rust WebSocket indexer through Kafka (AWS MSK), where Redpanda Connect classifies and routes them into per-event-type ClickHouse tables; ReplacingMergeTree keyed on event number and transaction hash makes the pipeline idempotent so reindexing and backfills deduplicate automatically. Moving off Databricks removed an hourly-batch-to-DynamoDB serving layer, cut query latency from 10-15 seconds to milliseconds, and replaced a 20-30 minute leaderboard cron job with a refreshable materialized view running every 10 minutes. Data freshness improved from 1-2 hours to under 5 seconds at comparable cost with 1,000x more data.
- Streaming Real-Time Visualizations with ClickHouse, Apache Arrow and Perspective
ClickHouse mediumAdept
A ~100-line browser demo streams forex tick data from ClickHouse into the Perspective visualization library (Rust/C++ compiled to WebAssembly) using Apache Arrow over HTTP. ClickHouse has no push or WebSocket API, so the client polls a sliding time window every ~30–50ms. The query filters on the primary-key timestamp and uses a window function over a slightly widened range to compute per-pair price change. Perspective keeps only the latest 20k rows. Queries run in under 10ms on 11.5B rows, latency is dominated by HTTP round trips, and 20 clients (~200 QPS) used under 2 cores. Polling can miss rows under eventual consistency and insert latency, which motivates planned streaming queries, and a full-dataset speed test uses the ArrowStream format with the Arrow JS library to feed data in chunks.
- Why Flock Safety turned to ClickHouse for real-time vehicle traffic analytics
ClickHouse mediumAdept
Flock Safety replaced a once-daily Redshift, DBT, Prefect and QuickSight SPICE pipeline with ClickHouse Cloud. The old setup had refreshes of up to four hours during which data was unavailable, and SPICE capped datasets at 1TB or 1 billion rows. Before choosing ClickHouse, the team found direct Redshift queries hit concurrency limits, and both Aurora PostgreSQL and S3 with Trino exceeded QuickSight's query timeouts. The new design ingests ML predictions via SNS, Firehose, S3 and ClickPipes (peaking above 20 MB/s, over 1 billion predictions a day) and uses materialized views with uniqState into AggregatingMergeTree tables, so transformation happens on insert and DBT and Prefect are no longer needed. QuickSight now queries ClickHouse directly, with queries finishing in under five seconds, no downtime and longer retention.
- Trade secrets: How Coinhall uses ClickHouse to power its blockchain data platform
ClickHouse easyNovice
Coinhall, an omnichain trading terminal aggregating swap data from 23 blockchains, moved from BigQuery (about 2-second queries, thousands of dollars per month) to QuestDB and then to self-hosted ClickHouse. In Coinhall's comparison against Rockset, SingleStore and Snowflake, ClickHouse ran candlestick queries in 20 ms, latest-price queries in 8 ms and ASOF JOINs in 50 ms, on a 4 vCPU / 16 GB server costing about $50 a month. After migrating, the team tuned queries around sparse primary indexes and replaced full-table LIMIT BY scans with aggregating tables fed by materialized views. They also avoided or simplified sort-merge joins.