Streaming 26,397 US, HK & China A-Share Instruments over WebSocket: Live TLS Benchmarks, permessage-deflate, and Backpressure Patterns

Multi-market dashboards and intraday screeners often work effortlessly with 10 test symbols, then hit rate limits, socket buffer spikes, or event-loop stalls when scaled to 26,000+ US, Hong Kong, and China A-Share instruments during opening peaks (09:30 CST in Shanghai/Shenzhen; 09:30 ET in New York — 21:30 DST / 22:30 Standard Time Beijing).
Below is a single-run wire-level TLS capture conducted on November 30, 2026 (03:42 UTC) across 26,397 returned instruments (14,847 US + 8,230 China A-Shares including ETFs/indices/bonds + 3,320 Hong Kong including indices), along with two non-obvious data-shape traps and a decoupled Node.js 22+ reference skeleton.
1. Why Batch Polling Fails at Full-Market Scale
Polling a standard 50-symbol batch REST endpoint every 2 seconds across 26,397 instruments requires 528 × 30 = 15,840 requests/minute, well above typical commercial REST ceilings while repeatedly pulling illiquid tickers whose prices have not moved. Unpaginated full-market REST snapshots are best scoped to cold-start hydration and post-close reconciliation.
| Tier | Representative Providers | US + HK + CN | Protocol & Key Engineering Boundaries (Public Docs, Nov 2026) |
|---|---|---|---|
| US-First Leaders | Polygon.io, Databento, Twelve Data | US / Western primary | Mature US feeds (T.* / Q.* or raw North American feeds); generally lack a single unified CN + HK full-market real-time WS contract |
| Brokerage OpenAPIs | IBKR, Futu OpenD, LongPort | Broker-dependent | Bound to trading-account quote quotas; Futu/IBKR typically require local gateway daemons |
| Unified Multi-Market Engine | TickDB | Unified 26,397 | universes full-market push (US_Stock, HK_Stock, CN_Stock), permessage-deflate + ≤500-item frames; MIT open-source MCP (tickdb-mcp); unentitled keys return 4005 |
| Regional Quant / Institutional / Scrapers | Tushare Pro / Bloomberg / Wind / yfinance | Varies | Offline research quotas, traditional institutional workflows, or unofficial scraping without SLA |
(If your watchlist stays under a few hundred symbols, per-symbol WebSocket subscriptions are usually simpler and lighter.)
2. Live TLS Wire Benchmarks (Single-Run Sample, Nov 30, 2026)
For the live wire capture and runnable reference skeleton below, we tested against TickDB's full-market feed during active HKEX morning trading, China A-Share midday break, and US overnight hours:
- Cold-start REST snapshots: Uncompressed 3-market JSON totaled 13.80 MB (US 10.31 MB + CN 2.58 MB + HK 905 KB).
zstdachieved the smallest wire payload across all three markets (2.22 MB total, 83.9% saved), while single-run end-to-end times forgzipandzstdwere close (HKgzip161 ms vs.zstd168 ms; single-client timing does not infer server CPU cost). - WebSocket
permessage-deflate: The server negotiatedpermessage-deflate; server_no_context_takeover; client_no_context_takeover. A 15-second capture across all 26,397 instruments dropped from 14.74 MB plain to 3.08 MB on the wire (79.1% saved). During active HKEX trading, the initial snapshot (7 frames / 350 ms) saved 80.3%, and live 15s deltas (20 frames / 945 updates) saved 75.8%. - Protocol pitfall: Sending
Accept-Encoding: gzipon a WebSocket upgrade does not enable frame compression—inspectws.extensionsonopenand halt on fatal code2008.
3. Four-Layer Reference Architecture & Two Verified Data Traps
Keep ws.on("message") minimal: parse JSON, enforce a monotonic timestamp guard (incomingTs >= currentTs), update an in-memory Map, and queue keys in dirtyKeys for a 100 ms async batch flush. Note that a single-process Node.js timer performs same-thread asynchronous coalescing; move CPU-heavy screening to separate processes, Worker Threads, or Redis Streams / Kafka for process isolation.
Two data-shape traps verified by scanning all 26,397 records:
- Mixed suffix conventions:
CN_Stock(8,230) carries.SH/.SZ/.BJ100% and includes 1,685 ETFs, 598 indices, 300 bonds, plus 66type="unknown"items omittingcategory;HK_Stock(3,320) omits.HKcompletely ("700") and omitsopenon suspended/zero-trade symbols;US_Stock(14,847) omits.USwhile 133 tickers contain valid dots (BRK.B,.WS,.U). Run 3 market-isolated workers and prefix internal keys (US:BRK.B,HK:700,CN:600519.SH) rather than calling.split(".")[0]globally. - US extended-hours
"0"guard & sample boundary: All 14,847 US snapshots includepre_market_quoteandpost_market_quote, and 10,866 (73.2%) includeovernight_quote. Because our 12sUS_StockWS window ran during quiet US overnight hours (incremental_items = 0), continuous push frequency during US pre-market/regular peaks was not measured here. Inactive extended objects (volume: 0) can returnlast_done: "0", so always guardNumber(q.volume) > 0 && Number(q.last_done) > 0.
Across 20 consecutive application-level ping → pong probes from public broadband, RTT ranged from 144.0 ms to 151.2 ms (median 145.7 ms, jitter < 7 ms); baseline your own 24-hour P50/P99 from your target cloud region.
Full Node.js 22+ reference skeleton and 6-point verification checklist are published in the original engineering post and TickDB's open-source repo.

