Backend · 29 concepts
Backend fundamentals
API design, auth, data and caching, background work and scaling: the backend every interview asks about, for engineers who build and call APIs.
Asked in these mock interviews
Part 1 · 8 concepts
Designing HTTP APIs
- 01
REST: resources, methods and idempotency
A REST API exposes resources as nouns in URLs and uses HTTP methods for actions, where GET is safe, GET, PUT and DELETE are idempotent, POST is neither, and each…
- 02
Status codes that mean what they say
Status codes tell clients and infrastructure what happened: 2xx success, 3xx redirect or cache, 4xx the client must change the request, 5xx the server failed, so…
- 03
One error format: RFC 9457 problem details
RFC 9457 (July 2023, replacing RFC 7807) defines a standard JSON error body, served as application/problem+json, with type, title, status, detail and instance fields…
- 04
Idempotency keys: charge exactly once
An idempotency key is a unique id the client sends with a non-idempotent request (like POST /payments) so the server can store the first result and return that same…
- 05
Pagination (offset vs cursor), filtering and sorting
Offset pagination (LIMIT 20 OFFSET 400) is simple and allows page numbers but gets slower and skips or repeats rows when data changes, while cursor (keyset) pagination…
- 06
Versioning and evolving an API
Most API changes should be additive so old clients keep working; when you must break the contract, publish a new version (usually /v2 in the path), announce deprecation…
- 07
GraphQL basics and the N+1 problem
GraphQL exposes one endpoint and a typed schema, the client asks for exactly the fields it needs, and resolvers fetch each field, which makes naive resolvers run one…
- 08
Backend for Frontend (BFF)
A Backend for Frontend is a small server owned by the frontend team that sits between one client (web or mobile) and the backend services, combining and shaping their…
Part 2 · 6 concepts
Authentication and authorization
- 09
Authentication vs authorization, RBAC and ownership
Authentication proves who the caller is; authorization decides what that caller may do with a specific resource, and both must be checked on the server for every request.
- 10
Storing passwords: hashing with Argon2id or bcrypt
Never store passwords or encrypt them; store a slow, salted hash (Argon2id first choice, scrypt or bcrypt otherwise) and compare by hashing the login attempt with the…
- 11
Sessions vs JWT
A server session stores login state on the server and gives the browser only a random session id (easy to revoke), while a JWT is a signed token that carries the claims…
- 12
Access and refresh tokens, rotation and storage
Use a short-lived access token for API calls and a long-lived refresh token to get new ones; rotate the refresh token on every use and treat reuse of an old one as…
- 13
Cookies, CSRF and session security
Session cookies should be HttpOnly, Secure and SameSite (ideally with the __Host- prefix), and because browsers attach cookies to cross-site requests automatically…
- 14
OAuth 2.0, OpenID Connect and PKCE
OAuth 2.0 lets an app get limited access to an API on a user's behalf, OpenID Connect adds a signed ID token that says who the user is, and every client, especially…
Part 3 · 5 concepts
Data, ORMs and caching
- 15
SQL vs NoSQL: choosing a database
Relational databases (Postgres, MySQL) store data in tables with a schema, joins and strong transactions; NoSQL stores like MongoDB (documents), Redis and DynamoDB…
- 16
ORMs, migrations and the N+1 problem
An ORM like Prisma or Drizzle maps tables to typed objects and generates SQL, but loading related rows inside a loop silently sends one query per row (N+1), so you load…
- 17
Database connection pooling
Opening a database connection is slow and each one costs the database memory, so a server keeps a small pool of open connections and lends them to queries, and you size…
- 18
Caching with Redis: cache-aside, TTL and invalidation
Cache-aside means the app first reads from the cache (Redis), and on a miss reads the database, stores the result with a TTL and returns it, while writes update the…
- 19
Cache stampede, locks and hot keys
A cache stampede happens when a popular key expires and thousands of requests miss at once and all hit the database; you prevent it with single-flight loading or a…
Part 4 · 4 concepts
Background work, webhooks and real-time
- 20
Queues and background jobs (BullMQ)
Slow or unreliable work (emails, image processing, calling partners) should not run inside the HTTP request: the API puts a job on a queue, answers quickly (often 202)…
- 21
Retries, backoff and idempotent consumers
Retry only failures that may succeed later (timeouts, 5xx, 429), wait longer each time with exponential backoff plus random jitter, cap the attempts, and make the…
- 22
Receiving webhooks safely
A webhook is an HTTP POST a provider sends you when something happens; you must verify its HMAC signature over the raw body, reject old timestamps, answer 2xx quickly…
- 23
Real-time: WebSockets, SSE and Socket.IO
Use Server-Sent Events for one-way server-to-client streams over plain HTTP (with automatic reconnect), WebSockets for two-way low-latency messaging, and remember that…
Part 5 · 6 concepts
Scaling and running in production
- 24
File storage: S3 and presigned URLs
Store files in object storage like S3, not on the API server's disk, and let clients upload and download directly with short-lived presigned URLs, while your API only…
- 25
Stateless servers, load balancers and horizontal scaling
To scale out, run many identical stateless API instances behind a load balancer, keep all shared state (sessions, files, caches, rate-limit counters) in external…
- 26
Rate limiting algorithms: token bucket and sliding window
A token bucket gives each client a bucket of tokens that refills at a steady rate (allowing short bursts up to its size), while window algorithms count requests per…
- 27
Observability: logs, metrics and traces
Observability means you can explain what your system is doing from the outside: structured logs say what happened, metrics show rates, errors and latency percentiles…
- 28
Serverless vs containers
Serverless functions (AWS Lambda, Vercel functions) run your code per request with no servers to manage and scale to zero, but bring cold starts, time limits and…
- 29
Deploying a Node service
A deployable Node service is a pinned-LTS container image built in CI, configured only through environment variables and a secrets manager, with health checks, graceful…
Your first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.