Realtime & WebSockets
bloom_realtime bridges backend mutations to connected clients over WebSockets, featuring zero-allocation channel pub/sub, multi-isolate cluster scaling, and automated query cache invalidation.
BloomChannelHub Server Pub/Sub
BloomChannelHub manages active WebSocket connections, topic subscriptions, broadcast fanout, and automatic dead-socket cleanup:
Multi-Core Isolate Cluster (50k+ msgs/s)
Scale real-time throughput past Node.js by distributing incoming TCP connections evenly across all CPU cores with BloomRealtimeCluster:
Kernel TCP_NODELAY & Binary Framing
Bloom Realtime achieves ultra-low latency and minimal memory overhead via three key production optimizations:
Eliminates Nagle packet buffering to ensure immediate message flushing for realtime chat and live cursor updates.
Disables per-message deflate by default to save 15-25% CPU on small JSON events during high fanout bursts.
Direct pointer set indexing eliminates hash-map queries and heap list allocations in the broadcast hot-path.
Server vs. Client Barrel Split
package:bloom_realtime/bloom_realtime.dart
Pure Dart, server-safe barrel export with zero Flutter framework dependencies. Used inside server entrypoints and backend route handlers.
package:bloom_realtime/bloom_realtime_client.dart
Client barrel adding the RealtimeQueryBridge and BloomData integration for Flutter applications.
Live Query Cache Invalidation
Connect channel broadcasts directly to BloomData.invalidateQueries(...) on the client. When a backend event occurs, cached queries automatically refetch in the background:
Presence Tracking
BloomPresenceTracker tracks real-time join/leave states with initial state snapshots and departure events when sockets disconnect.