Backend Developer interview questions
100 real questions with model answers and explanations for Senior candidates.
See a Backend Developer resume example →Questions
CAP says a distributed system can guarantee at most two of consistency, availability, and partition tolerance at once.
- Partitions are unavoidable, so the real choice is consistency vs availability during one.
- Payment ledger: PostgreSQL with synchronous replication for CP, accepting a brief read-only window on failover.
- User-preference store: Cassandra for AP, since stale data was tolerable but downtime was not.
Why interviewers ask this: The interviewer wants to see that the candidate understands partition tolerance is not optional and can map the abstract theorem to a concrete product decision with real trade-offs.
I start from the worst-case impact of a user or business reading stale data.
- Carts and feed counts tolerate staleness; balances and inventory reservations do not.
- Strong consistency costs latency and availability, so I default to eventual consistency.
- I add compensating workflows only where business correctness demands it.
- I document the decision so the team does not silently revert to strong consistency under pressure.
Why interviewers ask this: Senior engineers are expected to reason about consistency as a business requirement, not a technical preference, and to articulate the cost side of choosing strong guarantees.
CQRS separates the write model from the read model so each is optimized independently.
- Write side enforces business invariants on a normalized domain model.
- Read side materializes denormalized projections tuned for specific queries.
- It pays off when read and write loads diverge, reads need expensive aggregations, or you need multiple read shapes.
- For a simple CRUD service it is pure overhead.
Why interviewers ask this: The interviewer is checking that the candidate can argue both for and against a pattern, not just describe it, showing they apply it deliberately rather than by default.
Event Sourcing stores every state change as an immutable event in an append-only log instead of overwriting rows.
- Gives a full audit trail and the ability to replay events to rebuild state or new projections.
- Fits naturally with CQRS.
- Challenges: schema evolution on historical events, snapshot strategies as streams grow, thinking in events not current state.
- Reading current state needs a projection, not a simple row lookup.
Why interviewers ask this: The interviewer is testing whether the candidate understands both sides honestly and can explain why most systems should not use Event Sourcing by default.
I make the client send a unique idempotency key, usually a UUID, in a request header.
- The server stores the key with the result via an atomic upsert.
- A repeat request with the same key returns the original response without re-running the payment.
- Keys expire after a safe window, usually 24 hours, to limit storage growth.
- The idempotency record and the payment action share one database transaction so they never diverge.
Why interviewers ask this: Idempotency is a critical correctness requirement for financial operations. The interviewer looks for an answer that covers durability, atomicity, and key lifecycle, not just the concept.
I use Redis with a sliding window log or token bucket stored as a sorted set or a counter with expiry.
- Each instance runs a Lua script atomically so check-and-decrement is not split across round-trips.
- For very high throughput I keep a local in-process counter that syncs with Redis every 100 ms.
- That accepts a small overshoot but removes Redis from the hot path.
- I expose rate limit headers so clients can back off gracefully.
Why interviewers ask this: The interviewer is evaluating whether the candidate understands atomicity requirements and the latency cost of remote coordination, and whether they know how to tune that trade-off.
I follow the expand-and-contract pattern.
- Add the new column as nullable or with a default, then deploy code that writes to both old and new columns.
- Backfill historical rows in small batches, then drop the old column in a separate migration once all reads use the new one.
- Use CREATE INDEX CONCURRENTLY in PostgreSQL to avoid table locks.
- Treat migrations as code: in version control, run in CI, never applied manually in production.
Why interviewers ask this: The interviewer wants evidence that the candidate has shipped schema changes on live databases with significant traffic, not just described a textbook approach.
Two-phase commit couples availability and serializes everyone behind locks during the prepare phase.
- It holds locks across all participants, so one slow service becomes a system-wide bottleneck.
- It needs a coordinator that can become a single point of failure.
- Instead I use the Saga pattern: each service runs a local transaction and publishes an event.
- If a step fails, compensating transactions roll back the previous steps, avoiding cross-service coupling and lock contention.
Why interviewers ask this: The interviewer checks that the candidate can explain the fundamental availability and coupling problems of 2PC and has practical experience with Saga-based alternatives.
A Saga splits a multi-step transaction into local transactions with compensating actions.
- Choreography: each service reacts to events from the previous step, decentralized and easy to extend without changing existing code.
- Orchestration: a central coordinator calls each step in sequence, easier to trace but coupled to the orchestrator.
- I choose choreography for simple flows where the team values service autonomy.
- I choose orchestration for complex branching, retries, or a single source of truth for transaction state.
Why interviewers ask this: The interviewer is looking for the candidate to articulate the debugging and coupling trade-offs, not just name the patterns.
A service mesh like Istio or Linkerd injects a sidecar proxy into each pod to handle cross-cutting concerns without app code changes.
- It provides mTLS, load balancing, retries, timeouts, circuit breaking, and observability consistently.
- Cost: each proxy adds CPU and memory per pod.
- Cost: the control plane adds operational complexity and debugging through two proxy layers is much harder.
- I adopt it only when the team has the operational maturity and a shared library cannot cover these concerns.
Why interviewers ask this: The interviewer tests whether the candidate treats infrastructure choices as trade-offs with real costs rather than as features to collect.
I start with a key-value store mapping short codes to long URLs.
- Redis for hot reads backed by a durable store like DynamoDB.
- Generate short codes with a base62 counter from a dedicated ID service, or pre-generate a pool to avoid a single bottleneck.
- A CDN handles redirects at the edge for popular links, bringing reads to single-digit milliseconds.
- Rate limit the write path and push click analytics to Kafka asynchronously instead of blocking the redirect.
Why interviewers ask this: The interviewer is watching whether the candidate starts with the read-to-write ratio, identifies where caching gives the most leverage, and separates the analytics concern from the latency-critical redirect path.
Backpressure signals producers that consumers are overwhelmed so queues do not grow unbounded.
- In Kafka I tune max.poll.records and batch size, and watch consumer lag as the main health signal.
- When lag crosses a threshold I alert and can add consumer instances dynamically.
- For internal reactive pipelines I use bounded queues.
- I either drop messages to a dead-letter mechanism or block the producer, depending on whether data loss is acceptable.
Why interviewers ask this: The interviewer wants to see that the candidate understands backpressure as a flow control mechanism and knows both the Kafka and in-process dimensions of the problem.
Vertical partitioning splits a table by columns; horizontal partitioning (sharding) splits rows across nodes.
- Vertical moves rarely used or large columns to a separate store to cut I/O on common queries.
- Sharding distributes both read and write load by a shard key.
- I use vertical partitioning to keep blobs in object storage and metadata in Postgres.
- I shard when one node can no longer handle write throughput or data volume, picking a key that spreads writes without cross-shard queries.
Why interviewers ask this: The interviewer checks that the candidate understands the operational cost of sharding and does not jump to it prematurely before simpler vertical split options are exhausted.
The approach depends on how stale the data can be.
- Mostly-static reference data: TTL-based expiration with a short enough window.
- Data that must be fresh after a write: write-through caching, updating cache and database together.
- Complex cross-entity invalidation: publish an invalidation event so every instance flushes the affected key.
- I avoid cache-aside with manual invalidation at scale because it causes read-write race conditions.
Why interviewers ask this: The interviewer is assessing whether the candidate understands that cache invalidation is a consistency problem and knows how to pick the right strategy based on staleness tolerance.
PostgreSQL gives ACID, rich queries, and simple tooling, but a single-primary write model becomes a bottleneck at scale.
- Replication lag grows under sustained high write throughput.
- Cassandra distributes writes across all nodes with no single primary, giving linear write scalability and active-active replication.
- Cassandra trade-offs: no joins, limited secondary indexes, tables designed around access patterns upfront.
- I choose Cassandra when writes exceed a single Postgres primary and query patterns are known and simple.
Why interviewers ask this: The interviewer wants to see that the candidate does not treat NoSQL as a universal solution but can articulate the query flexibility and operational complexity trade-offs.
MVCC, multi-version concurrency control, creates a new row version per update instead of locking rows on read.
- Transaction IDs decide which version a transaction sees, so reads never block writes and vice versa.
- The cost is that old row versions accumulate until VACUUM reclaims them.
- If autovacuum cannot keep up, table bloat and transaction ID wraparound become serious risks.
- I monitor bloat and dead tuples and tune autovacuum aggressively on high-churn tables.
Why interviewers ask this: The interviewer is testing whether the candidate understands the operational implications of MVCC, not just the concurrency benefit, because vacuum problems have caused real production outages.
I find slow queries with pg_stat_statements and EXPLAIN ANALYZE before adding anything.
- I check whether the bottleneck is a sequential scan on a large table.
- I create partial indexes on filtered subsets and composite indexes ordered to match the predicate.
- I add covering indexes with INCLUDE to avoid heap fetches and always use CREATE INDEX CONCURRENTLY.
- I audit existing indexes for duplicates or unused ones via pg_stat_user_indexes, since each one slows every write.
Why interviewers ask this: The interviewer checks that the candidate understands the write amplification cost of indexes and uses evidence from query analysis rather than creating indexes speculatively.
PostgreSQL spawns a process per connection, so thousands of direct connections are very expensive in CPU and memory.
- A pooler like PgBouncer keeps a small pool of real connections and multiplexes app requests across them.
- In transaction mode it reuses a connection right after commit, serving thousands of app connections with tens of real ones.
- I run PgBouncer as a sidecar or dedicated service and tune max_client_conn to expected concurrency.
- I monitor pool wait times as a signal the pool is undersized.
Why interviewers ask this: The interviewer wants to know whether the candidate understands the process model of PostgreSQL and has operated a pooler in production rather than just knowing it exists.
Read replicas stop helping when the primary saturates or replicas serve too-stale data.
- They fail when primary write throughput saturates disk I/O or CPU.
- They fail when replication lag makes replica reads unacceptably stale, or the dataset outgrows one node.
- Next steps: vertical scaling, partitioning hot tables onto dedicated instances, a caching layer, or sharding by a distribution key.
- I exhaust vertical scaling and caching before sharding, which adds significant query and app complexity.
Why interviewers ask this: The interviewer is checking that the candidate has a realistic escalation ladder and does not jump to sharding as the first solution.
I identify the query from pg_stat_statements ordered by total_time or mean_exec_time.
- I run EXPLAIN (ANALYZE, BUFFERS) on a read replica or with a short statement_timeout to avoid long locks.
- I look for sequential scans, nested loops with high row estimates, or high buffer hits suggesting memory pressure.
- Common fixes: a targeted index, rewriting a correlated subquery as a join, or ANALYZE to refresh stale statistics.
- I stage any index creation or rewrite in a non-production environment first.
Why interviewers ask this: The interviewer is evaluating whether the candidate follows a methodical diagnostic process and avoids making changes that could worsen production performance during the investigation.
Locked questions
- 21
How do you determine where a performance bottleneck is in a microservices call chain?
microservicesperformance - 22
What profiling tools have you used for Go or Java services and walk me through how you used them.
profiling - 23
How do you measure and reduce tail latency (P99 and P999) in a production API?
latencyapi - 24
What is the thundering herd problem in a caching layer and how do you prevent it?
caching - 25
How do you approach capacity planning for a service that needs to handle 10x its current traffic?
capacity - 26
Explain the circuit breaker pattern and how you tune its thresholds for a specific service integration.
resilience - 27
How do you reduce garbage collection pressure in a JVM-based service under sustained high throughput?
throughputgc - 28
How do you design a batch processing system that handles 500 million records per run without timing out or overwhelming the database?
system-designdesignbatch - 29
What is the difference between async I/O and multi-threading for backend performance, and when do you prefer each?
asyncconcurrencyperformance - 30
How do you handle long-running background jobs so they do not degrade the latency of your API endpoints?
endpointslatencysoft-skills - 31
How do you prevent race conditions in a Go service that uses goroutines to handle concurrent requests?
concurrency - 32
Walk me through implementing a distributed lock using Redis. What are the failure modes?
redisdistributed - 33
What is a deadlock in a relational database, how do you detect it, and how do you prevent it in application code?
databaselocking - 34
How do you effectively test concurrent code to catch race conditions before they reach production?
concurrency - 35
What is Kafka's consumer group model and how do you tune partition count for throughput?
partitioningkafkathroughput - 36
How do you design a message schema in Kafka to support backward-compatible evolution across producer and consumer versions?
kafkadesignschema - 37
Explain exactly-once semantics in Kafka and when you actually need them versus at-least-once delivery.
kafka - 38
How do you handle poison-pill messages in a Kafka consumer pipeline?
soft-skillskafka - 39
What is the outbox pattern and how does it reliably connect database writes with message publishing?
database - 40
How do you design a REST API that can evolve over time without breaking existing clients?
restdesign - 41
When would you choose gRPC over REST and what are the trade-offs?
restgrpc - 42
How do you implement authentication and authorization in a microservices architecture?
authmicroservicesarchitecture - 43
What does an API gateway do and which concerns belong there versus in individual services?
gatewayapi - 44
What is the GraphQL N+1 problem and how do you solve it with the DataLoader pattern?
n+1graphql - 45
How do you implement cursor-based pagination for a large dataset and why is it better than offset-based pagination at scale?
pagination - 46
How do you implement webhook delivery reliably with retry logic and failure handling?
resiliencewebhooks - 47
How do you set up distributed tracing end-to-end across a microservices system?
microservicessystem-designdistributed - 48
What metrics do you instrument in a backend service and what is your alerting philosophy?
monitoring - 49
Walk me through a real production incident you investigated and how you found the root cause.
incidents - 50
How do you define and use SLOs and error budgets for a backend service?
reliability - 51
How do you implement structured logging in a backend service and what fields are mandatory in every log entry?
logging - 52
How do you approach blue-green deployment and canary releases for a stateful service that has a database?
databasedeployment - 53
What is chaos engineering and how would you introduce it on a team that has not practiced it?
resilience - 54
How do you handle database failover in a high-availability PostgreSQL setup?
databasepostgressoft-skills - 55
Describe your approach to designing an on-call rotation and reducing alert fatigue.
design - 56
How do you structure a Kubernetes deployment for a stateless backend service and what pitfalls matter most?
kubernetesdeployment - 57
What is the difference between liveness and readiness probes in Kubernetes and how do you tune them?
kuberneteshealth-checks - 58
How do you manage secrets in a production environment and walk through a complete secret rotation?
secrets - 59
How do you write a meaningful integration test for a service that depends on a database and a message queue?
databasequeuesintegration - 60
What is contract testing and how do you use it to prevent breaking changes between services?
contract - 61
How do you manage Terraform state for a team of engineers without causing conflicts?
terraform - 62
What is your approach to feature flags in a backend system and how do you manage their lifecycle?
system-designfeature-flags - 63
How do you prevent SQL injection and what other OWASP Top 10 vulnerabilities are most critical for backend developers?
owaspinjectionvulnerabilities - 64
Explain the security risks in JWT-based authentication and how you mitigate them.
authjwt - 65
What is RBAC versus ABAC and when do you use one over the other for a multi-tenant SaaS?
rbacmulti-tenancy - 66
How do you implement mTLS between microservices and when is it necessary?
mtlsmicroservices - 67
How do you do a technical design review with a junior engineer? Walk me through your process.
designconcurrency - 68
How do you decompose a monolith into microservices? How do you decide what to extract first?
microservicesmonolith - 69
How do you evaluate whether to build or buy a component? Walk me through a real decision.
decision-makingcomponents - 70
How do you communicate a significant technical risk to a non-technical stakeholder?
communication - 71
How do you run an Architecture Decision Record process on your team?
concurrency - 72
Tell me about a time you disagreed with a technical decision made by a lead or architect. What did you do?
storyconflict - 73
How do you onboard a new engineer onto a complex service they have never seen before?
onboarding - 74
Describe a significant mistake you made in production. What happened and what did you change afterward?
ownership - 75
How do you handle technical debt on a team that is always shipping features?
soft-skillstech-debt - 76
How do you approach data modeling for Domain-Driven Design bounded contexts?
design - 77
What is the difference between synchronous and asynchronous communication between services and when do you choose each?
async - 78
How do you implement distributed rate limiting for a multi-region deployment?
distributedrate-limitingdeployment - 79
How would you migrate a critical table with 500 million rows to a new schema with zero downtime?
schema - 80
How do you securely handle PII in a backend system and what do you audit?
system-design - 81
Describe a system you designed from scratch that is now in production. What would you do differently today?
system-designdesign - 82
How do you evaluate and adopt a new programming language or framework for a production service?
decision-making - 83
How do you break down a large technical project for a team of five engineers?
planning - 84
How do you handle a situation where product management pushes back on the timeline you estimated?
soft-skillsestimation - 85
What does good documentation look like for a backend service and who is responsible for it?
documentation - 86
How do you load test a backend service and interpret the results?
load-testing - 87
How do you design and version an internal SDK or shared library that multiple teams consume?
design - 88
How do you approach observability for a new service from day one?
observability - 89
What is your strategy for keeping dependencies updated across a large backend codebase?
dependencies - 90
How do you mentor a mid-level engineer who wants to grow toward a senior role?
mentoring - 91
How do you stay current with backend technology trends without losing productivity?
learning - 92
Describe your personal philosophy on service ownership and how you implement it in practice.
ownership - 93
How do you design an API for a public developer platform that will have hundreds of integrating teams?
designapi - 94
How do you approach testing strategy for a service that has both synchronous API endpoints and asynchronous event consumers?
endpointsasynctesting - 95
What is optimistic concurrency control and when do you use it instead of database row locking?
databaselockingconcurrency - 96
How do you design a multi-tenant backend system and what are the key isolation trade-offs?
system-designdesignmulti-tenancy - 97
How do you manage the operational complexity of running many microservices in production?
microservicesalgorithms - 98
How do you implement a reliable job queue for delayed task execution?
jobs - 99
Describe how you would approach building a real-time leaderboard that updates across 1 million active users.
- 100
What does engineering excellence mean to you and how do you build a culture of it on a team?
culture