Real Time
28 bites tagged Real Time — interview questions with model answers, and 60-second explainers.
How to sync state across multiple user devices?
Attach userId to each socket, track active sockets per user, broadcast user state to all their sockets. multi-device presence and state coherence patterns.
Socket.IO emit methods: socket, io, broadcast differences?
Socket.emit() sends to one client, broadcast.emit() to all except sender, io.emit() to all. Socket.IO API design and message scope understanding.
HTTP request-response versus WebSocket connections?
HTTP is request-initiated, pull-based, client waits for response. WebSocket is persistent, bidirectional, either side sends data anytime. understanding request-response versus persistent bidirectional models.
WebSocket connection manager and broadcast
A manager class holding a list of active connections, connect accepts and appends, disconnect removes, broadcast iterates sending to each, all wrapped in try/finally to handle disconnects. Managing WebSocket lifecycle and fan-out.
Managing user presence with reconnection grace periods
Rely on heartbeats, apply a grace period before marking offline, reconcile reconnects by user not socket id, use a shared store for multi-instance. robust presence tracking over flaky networks.
The WebSocket Protocol
WebSocket (RFC 6455) is a protocol providing full-duplex, persistent communication over a single TCP connection. It begins as an HTTP request that upgrades, then both client and server can send messages anytime, enabling real-time apps without HTTP's…
Sub-20ms online feature serving
An in-memory key-value store (Redis) as the online feature store, precomputed features, streaming updates, and offline-online consistency. low-latency feature serving design.
How do you speed up a slow detection model?
Quantization, pruning, distillation, lighter backbones, and resolution or batching tweaks, each trading some accuracy or effort for speed. inference optimization techniques.
Feature choice for real-time mobile SLAM
Pick ORB for fast FAST keypoints and cheap binary descriptors matched by Hamming distance; accept reduced robustness versus SIFT for real-time, low-power operation. system-level feature trade-offs.
SIFT versus SURF versus ORB
SIFT is most accurate but slow with float descriptors; SURF approximates SIFT for speed; ORB is fast, binary, and free, ideal for real-time and embedded. feature-method trade-offs.
Detect a three-action user sequence in real-time at scale
Tests stream processing and stateful pattern matching on unbounded data. A strong design uses a CEP engine with keyed event-time windows, pushes alerts via WebSocket, and trades state-memory for latency.
Online vs offline feature store architecture and use cases
This tests latency trade-offs between real-time and batch infrastructure. Contrast fast online lookups against batch offline stores; fraud detection maps to online and model training to offline. Red flag: treating them as interchangeable and ignoring latency.
How would you design a near real-time social proof notification system?
This tests low-latency event pipeline design with bounded load. A strong answer uses a fire-and-forget beacon, stream processor, and cache with TTL; it favors approximate counts and windowed aggregation.
Outline the architecture of a Dynamic Creative Optimization system
Tests distributed system design for combinatorial ad optimization. A strong answer maps a creative asset service, combination engine, real-time ad server with A/B testing, performance feedback pipeline, and campaign config UI.
Architect a real-time multi-armed bandit and compare trade-offs to A/B testing
Sketch a fast arm router, streaming feedback, and model updates; contrast MAB regret minimization with A/B's unbiased estimates. Real-time ML serving and statistical trade-offs.
SSD: Real-Time Detection Without Region Proposals
SSD scores default boxes across multiple scales in one forward pass. It runs real-time robotics and mobile vision where two-stage detectors lag. The footgun is ignoring shallow feature maps, which destroys small object accuracy as early layers carry fine…
Design a real-time mobile analytics pipeline
Tests decoupling high-volume ingestion from low-latency querying. Strong designs use an event broker, a stream processor for windowed aggregates, and an OLAP database for sub-second dashboards.
Design a real-time anomaly detection system for 'add to cart' events
Tests real-time data pipeline design and nuanced anomaly detection. A good answer outlines ingestion (Kinesis), processing (Lambda/Flink), seasonal modeling for 'a drop', and alerting (SNS).
WebSockets: A Persistent, Two-Way Connection
Think of a WebSocket as a dedicated phone line to a server, keeping the connection open for two-way conversation. It's ideal for real-time features like live chat or streaming stock tickers.
Server-Sent Events (SSE): One-Way Data Push from Server
Server-Sent Events (SSE) push data from server to client over one HTTP connection. It's a simpler, one-way alternative to WebSockets for things like live news feeds or status updates.
Socket.IO Rooms: Broadcasting to Subsets of Clients
Think of Socket.IO Rooms as server-side channels for grouping clients. They let you broadcast messages to a specific subset, like a private chat or users following a topic. Remember rooms are a server-only concept; a client can't see which rooms it has joined.
Socket.IO: Broadcasting Events to Clients
Broadcasting sends a server-side event to multiple clients at once, like a public announcement system. Use it for live notifications or game state updates. The footgun: by default, it only reaches clients on the same server; use an adapter for multi-server…
Socket.IO: Emitting and Handling Events
Socket.IO events are named messages sent between a client and server. One side `emit`s a message, the other listens with `on`. This powers real-time apps like chat. The footgun: don't `JSON.stringify` objects; Socket.IO does it for you.
Socket.IO: More Than Just WebSockets
Socket.IO is a library that guarantees real-time, bidirectional communication. It automatically picks the best transport—WebSocket or HTTP long-polling—to ensure your connection works. Use it for chat apps or live dashboards.
Get Real Time bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.