Backend interview questions

37 questions, easy to hard. Read one, then answer it out loud: an AI interviewer follows up, hints when you're stuck and grades your answer.

Backend interviews test how you build servers people rely on: HTTP, REST and GraphQL APIs, authentication, error handling, background jobs and caching.

HTTP and Web Servers

  1. A junior developer has only ever called APIs through a library and asks what an HTTP request and response actually contain. Walk them through the parts of each, using a request to load a user's profile as the example.

    What a strong answer covers
    • What a request carries: what you want done, to which resource, plus metadata and sometimes a payload.
    • What comes back: an outcome code, metadata and usually a payload.
    • Concrete header examples and what each is for.
    • Why every request has to identify the user again.

    Common mistake: Describing the library or framework you use instead of what actually travels over the wire.

  2. A teammate built a link in an email that deletes an account when it's opened, using a plain GET request. Explain what safe and idempotent mean for HTTP methods, which common methods are which, and why this link is a problem.

  3. Your app sets a session cookie when a user signs in. Explain how cookies are set and sent, and what the main cookie attributes do and why a session cookie should use them.

  4. Explain what happens inside a typical web framework from the moment a request reaches your server to the moment the response is sent, including routing and middleware.

  5. Your Node app runs behind a reverse proxy such as nginx. Explain what a reverse proxy does, why you'd put one in front of an application server, and one problem it can cause for the app if you're not careful.

  6. A colleague asks whether switching from HTTP version one point one to version two or three would make your site faster. Explain the main differences between the three versions and when the upgrade helps.

  7. An export endpoint builds a two-gigabyte CSV file in memory before sending it, and the server keeps running out of memory. Explain how you'd stream the response instead, and what you need to watch out for.

REST and GraphQL in Practice

  1. Your sign-up endpoint trusts whatever JSON the client sends, and the database has filled with empty names and impossible ages. Explain how and where you'd validate request input on the server.

  2. Every endpoint in your API reports errors differently: some return plain text, some a message field, some an empty body. Explain how you'd design one consistent error format and make sure every endpoint uses it.

  3. Clients want to filter your list of orders by status and date range, and sort by date or total. Explain how you'd design the query parameters and implement them safely on the server.

  4. Users can upload profile photos to your API. Explain how you'd handle the upload on the server safely and efficiently, from the request to where the file ends up.

  5. A GraphQL query asks for fifty posts and each post's author, and your logs show fifty-one database queries. Explain how resolvers cause this and how a batching loader fixes it.

  6. Someone sends your public GraphQL API a deeply nested query, friends of friends of friends ten levels down, and it takes the server down. Explain how you'd protect a GraphQL API from expensive queries.

Authentication and Sessions

  1. Walk me through what happens on the server, step by step, when a user types their email and password and presses sign in, until they see their dashboard on the next page load.

  2. Your API uses JSON Web Tokens. Explain what's inside one, how the server checks it, and what you should never put in it.

  3. In your project management app, any signed-in user can edit any project by changing the ID in the URL. Explain the bug and how you'd implement permission checks properly.

  4. Design the forgot-password flow for your app, from the user entering their email to them signing in with a new password, and explain how you'd keep it secure.

  5. Your mobile app keeps users signed in for months, but access tokens expire after fifteen minutes. Explain how access and refresh tokens work together and how you'd handle a stolen refresh token.

  6. You're adding a Sign in with Google button. Explain the OAuth authorisation code flow with OpenID Connect from the click to the user having a session in your app, including the security checks along the way.

Errors and Logging

  1. Your server logs are free-text sentences, and finding every error for one customer means writing fragile text searches. Explain structured logging and how you'd change your logs.

  2. Your production logs are so noisy that real errors get lost, and your team argues about what counts as a warning. Explain the common log levels and give a rule of thumb for when to use each.

  3. A user reports that checkout failed, and the request passed through your API, a payment service and a background worker. Explain how request or correlation IDs let you follow it through all three.

  4. You find code that catches every error, logs nothing, and returns an empty list, and customers have been seeing empty pages for a week without anyone noticing. Explain good error-handling practice in server code.

  5. During an audit you find passwords, access tokens and full card numbers in your application logs. Explain how this happens and how you'd stop it happening again.

  6. Your health check endpoint queries the database and every downstream service, and when one minor service went down, the platform restarted all your app servers in a loop. Explain how to design health checks properly.

Background Jobs and Queues

  1. When a user signs up, your endpoint sends a welcome email, resizes their avatar and syncs them to the CRM before responding, and sign-up takes eight seconds. Explain how you'd move this work into background jobs.

  2. Some of your background jobs fail because an email provider is briefly down, and others fail every time because of a bug. Explain how you'd retry jobs and what should happen to ones that never succeed.

  3. Your queue promises at-least-once delivery, and a few customers were charged twice when a worker crashed after charging but before marking the job done. Explain why this happens and how to make job handlers safe to run twice.

  4. Your app runs a nightly cron job to send invoices, but after you scaled to three servers every customer got three invoices, and one night the job ran so long it overlapped with the next run. Explain how to run scheduled jobs safely.

  5. When an order is placed, your code saves it to the database and then publishes an order placed message to a queue. Sometimes the save succeeds but the publish fails, and the warehouse never hears about the order. Explain the outbox pattern and how it fixes this.

  6. One large customer imports a million records, which creates a million jobs, and every other customer's jobs wait for hours behind them. Explain how you'd make your job processing fair.

Runtimes and Caching

  1. Your Node.js API is fast until one user uploads a big spreadsheet to be parsed, and then every other request hangs for several seconds. Explain why this happens and how you'd fix it.

  2. A colleague asks how a Node server, a Python server with several worker processes, and a Java server with a thread pool each handle many requests at once. Compare the three models and their trade-offs.

  3. After moving your app to serverless functions, the database starts refusing connections with a too many connections error during busy periods. Explain what a connection pool is and how you'd fix this.

  4. You're adding Redis in front of a slow product details query. Explain how you'd implement the cache-aside pattern in code, including keys, expiry and what happens when a product is updated.

  5. The cached homepage data expires every five minutes, and each time it does, hundreds of requests hit the database at once and it slows to a crawl. Explain what's happening and several ways to prevent it.

  6. Every time you deploy, a handful of users get connection errors and some background jobs are left half finished. Explain how a server should shut down gracefully.

Questions about practising

How should I prepare for backend interview questions?
Practise answering them out loud, not just reading them. Explaining an answer under follow-up questions is what interviews test. Work through the 37 questions here from easy to hard, and revisit the ones you struggle with.
Can I practise backend interview questions with an AI?
Yes. Open any question and start a voice session: an AI interviewer asks it, follows up on your answer, gives hints when you're stuck and grades your answer with written feedback when the call ends.
Are these backend interview questions free?
5 of the 37 questions are free to practise. Sign in with Google, no card needed. Pro unlocks the rest, plus practice calls to your phone.