Decoupling 500+ ticks/sec WebSocket bursts from a 60fps UI via ring-buffer conflation, enforcing zero-duplicate idempotent order execution, and guarding against stale-quote trades.
balanceAct V · Architectural Tradeoffs & Production Observability SLOs
Engineering Tradeoffs & Reliability Targets
Step 5 of 5
Tradeoff 0160fps Safe
Latest-Value Conflation vs. Full Tick Queue
check_circleLatest-Value Conflation
Overwrites per-symbol slot in O(1) and emits 1 immutable snapshot every 100ms—memory stays strictly O(symbols).
cancelFull Tick Queue
Backlogs 500 ticks/sec during market open, delaying displayed prices by seconds and starving the UI thread.
Defense: Traders only care about the freshest bid/ask. Dropping intermediate ticks between 100ms paints protects both latency and frame time.
Tradeoff 02Idempotent
REST for Orders vs. WebSocket for Orders
check_circleREST + Idempotency-Key
Explicit request/response status codes, standardized Idempotency-Key caching, and independent retry semantics.
cancelWebSocket Orders
Shares congestion with noisy market-data ticks and requires custom correlation IDs and timeout state machines.
Defense: Separate the data plane (WebSocket tick bursts) from the transactional control plane (idempotent REST POST /v1/orders).
Tradeoff 03Financial Safety
Pessimistic Order Lock vs. Optimistic UI
check_circlePessimistic Ledger Lock
Persists SUBMITTING locally and waits for authoritative exchange confirmation before mutating cash balance.
cancelOptimistic Fill UI
Showing a fake fill before matching engine execution causes phantom buying power and dangerous rollback confusion.
Defense: Unlike social likes or chat messages, financial fills cannot be assumed locally—show a clear SUBMITTING state backed by SQLite WAL until confirmed.
Tradeoff 04Fast Resync
Snapshot + Delta vs. Full Book Resend
check_circleSnapshot + Delta
Fetch one atomic REST snapshot on connect or sequence gap, then apply tiny incremental WebSocket deltas.
cancelFull Book Resend
Broadcasting the entire order book on every tick wastes cellular bandwidth and triggers constant JSON parsing GC.
Defense: Sequence numbers (seq) detect any missed delta immediately, falling back to a sub-600ms REST snapshot hydrate.