Skip to content

Backend Developer interview questions

100 real questions with model answers and explanations for Middle candidates.

See a Backend Developer resume example

Practice with flashcards

Spaced repetition · Hunter Pass

Listen to the interview

Play it like a podcast: question and model answer, one after another.

Questions

restdesign

Keep URLs shallow and fetch deep relations separately.

  • Nest only one level deep, like /orders/{id}/items, and avoid /users/{id}/orders/{id}/items.
  • For deeper links, return related resource IDs and let the client fetch them.
  • Or offer an ?include= query param that triggers a server-side join.
  • Define naming, verb, and error-payload conventions before the first endpoint.

Why interviewers ask this: The interviewer is checking whether the candidate understands RESTful constraints and can balance discoverability with practical usability, rather than just knowing the word REST.

queriesn+1

The N+1 problem is one query for N records plus one extra query per record.

  • It results in N+1 total queries instead of one.
  • In an ORM, fix it with eager loading via JOIN includes or a batch loader like DataLoader.
  • In raw SQL, rewrite it as a single JOIN or IN query, then reassemble in code.

Why interviewers ask this: This is a litmus test for real-world ORM experience and the ability to reason about the relationship between application code and database round trips.

locking

They differ in whether you lock the row up front.

  • Optimistic assumes rare conflicts: read with a version, check it on update, roll back if it changed.
  • Pessimistic locks the row at read time, blocking other writers until commit.
  • Use optimistic for low-contention writes like profile updates.
  • Use pessimistic for high-contention ones like reserving limited inventory.

Why interviewers ask this: The interviewer wants to see that the candidate knows the concurrency implications of each approach and can match the mechanism to the actual conflict rate.

databasemongodb

Choose a document database when data is naturally hierarchical or polymorphic.

  • Good fit for nested or polymorphic shapes that would need many JOIN tables in SQL.
  • Also when the schema evolves fast and shared-table columns would be disruptive.
  • Relational wins for multi-row ACID transactions, complex ad-hoc queries, and strict referential integrity.
  • The decision hinges on access patterns, not just data shape.

Why interviewers ask this: The interviewer is probing whether the candidate avoids cargo-culting a technology and can articulate the specific trade-offs rather than citing popularity.

endpointsidempotency

Use a client-supplied Idempotency-Key to dedupe requests.

  • The client generates a unique key, usually a UUID, and sends it with the request.
  • The server stores the key and response in a short-lived cache like Redis before processing.
  • On a duplicate key, return the cached response without re-running the side effect.
  • Set a TTL, usually 24 hours, and document the client retry window.

Why interviewers ask this: Idempotency is critical for payment and order endpoints; the interviewer is testing whether the candidate has handled real-world retry scenarios and understands the server-side mechanics.

pooling

Connection pooling reuses open database connections across requests.

  • It avoids a new TCP connection and TLS handshake on every query.
  • Without it, a service under load can exhaust connection limits and add hundreds of ms per request.
  • Tune min and max pool sizes from concurrency, the database max_connections, and average query duration.

Why interviewers ask this: This question reveals whether the candidate understands the operational boundary between application code and the database and can reason about resource exhaustion under load.

memory

Confirm the leak, then snapshot the heap to find what is retained.

  • Confirm with a heap usage metric that trends up instead of returning to baseline after GC.
  • Take heap snapshots over time with --inspect and Chrome DevTools or clinic.js, then diff them.
  • Look for unremoved event listeners, closures holding large buffers, and unbounded module-level caches.

Why interviewers ask this: The interviewer wants evidence that the candidate can move from symptom to root cause systematically rather than guessing and restarting the process.

resilience

A circuit breaker tracks a dependency's error rate and fails fast when it spikes.

  • It tracks errors over a rolling window.
  • When the error rate crosses a threshold, it opens and calls fail fast without hitting the dependency.
  • After a timeout it goes half-open, letting one probe through; success closes it again.
  • Apply it to synchronous external calls where slow failures would exhaust thread pools or queues.

Why interviewers ask this: The question tests whether the candidate understands cascading failure modes in distributed systems and knows a concrete mechanism to contain blast radius.

indexes

A B-tree index gives O(log n) lookups but adds write cost.

  • It stores sorted keys in a balanced tree, finding rows in O(log n) instead of a full scan.
  • It speeds reads but slows every INSERT, UPDATE, and DELETE because the tree updates too.
  • Add one when plans show sequential scans on large tables with selective filters.
  • Review unused indexes with pg_stat_user_indexes and drop the dead weight.

Why interviewers ask this: This assesses whether the candidate understands that indexes are not free and can reason about the read/write trade-off rather than reflexively indexing every column.

databasecap

CAP says a distributed store guarantees at most two of consistency, availability, and partition tolerance.

  • Partitions are unavoidable, so the real choice is CP versus AP.
  • CP example: PostgreSQL with synchronous replication.
  • AP example: Cassandra or DynamoDB.
  • Use it to frame whether a service tolerates stale reads or needs linearizable reads.

Why interviewers ask this: The interviewer is checking that the candidate can translate a theoretical constraint into a concrete design decision rather than just reciting the theorem.

databasemigrationsdeployment

Use the expand-contract pattern for zero-downtime schema changes.

  • First deploy a migration that adds new columns or tables without removing old ones.
  • Deploy app code that writes to both old and new structures.
  • Backfill existing data, then deploy a final migration that drops the old structure.
  • Avoid locking DDL by using concurrent index builds in PostgreSQL.

Why interviewers ask this: This reveals whether the candidate has actually owned a production schema and understands that a naive ALTER TABLE can lock a table for minutes and cause downtime.

scaling

Vertical adds resources to one machine; horizontal adds more instances.

  • Vertical adds CPU or RAM to one machine: simple but limited and a single point of failure.
  • Horizontal adds instances behind a load balancer, requiring stateless apps or externalized state.
  • Default to horizontal for stateless API services.
  • Accept vertical for managed databases until read replicas or sharding is needed.

Why interviewers ask this: The interviewer wants to confirm the candidate understands the statelessness prerequisite for horizontal scaling and can reason about the operational complexity each option introduces.

event-sourcing

Event sourcing stores state as an ordered log of immutable events.

  • The current state is derived by replaying events from the start or a snapshot.
  • It fits when you need a full audit trail, history replay, or multiple read models.
  • Costs are complex read paths, eventual consistency between projections, and more storage.

Why interviewers ask this: The question evaluates whether the candidate understands when the added complexity is justified versus when it would be over-engineering for a simple CRUD service.

rate-limiting

Use a Redis-backed token bucket or sliding window keyed by client.

  • Key it by API key or IP address.
  • On each request, atomically decrement and check the limit, returning 429 with Retry-After when exceeded.
  • Configure per-key limits for client tiers and expose X-RateLimit-Remaining.
  • Consider moving the logic to a gateway layer to keep service code clean.

Why interviewers ask this: This tests practical knowledge of distributed state management for a common API protection mechanism and whether the candidate thinks about client experience, not just server protection.

databaselocking

Find the conflicting locks, then enforce a consistent lock order.

  • Query pg_locks and pg_stat_activity or the error log to see who holds and waits on what.
  • Deadlocks usually come from acquiring locks in different orders.
  • Fix it by acquiring locks in a consistent order, often by sorting resource IDs first.
  • Set a reasonable lock_timeout so a stuck transaction fails fast.

Why interviewers ask this: The interviewer is checking that the candidate has actually debugged a deadlock and knows the specific tools and the root cause, not just a theoretical definition.

microservicesconsistency

Keep transactions local and use sagas across services.

  • Design around bounded contexts so each transaction is local to one service.
  • For cross-service operations use the saga pattern via choreography events or an orchestrator.
  • Accept eventual consistency across service boundaries as the practical reality.
  • Design the UX for it, such as a pending state while an async operation completes.

Why interviewers ask this: This tests whether the candidate understands that two-phase commit is usually impractical in microservices and knows real alternatives with their trade-offs.

system-designqueues

A queue delivers each message to one consumer; pub-sub broadcasts to all subscribers.

  • Queue: one consumer takes a message and it is removed, good for distributing work.
  • Pub-sub: every current subscriber gets the message, good for broadcasting events.
  • Kafka blurs this: consumer groups act like queues, independent groups replay the same log.
  • Choose by whether a message is processed once or by many independent systems.

Why interviewers ask this: The interviewer is looking for a candidate who can distinguish competing message patterns and match the right one to the actual use case.

authrestapi

Use stateless JWTs for authentication and middleware checks for authorization.

  • Issue a short-lived access token and a longer refresh token on login; send the access token in Authorization.
  • Store roles or fine-grained permissions in the DB and check them in middleware before the handler.
  • Keep auth logic out of business logic.
  • Rotate signing keys, set strict expiry, and use HTTPS to prevent token theft.

Why interviewers ask this: This assesses whether the candidate knows the full lifecycle of auth, not just how to decode a JWT, and understands the security implications of token expiry and revocation.

databasedenormalization

Denormalization stores redundant data to avoid expensive JOINs.

  • Example: copy a user's display name into the orders table.
  • It helps when a read-heavy endpoint hits the same JOIN millions of times.
  • The trade-off is propagating updates to copies, adding write complexity and stale-data risk.
  • Introduce it only after profiling confirms the JOIN is a real bottleneck.

Why interviewers ask this: The question probes whether the candidate treats denormalization as a deliberate, measured trade-off rather than a default style choice.

caching

Cache data that is expensive, changes rarely, and is read far more than written.

  • Cache it at the layer closest to the consumer.
  • For shared data across instances use Redis with an explicit TTL and invalidation on write.
  • Guard against cache stampede with probabilistic early expiry or a mutex on cold cache.
  • Keep keys narrow and prefer TTL expiry over event-driven invalidation for simple cases.

Why interviewers ask this: This tests whether the candidate understands the classic caching trade-offs and has dealt with real-world invalidation problems rather than treating Redis as magic.

Locked questions

  • 21

    What are the practical differences between HTTP/1.1 and HTTP/2 for backend services?

    http
  • 22

    What is the saga pattern and how does it manage distributed transactions?

    sagadistributedtransactions
  • 23

    How do you handle long-running background jobs in a web application?

    soft-skillsjobs
  • 24

    What are the trade-offs between synchronous and asynchronous API design?

    designapiasync
  • 25

    How do you implement efficient pagination for large datasets?

    pagination
  • 26

    What is a bloom filter and what backend problems is it suited for?

    bloom-filter
  • 27

    How do you write integration tests for a service that calls external APIs?

    integrationapi
  • 28

    What is gRPC and when would you prefer it over REST?

    restgrpc
  • 29

    How do you profile a slow API endpoint in production?

    endpoints
  • 30

    What is eventual consistency and what are the practical implications of building systems with it?

    system-designconsistency
  • 31

    How do you design a database schema for a multi-tenant application?

    databaseschemadesign
  • 32

    What is CQRS and when does it make sense to apply it?

    cqrs
  • 33

    How do you implement distributed locking?

    lockingdistributed
  • 34

    What strategies do you use to reduce P99 latency in a high-traffic service?

    latency
  • 35

    How do you validate and sanitize user input in a backend service?

    validation
  • 36

    How do you structure backend code to make it testable?

  • 37

    What is database sharding and what challenges does it introduce?

    databasesharding
  • 38

    How do you handle secrets and configuration in a deployed application?

    deploymentconfigsecrets
  • 39

    What is the difference between a hard delete and a soft delete, and how do you choose?

    soft-delete
  • 40

    How do you approach code reviews as a middle-level developer?

    code-review
  • 41

    What is observability and how do you implement it in a backend service?

    observability
  • 42

    How do you handle API versioning?

    versioningsoft-skills
  • 43

    What is backpressure in a streaming system and how do you handle it?

    system-designstreamingbackpressure
  • 44

    What is a JWT and what are its main security considerations?

    jwt
  • 45

    How do you design an efficient job scheduling system for recurring tasks?

    system-designdesignjobs
  • 46

    What is the difference between OLTP and OLAP workloads, and how does it affect your database choice?

    database
  • 47

    How do you implement retry logic with exponential backoff?

    resilience
  • 48

    What is a prepared statement and how does it prevent SQL injection?

    sqlinjection
  • 49

    When might you intentionally avoid using a foreign key constraint?

    foreign-keys
  • 50

    How do you respond when a service you own goes down in production?

    incidents
  • 51

    What is a reverse proxy and why would you place one in front of your backend service?

    proxy
  • 52

    How do you measure and improve the throughput of a data processing pipeline?

    throughputconcurrency
  • 53

    How do you handle concurrent writes to the same database row safely?

    soft-skillsdatabaseconcurrency
  • 54

    What is the difference between an index scan and a sequential scan in PostgreSQL, and when does each occur?

    indexespostgres
  • 55

    How do you decide when to introduce a message queue into your architecture?

    queues
  • 56

    How do you implement a webhook delivery system reliably?

    system-designwebhooks
  • 57

    How do you test business logic that is tightly coupled to database calls?

    database
  • 58

    What is a service mesh and when does it become useful?

    service-mesh
  • 59

    How do you manage database connection pool settings under high concurrency?

    databasepoolingconcurrency
  • 60

    What are the ACID properties of a database transaction and what does each mean in practice?

    databasetransactionsacid
  • 61

    What is the difference between structured and unstructured logging, and which do you prefer for production services?

    logging
  • 62

    How do you implement full-text search in a backend service?

    search
  • 63

    How do you handle partial failures in a distributed system?

    system-designdistributedsoft-skills
  • 64

    What is the strangler fig pattern and when is it useful?

    migration
  • 65

    How do you ensure backward compatibility when making changes to an API?

    api
  • 66

    What is a read replica and how do you use it in your architecture?

    replicationarchitecture
  • 67

    What is your process for writing a post-mortem after a production incident?

    incidentsconcurrency
  • 68

    What is the difference between eager and lazy loading in an ORM?

    ormlazy-loading
  • 69

    How do you implement health checks and readiness probes for a backend service?

    health-checks
  • 70

    How do you keep service dependencies up to date without breaking your application?

    dependencies
  • 71

    How do you approach designing an API contract between two teams?

    designapi
  • 72

    Where should SSL/TLS termination happen in your infrastructure and why?

    tls
  • 73

    How do you implement feature flags in a backend service?

    feature-flags
  • 74

    How do you prioritize fixing technical debt alongside delivering new features?

    prioritizationtech-debt
  • 75

    What is a write-ahead log in a database and how is it used?

    database
  • 76

    How do you handle timezone complexity in a backend application?

    soft-skillsalgorithms
  • 77

    How does a CDN interact with a backend API service?

    api
  • 78

    How do you choose between using an ORM and writing raw SQL?

    sqlorm
  • 79

    What is a database EXPLAIN plan and how do you use it to optimize queries?

    databasequeriesoptimization
  • 80

    How do you implement idempotent message consumers?

    idempotency
  • 81

    How does container orchestration affect how you write backend services?

    containers
  • 82

    How do you approach performance testing before a major release?

    testing
  • 83

    What are the trade-offs between using a UUID and an auto-increment integer as a primary key?

    primary-keys
  • 84

    How do you implement multi-factor authentication in a backend service?

    auth
  • 85

    How do you diagnose and fix slow database queries in a production system?

    databasequeriessystem-design
  • 86

    What is the difference between push-based and pull-based metric collection?

    monitoring
  • 87

    How do you choose a data serialization format for inter-service communication?

    serialization
  • 88

    What is the fan-out problem in social feeds and how do you address it?

    fan-out
  • 89

    How do you implement graceful shutdown for a backend service?

    lifecycle
  • 90

    What is an API gateway and what responsibilities does it typically handle?

    gatewayapi
  • 91

    How do you handle cascading failures between services?

    soft-skills
  • 92

    What is a materialized view and when would you use one?

    materialized-views
  • 93

    How do you ensure your service can handle a sudden 10x spike in request volume?

  • 94

    What is the two generals problem and how does it relate to distributed systems?

    system-designdistributed
  • 95

    What is vertical partitioning and how does it differ from horizontal partitioning?

    partitioningscaling
  • 96

    How do you mentor a junior developer on your team?

    mentoring
  • 97

    How do you estimate the effort for a technical task?

    estimation
  • 98

    How do you evaluate and adopt a new technology for your production stack?

    decision-making
  • 99

    How do you handle database schema changes that affect a shared library or package used by multiple services?

    databaseschemasoft-skills
  • 100

    What do you do when you disagree with a technical decision made by a more senior engineer?

    conflict