Interview questions in Backend Dev, page 22

How do you define a WebSocket endpoint in FastAPI?
Import WebSocket, use @app.websocket, await accept, receive_text, then send_text.
How to add Socket.IO to an Express application?
Create HTTP server with express(), attach Socket.IO to it, listen on server not app, define event handlers.
Tuning HNSW for recall vs latency
ANN trades exactness for speed, and HNSW knobs M and efConstruction shape graph quality while efSearch trades query latency for recall at runtime.
Handling Result and errors in a Rust web handler
Handler returns Result, the ? operator early-returns errors, a custom error type implements IntoResponse to map to 500, success returns 200 with data.
What are startup and shutdown events in FastAPI?
Tests app lifespan hooks and resource lifecycle. Startup creates DB pools before traffic arrives; shutdown closes them after the last request. These decorators are deprecated; prefer lifespan context managers. Red flag: per-request middleware.
How do Socket.IO rooms organize client communication?
Rooms group sockets for targeted broadcasting, socket can join multiple rooms, emit to room broadcasts to all members.
Zero-downtime schema migration on a hot table
Expand-migrate-contract phases, dual-write and backfill, decouple deploys from migrations.
In-memory rate limiter middleware in Go
Use a token-bucket limiter (golang.org/x/time/rate), guard a per-client map with sync.Mutex, wrap http.Handler so requests over the limit get 429.

How do you handle a WebSocket client disconnect in FastAPI?
Cite installing websockets, Handling disconnections and multiple clients pattern, and Depends.
How does Socket.IO handle WebSocket failures with fallbacks?
Transports are communication protocols, WebSocket is primary, long-polling is fallback, client auto-detects and downgrades.
SQL isolation levels and the anomalies they prevent
Read Uncommitted allows dirty reads; Read Committed blocks them; Repeatable Read blocks non-repeatable reads; Serializable blocks phantoms.
Logging middleware wrapping an http.Handler in Go
Middleware has signature func(http.Handler) http.Handler, records start time, calls next.ServeHTTP, then logs method, URL, and elapsed duration; chaining works because the wrapper is itself a…
Use startup events to initialize a database pool and inject it
This tests FastAPI lifespan hooks and dependency injection for shared state. A strong answer creates the pool in an async startup handler, stores it on app.state, and accesses it via a dependency in routes. A red flag is creating a fresh pool per request.
How to authenticate WebSocket connections using JWTs?
Client sends JWT on connection, server validates via middleware, socket is attached to user.
When a graph database beats relational or document stores
Deeply connected data, variable-depth traversals, fraud or recommendation paths, index-free adjacency.
Static dispatch over Write with generics in Rust
Write generically over the std::io::Write trait with a type parameter W: Write, letting the compiler monomorphize and inline per concrete type, avoiding the vtable indirection of Box<dyn Write>.

How do you authenticate a FastAPI WebSocket connection?
This tests WebSocket limits and FastAPI dependency injection. Pass the JWT via query parameter or cookie at handshake, validate it with Depends, and reject with HTTP 403 or 1008 close.
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.
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.
Choosing a good shard key and avoiding hot spots
High cardinality, even write distribution, query alignment; monotonic keys send all writes to one shard.
We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.
See open roles