Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

ClickHouse 6 min read Case study mediumAdept

Building StockHouse: Real-time market analytics with ClickHouse

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.

Related posts

  • Build a real-time market data app with ClickHouse and Massive

    ClickHouse mediumAdept

    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.

  • 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.

  • 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.

  • How Fountain rebuilt its data plane on ClickHouse Cloud to power Cue, the Frontline Superintelligence

    ClickHouse mediumAdept

    Fountain replaced a multi-vendor batch pipeline (third-party replication to S3/Iceberg, then BigQuery) with ClickPipes CDC streaming Postgres and MongoDB directly into ClickHouse Cloud, cutting analytics freshness from three hours to under two minutes, with most queries sub-second, at about 66% lower cost. MongoDB documents land in ClickHouse's native JSON type, which enables schema-on-read dot-notation access, and over 2,000 incremental materialized views built with dbt replace any orchestrator. Moving a lagInFrame plus ASOF JOIN window computation into insert-time materialized views cut per-query memory by 80% on an 838M-row table, and 60-98% across other query shapes. Tenant isolation for the Cue LLM agent is enforced through empty service users, versioned RBAC roles, session variables set by the MCP backend, and row policies, so the design fails closed and resists prompt injection.

  • Building a Unified Data Platform with ClickHouse

    ClickHouse mediumAdept

    Synq, a data observability startup, consolidated its user-facing application, internal BI, in-app analytics and ML training data onto a single ClickHouse Cloud cluster after Postgres with a time-series plugin struggled with large backfills. Naive per-message inserts from its Go ingestion service caused part explosions and insert timeouts. Buffer tables fixed that but used too much cluster memory, so the team settled on Async Inserts and handled duplicates with ReplacingMergeTree plus LIMIT 1 BY on a surrogate key. Materialized views feeding query-specific tables with ORDER BY keys matched to access patterns cut scanned data by an order of magnitude and keep API latencies around 100ms, while dbt builds auditing and daily-aggregated analytics tables without separate ETL.

The quest for software engineering knowledge.

Look:
Layout: