Interview guide

Backend Developer Interview Questions and Sample Answers

For backend developers preparing for API design, database, caching, reliability and behavioural rounds. Each question explains what the interviewer is checking, with practical tips and sample answers you can adapt to your own experience.

16 questions · Updated 24 November 2026

Backend interviews are mostly about what happens when things don’t go to plan: a client retries a payment, two requests update the same row, a cache serves old data, or a dependency slows to a crawl. Interviewers want to hear that you think about those cases without being asked.

This guide goes deeper than general software engineering questions. It covers API design, authentication and authorisation, indexes and transactions, caching, queues, performance and observability, plus behavioural questions about outages and testing. For coding fundamentals and broader system design, see the software engineer guide. The sample answers use [placeholders] for your own systems and results.

Answers land best when they’re anchored in your own work. For each topic, have one real example ready: an index you added, a cache you had to invalidate, a job you moved to a queue.

How the interview usually goes

  • Recruiter screen: your experience, main languages and frameworks, the kinds of systems you’ve worked on, notice period and salary expectations.
  • Coding round: a data-structures problem, or a practical task such as parsing logs or writing a small endpoint, in a shared editor.
  • Practical backend exercise at many companies: a take-home or live task to build or extend a small service, usually reviewed for API design, error handling and tests.
  • System design, especially for mid-level and senior roles: a service designed end to end, including its API, data model, caching, queues and what happens when parts of it fail.
  • Behavioural or hiring-manager round: incidents, on-call, trade-offs under deadlines, and working with frontend, product and operations teams.

API design

Interviewers often take a familiar domain and push on the details: conflicts, retries, long lists and change over time. Ask about the rules of the domain before you name a single endpoint.

Design the API for a simple room booking system.

What they’re checking: A concrete design question shows how you model resources and use HTTP properly, especially for conflicts and concurrent updates.

  • Clarify the rules first: can bookings overlap, can they be changed, and who can cancel them?
  • Use status codes precisely: 201 with a Location header on create, 409 Conflict when a slot is taken, 400 or 422 for invalid input.
  • Prevent double bookings in the database, not just in application code, because two requests can arrive at the same moment.
Sample answer

I’d start with the rules: can bookings overlap, how far ahead can people book, and who can cancel? Then the resources: /rooms, /rooms/{id}/availability and /bookings, with bookings at the top level because people often list their own across rooms. POST /bookings creates one and returns 201 with a Location header. If the slot is taken, that’s a 409 Conflict with a clear error body; an end time before the start time is a 400 or 422. Cancelling could be DELETE /bookings/{id}, or a PATCH that sets the status to cancelled if we want to keep history. To stop double bookings when two requests arrive together, I’d enforce it in the database with a constraint that rejects overlapping bookings for the same room, not only with a check in code. For edits, an ETag with If-Match stops one person silently overwriting another’s change.

What does idempotency mean, and how would you make a payment endpoint safe to retry?

What they’re checking: Networks fail, clients retry, and a payment endpoint that isn’t idempotent can charge someone twice. This is a favourite way to test real-world API thinking.

  • Define it plainly: making the same request several times has the same effect as making it once.
  • GET, PUT and DELETE are idempotent by definition; POST isn’t, so it needs an idempotency key.
  • Cover the edge cases: two identical requests arriving at the same time, and the same key reused with a different request body.
Sample answer

An operation is idempotent if repeating it has the same effect as doing it once. That matters because a client that times out can’t tell whether the server processed its request, so it retries. For a payment endpoint, the client generates a unique idempotency key for each payment and sends it as a header. On the server, I store the key with a hash of the request and, once processing finishes, the response. If the same key arrives again, I return the stored response instead of charging again. If it arrives while the first request is still running, I return a conflict so the client retries later, and a unique constraint on the key stops two workers racing. The same key with a different body is a client error. Keys expire after [an agreed period], and queue consumers need the same protection.

Offset or cursor pagination: which would you use?

What they’re checking: Pagination looks trivial until a table has millions of rows or changes while someone pages through it. Interviewers want the trade-offs, not just the syntax.

  • Offset pagination is simple and allows jumping to any page, but deep pages get slow, and rows can be skipped or repeated when data changes.
  • Cursor, or keyset, pagination continues from the last item seen using an index, so it stays fast and stable.
  • Sort on a unique combination, such as created time plus ID, and return the cursor as an opaque token.
Sample answer

Offset pagination, like LIMIT 20 OFFSET 400, is easy to build and lets users jump to any page, so it’s fine for small admin tables. At scale it has two problems. The database still walks past every skipped row, so deep pages get slower. And if rows are inserted or deleted while someone is paging, they see duplicates or miss items. Cursor pagination, also called keyset pagination, asks for “the next 20 after this item”: the query filters on the sort key of the last row returned, such as created time and ID, which an index can serve directly. It stays fast at any depth and is stable while data changes. The trade-off is that you can’t jump straight to page 50. For a public API or an infinite feed I’d use cursors, returned as an opaque token so I can change how they work later.

How do you change an API without breaking existing clients?

What they’re checking: Real APIs live for years and have clients you don’t control. They want to see you treat an API as a contract.

  • Prefer additive changes: new optional fields and new endpoints are safe; renaming or removing a field, or changing what it means, is not.
  • When a breaking change is unavoidable, publish a new version, by URL path or header, and run both versions through a deprecation period.
  • Track which clients still call the old version, announce a switch-off date, and remind them before it arrives.
  • Ask clients to ignore fields they don’t recognise, so you can add data without breaking them.

Security and data

What’s the difference between authentication and authorisation? Would you use sessions or tokens?

What they’re checking: Mixing the two up leads to some of the most serious API vulnerabilities. Interviewers check the concepts and the practical trade-offs between sessions and tokens.

  • Authentication is who you are; authorisation is what you’re allowed to do. They map to 401 and 403.
  • Check authorisation on every request against the specific resource, such as whether this user may see order 123, not just whether they’re logged in.
  • Know the token trade-off: easy to verify without a lookup, but hard to revoke before they expire.
Sample answer

Authentication establishes who the caller is, through a password, single sign-on or an API key. Authorisation decides what that caller may do, and I check it on every request against the specific resource: a logged-in user shouldn’t be able to read order 123 just by changing the ID in the URL. With sessions, the server keeps the state and the browser holds only an opaque ID in a cookie marked HttpOnly, Secure and SameSite. Revoking access is easy, because I delete the session, but every server needs the shared session store. Signed tokens such as JWTs carry their claims with them, so any service can verify them without a lookup, which suits service-to-service calls. They’re hard to revoke early, though, so I keep access tokens short-lived with refresh tokens. And a JWT payload is encoded, not encrypted, so nothing sensitive goes in it.

Explain OAuth at a high level.

What they’re checking: Many systems let users sign in with another provider or grant apps access to their data. Interviewers want the core idea and the current recommended flow, not every detail of the specification.

  • OAuth 2.0 is about delegated authorisation: a user lets an app access their data on another service, limited by scopes, without sharing their password.
  • Name the roles: the user, the client app, the authorisation server that issues tokens, and the resource server that accepts them.
  • The authorisation code flow with PKCE is the recommended flow today, including for single-page and mobile apps; the implicit flow is discouraged.
  • Signing in with another provider uses OpenID Connect, which adds an ID token on top of OAuth to say who the user is.

How do database indexes work, and when can they hurt?

What they’re checking: Indexes are the most common fix for slow queries and a common cause of slow writes. Interviewers want to know you understand both sides.

  • Explain the idea: a sorted structure, usually a B-tree, that lets the database find rows without scanning the whole table.
  • Column order in a composite index matters; it mainly serves queries that filter on its leading columns.
  • Check the query plan with EXPLAIN to confirm an index is actually used, before and after you add it.
Sample answer

An index is a separate, sorted structure, usually a B-tree, that maps column values to rows, so the database can find matches in a few steps instead of scanning the table. It helps with filtering, joins and sorting. Column order matters in a composite index: one on customer ID and created time serves queries by customer, or by customer and date range, but is usually much less useful for date alone. If an index contains every column a query needs, the database can answer from the index without reading the table at all. The costs are real, though. Every insert and update has to maintain each index, indexes take storage, and an index on a column with few distinct values may never be used. Wrapping an indexed column in a function can also stop it being used. So I index for real query patterns and confirm with EXPLAIN.

What do ACID and transaction isolation levels mean in practice?

What they’re checking: Concurrency bugs like lost updates often pass every test and then appear under real traffic. They want to see that you can explain isolation in plain words and choose a fix.

  • Explain each letter in one line, then spend your time on isolation, where the real trade-offs are.
  • Know the common levels, Read Committed, Repeatable Read and Serializable, and roughly what each one prevents.
  • Have a concrete example, such as two requests buying the last item in stock, and two ways to fix it.
Sample answer

Atomicity means all of a transaction’s changes happen or none do. Consistency means constraints still hold afterwards. Isolation means concurrent transactions don’t interfere with each other, to a degree set by the isolation level. Durability means committed data survives a crash. Isolation is where the trade-offs are. Read Committed, the default in PostgreSQL, only shows committed data, but reading the same row twice in one transaction can give different results. Repeatable Read gives the transaction a consistent snapshot. Serializable makes the outcome as if transactions ran one at a time, but the database may abort some, so the application must retry them. A classic bug is two requests both reading a stock level of one and both selling the item. I’d fix it with a single atomic update that only succeeds while stock is above zero, or by locking the row, or with a version column for optimistic locking.

Performance, scale and reliability

Expect follow-up questions that start with “what if”: what if the cache is wrong, the queue backs up, or one client sends ten times the usual traffic. Talk about failure as naturally as the happy path.

How do you use caching, and how do you stop a cache serving stale data?

What they’re checking: Adding a cache is easy; keeping it correct is the hard part. They want to hear your invalidation strategy, not just the name of a technology.

  • Decide what can be cached and how out of date it’s allowed to be before choosing a pattern.
  • With cache-aside, update the database and then delete the cache key, rather than writing the new value into the cache, to reduce race conditions.
  • Plan for a stampede, when a popular key expires and many requests hit the database at once. Letting one request rebuild the value and adding a little randomness to expiry times both help.
Sample answer

First I ask what’s worth caching: data that’s read far more often than it changes and can be briefly out of date, like product details or configuration. My default is cache-aside. On a read, check the cache; on a miss, read the database and store the result with a time-to-live. On a write, update the database and then delete the cache key, so the next read fetches fresh data. Deleting is safer than writing the new value in, because two concurrent writers can otherwise leave the older value in the cache. The TTL is a safety net in case an invalidation is missed. For very popular keys, I let one request rebuild the value while the others wait or get the old one. I never cache per-user data under a shared key, and I watch the hit rate to check the cache is earning its place.

When would you move work to a queue or background job?

What they’re checking: Knowing what doesn’t belong in the request path keeps APIs fast and resilient. Interviewers also check that you understand delivery guarantees and retries.

  • Good candidates: sending emails, generating reports, processing uploads and calling slow or unreliable third parties.
  • Most queues deliver at least once, so consumers must be idempotent.
  • Plan retries with backoff, a dead-letter queue for messages that keep failing, and alerts on queue depth and the age of the oldest message.
Sample answer

I move work out of the request when the user doesn’t need the result straight away, when it’s slow, or when it depends on something that might fail and should be retried. Sending a confirmation email, generating a PDF report or processing an uploaded file are typical. The API saves what it needs, puts a message on the queue and responds quickly, sometimes with a 202 Accepted and a job ID the client can check. Most queues guarantee at-least-once delivery, so a message can arrive twice and the consumer has to be idempotent. Failed jobs are retried with exponential backoff, and messages that keep failing go to a dead-letter queue instead of blocking everything else. One subtle problem is writing to the database and publishing the message as two separate steps: if the second fails, the work is lost. The transactional outbox pattern solves that.

An endpoint that used to be fast is now slow. How do you investigate?

What they’re checking: This shows whether you debug methodically with data or guess. Interviewers listen for measuring, narrowing down and verifying the fix.

  • Scope it first: since when, for every request or only some, and is the median slow or only the 95th and 99th percentiles?
  • Check what changed: a deploy, traffic, data volume or a dependency.
  • Use traces to see where the time goes before you change any code.
Sample answer

First I’d confirm and scope it: which endpoint, since when, and whether it’s slow for everyone or only some requests. Percentiles matter here, because an average can look fine while the slowest requests are timing out. Then I’d check what changed around that time: a deploy, more traffic, data growth or a slower dependency. Traces usually show where the time goes: the database, an external call or our own code. Common causes are a query that no longer uses a good index as the table has grown, an N+1 pattern where the code runs one query per item, an exhausted connection pool, or a third-party API that slowed down with no timeout configured. I’d fix the specific cause, confirm the improvement in the same metrics, and add an alert or test so we notice a regression before users do. At [Company], [a real example and its result].

One client is sending so much traffic that the service is slowing down for everyone. What do you do?

What they’re checking: This tests rate limiting and fairness in a realistic situation, and whether you look for the cause rather than only blocking the client.

  • Short term, apply a per-client rate limit or quota and return 429 Too Many Requests with a Retry-After header.
  • Protect everyone else: limits per API key, and separate pools of workers or connections so one tenant can’t use them all.
  • Find out why it’s happening: a client retrying without backoff is a common cause, and a bulk endpoint or webhooks may serve them better.
  • Decide in advance whether the limiter fails open or closed if its own data store goes down.

How do you make a service observable?

What they’re checking: You can’t fix what you can’t see. Interviewers want to know you can work out what is broken, and why, from the data your service produces.

  • Logs, metrics and traces answer different questions; explain what each one is for.
  • For every endpoint, track request rate, errors and latency percentiles, plus saturation signals such as connection pool usage and queue depth.
  • Put the trace ID in every log line so you can jump from a slow trace straight to its logs.
Sample answer

I think in three signals. Metrics tell me something is wrong: for each endpoint, request rate, error rate and latency percentiles, plus saturation signals like connection pool usage and queue depth. Traces show where a slow or failing request spent its time as it moved between services; I’d instrument them with OpenTelemetry, the open standard. Logs give the detail of a specific event. I make them structured so they can be searched by field, include the trace ID in every line, and keep personal data, passwords and tokens out of them. Each service has a dashboard of its key metrics, and alerts fire on what users feel, such as error rate or latency against our targets, rather than every CPU spike. The real test is whether an on-call engineer who has never worked on the service can find out what’s wrong from the data alone.

Testing and behavioural questions

These questions are about how you work day to day and under pressure. Use real stories, structured with the STAR method, and be clear about what you did yourself.

What’s your testing strategy for a backend service?

What they’re checking: They want a balanced approach that gives the team confidence to deploy often, not just a high coverage number.

  • Unit-test business logic, and test data access against a real database running in a container rather than mocks.
  • For services that call each other, contract tests catch breaking API changes before deployment.
  • Test the failure paths: timeouts, retries, duplicate messages and invalid input.
Sample answer

I aim for tests that let us deploy confidently and often. Business logic, like pricing rules or order state changes, gets fast unit tests. For the data layer, I prefer integration tests against a real database started in a container, because mocks won’t catch a wrong query, a constraint violation or a migration that fails. Where services depend on each other, contract tests check that a provider still gives its consumers what they expect. A small number of end-to-end tests cover the most important journeys, like [a critical flow — for example, sign-up to first order]. I also test the unhappy paths: a dependency timing out, a message delivered twice, a request retried with the same idempotency key. Everything runs in CI on each pull request, and a flaky test gets fixed or removed quickly, because once people stop trusting the tests, they stop reading the results.

Tell me about an outage you helped resolve.

What they’re checking: Interviewers want calm, structured incident handling and, above all, what changed in the system afterwards.

  • Give a clear timeline: detection, mitigation, root cause and follow-up.
  • Be specific about your role, whether you led, investigated or handled communication.
  • Show a lasting fix, such as timeouts, a circuit breaker or graceful degradation, not just a restart.
Sample answer

At [Company], [the service] started [the symptom — for example, failing most checkout requests] during [time or event]. I was [your role — for example, on call, or the engineer who knew that service best]. The dashboards showed [what you saw — for example, request threads piling up while waiting on a slow third-party API]. Because that call had no timeout, one slow dependency was taking down the whole service. To stop the impact, we [the mitigation — for example, switched off the non-essential feature behind a flag], and errors returned to normal within [time]. In the post-mortem, we added [the lasting fixes — for example, timeouts, retries with backoff and jitter, and a circuit breaker], plus an alert on [the signal you were missing]. My biggest lesson was [your lesson — for example, that every network call needs a timeout and a plan for when it fails].

Tell me about a database schema change you made on a live system.

What they’re checking: Changing a schema under live traffic without downtime is a core backend skill. They want a safe, step-by-step approach.

  • Describe expand and contract: add the new structure, migrate gradually, switch reads over, then remove the old structure in a later release.
  • Backfill large tables in batches to avoid long locks and replication lag.
  • Make each step deployable and reversible on its own, with code that works against both the old and new schema during the change.

Questions to ask the interviewer

  • What does on-call look like for this team, and what happens after an incident?
  • How does code get from a merged pull request to production, and how long does that usually take?
  • What’s the biggest reliability or scaling problem the team is working on right now?
  • How do teams agree and change API contracts between services?
  • How do you balance technical debt against new features?
  • What would a strong first three months look like in this role?

Common mistakes

  • Jumping to large-scale architecture before clarifying requirements; ask about traffic, data and consistency needs first.
  • Saying “add a cache” without explaining invalidation; say what gets cached, for how long and how it’s refreshed.
  • Ignoring failure paths; mention timeouts, retries, duplicates and partial failures without waiting to be asked.
  • Describing latency only with averages; talk about percentiles, because the slowest requests are the ones users complain about.
  • Treating authorisation as a login check; explain how you check access to each specific resource.
  • Listing technologies without trade-offs; for every choice, say what it costs and when you’d choose differently.

The day before

  • Sketch an API for a domain you know well: resources, status codes, pagination, the error format and how retries are handled.
  • Prepare one real example each of an index you added, a concurrency or transaction issue, and a cache you designed or fixed.
  • Write out an incident story with a timeline, your role and what changed afterwards.
  • Practise one system design question out loud with a timer, covering failure cases as well as the happy path.
  • Re-read the job description and note the languages, databases, messaging and cloud technologies it mentions.
  • Test your camera, microphone, internet connection and any coding platform link you’ve been sent.
Practise these questions out loud

Lucimeet’s AI interviewer asks you the questions, listens to your answers, asks follow-ups and scores each one — then shows a better way to say it. Your first interview is free.