HireHireInterview Quizzes › Backend Developer

Backend Developer Interview Questions

Think you're ready? These are the questions that actually decide Backend Developer interviews. Warm up on Easy — then face the Hard round, where 95% of candidates crumble. 80 questions across 3 levels, instant score, completely free.

80Questions
3Difficulty levels
95%Fail the hard round
FreeInstant score
Easy
Warm-up · 20 Qs
Medium
Practical · 30 Qs
Hard
Brutal · 30 Qs
⚡ Take the Backend Developer quiz — get your score →

The Backend Developer interview questions

Below are the real questions, grouped by difficulty. Expand any one to reveal the correct answer and why — or take the timed quiz for a score you can share. Can you clear the Hard round?

Easy round 20 questions

A client sends POST /users and the server successfully creates a brand-new user record. Which status code best fits this response?
  • A. 200 OK
  • B. 201 Created ✓
  • C. 202 Accepted
  • D. 204 No Content
Correct answer: B. 201 Created is the correct code when a request results in a new resource being created.
Your POST /orders endpoint creates a new order on every call. A flaky network makes the client retry the same request. What is the likely effect?
  • A. The retry is safely ignored
  • B. The order is updated in place
  • C. A duplicate order is created ✓
  • D. The server returns 304 Not Modified
Correct answer: C. POST is not idempotent, so retrying the same create request produces a duplicate order.
You need every customer plus their orders, including customers who have placed no orders at all. Which join do you use?
  • A. LEFT JOIN ✓
  • B. INNER JOIN
  • C. RIGHT JOIN (from orders)
  • D. CROSS JOIN
Correct answer: A. A LEFT JOIN keeps all rows from customers even when there is no matching order.
A query runs WHERE email = ? on a large table that has no index on the email column. What most likely happens?
  • A. The query is rejected by the database
  • B. It automatically uses the primary key
  • C. Rows are returned pre-sorted
  • D. A full table scan reads every row ✓
Correct answer: D. Without an index the database must scan every row to find matches, which is slow on large tables.
A column has a UNIQUE constraint. You insert a new row whose value already exists in that column. What happens?
  • A. The duplicate silently overwrites the old row
  • B. The insert fails with a constraint violation ✓
  • C. Both rows are kept side by side
  • D. The value is auto-incremented to stay unique
Correct answer: B. A UNIQUE constraint rejects the insert and raises a constraint-violation error.
How should you store user passwords in your database?
  • A. As plain text for easy resets
  • B. Reversibly encrypted with a shared key
  • C. Hashed with a per-user salt using bcrypt or argon2 ✓
  • D. Base64-encoded
Correct answer: C. Passwords should be one-way hashed with a salt using a slow algorithm like bcrypt or argon2.
A user is logged in but requests an admin-only endpoint they are not permitted to use. Which status code is most appropriate?
  • A. 403 Forbidden ✓
  • B. 401 Unauthorized
  • C. 404 Not Found
  • D. 400 Bad Request
Correct answer: A. 403 means the user is authenticated but lacks permission, whereas 401 means not authenticated.
Two concurrent requests both read a counter value of 5, each add 1, then write back, with no locking. What final value is stored?
  • A. 8
  • B. 7
  • C. 5
  • D. 6 ✓
Correct answer: D. Both requests read 5 and write 6, so one increment is lost and the final value is 6.
Which HTTP method is expected to be safe and should never change server state?
  • A. POST
  • B. GET ✓
  • C. PUT
  • D. DELETE
Correct answer: B. GET is a safe method meant only to retrieve data, not to modify server state.
You need to update only one field of an existing resource without touching the rest. What is the most appropriate approach?
  • A. Use PUT since it always replaces the whole resource
  • B. Delete the resource then re-create it
  • C. Use PATCH to apply a partial update ✓
  • D. Use GET with a request body
Correct answer: C. PATCH is designed for partial updates, while PUT replaces the entire resource.
You load 100 blog posts, then run a separate query for each post's author. How many queries does this pattern run?
  • A. 101 queries, hurting performance ✓
  • B. 1 query
  • C. 2 queries
  • D. 0 queries
Correct answer: A. This is the N+1 problem: 1 query for the posts plus 100 for authors equals 101 queries.
To return page 3 of results with 20 records per page in SQL, which clause is correct?
  • A. LIMIT 20 OFFSET 60
  • B. LIMIT 20 OFFSET 40 ✓
  • C. LIMIT 60 OFFSET 20
  • D. LIMIT 40 OFFSET 20
Correct answer: B. Page 3 skips the first two pages (40 rows) and returns 20, so LIMIT 20 OFFSET 40.
Inside a database transaction you update two tables, but the second update fails and the transaction is aborted. What happens to the first update?
  • A. It is committed anyway
  • B. It is retried automatically
  • C. It is rolled back ✓
  • D. It is saved as a draft
Correct answer: C. Atomicity means either all changes commit or all roll back, so the first update is undone.
Your endpoint returns a JSON body. Which response header should it set so clients parse it correctly?
  • A. Content-Type: application/json ✓
  • B. Content-Type: text/html
  • C. Accept: application/json
  • D. Content-Encoding: json
Correct answer: A. Content-Type: application/json tells the client the response body is JSON.
A foreign key on orders.customer_id referencing customers.id primarily prevents what?
  • A. It speeds up every query
  • B. It prevents duplicate orders
  • C. It blocks nulls in every column
  • D. It stops inserting an order for a customer that does not exist ✓
Correct answer: D. A foreign key enforces referential integrity, blocking orders that reference a non-existent customer.
Why use a database connection pool instead of opening a new connection for every request?
  • A. It encrypts every query
  • B. It reuses connections to avoid the cost of opening new ones ✓
  • C. It removes the need for indexes
  • D. It prevents SQL injection
Correct answer: B. Connection pools reuse established connections, avoiding the expensive setup cost per request.
A client sends far more requests than your API allows in a given window. Which status code signals this?
  • A. 503 Service Unavailable
  • B. 408 Request Timeout
  • C. 429 Too Many Requests ✓
  • D. 403 Forbidden
Correct answer: C. 429 Too Many Requests is the standard code for exceeding a rate limit.
A request arrives with a required field missing from the body. Which status code is most appropriate to return?
  • A. 400 Bad Request ✓
  • B. 500 Internal Server Error
  • C. 404 Not Found
  • D. 200 OK
Correct answer: A. A malformed or invalid client request should return 400, not a 500 server error.
Which statement best describes a stateless REST API?
  • A. The server keeps each client's session in memory
  • B. Clients must always hit the same server
  • C. State lives only in the URL path
  • D. Each request carries all the information needed to process it ✓
Correct answer: D. Statelessness means every request is self-contained and independent of prior requests.
GET /products?category=books returns 10,000 items in a single response and is slow. What is the standard fix?
  • A. Increase the request timeout
  • B. Add pagination to return results in pages ✓
  • C. Add more server RAM
  • D. Enable gzip only
Correct answer: B. Pagination limits each response to a manageable page of results, improving scalability.

Medium round 30 questions

You have a slow SQL query that filters users by `email` on a large table. The `email` column has no index. What is the most direct fix to speed up this lookup?
  • A. Add a B-tree index on the `email` column ✓
  • B. Increase the database connection pool size
  • C. Wrap the query in a transaction
  • D. Switch the query from an ORM to raw SQL
Correct answer: A. An index on the filtered column lets the database find matching rows without a full table scan, directly addressing the slow lookup.
A REST endpoint successfully creates a new resource. Which HTTP status code is the conventionally correct response?
  • A. 200 OK
  • B. 201 Created ✓
  • C. 202 Accepted
  • D. 204 No Content
Correct answer: B. 201 Created signals that the request succeeded and a new resource was created, typically with a Location header pointing to it.
In a relational database, which combination of properties does a well-designed foreign key constraint enforce?
  • A. That referenced values must exist in the parent table (referential integrity) ✓
  • B. That the column is automatically indexed and unique
  • C. That the column can never contain NULL
  • D. That rows are physically ordered by the key
Correct answer: A. A foreign key enforces referential integrity, guaranteeing that every non-null child value corresponds to an existing parent row.
Your API must remain safe to retry after network failures. Which HTTP method is expected to be idempotent, meaning repeated identical calls have the same effect as one?
  • A. POST
  • B. PUT ✓
  • C. PATCH
  • D. CONNECT
Correct answer: B. PUT is defined as idempotent because sending the same full-resource update repeatedly leaves the resource in the same final state.
You need to store a user's password. What is the correct practice?
  • A. Encrypt it with AES so it can be decrypted for comparison
  • B. Hash it with a slow, salted algorithm like bcrypt or Argon2 ✓
  • C. Store it as a base64-encoded string
  • D. Hash it once with plain MD5 for speed
Correct answer: B. Passwords should be one-way hashed with a deliberately slow, salted algorithm like bcrypt or Argon2 to resist brute-force and rainbow-table attacks.
Two concurrent requests both read a counter value of 10, each add 1, and write back 11, losing an update. What database technique most directly prevents this lost update?
  • A. Adding a database index on the counter
  • B. Using SELECT ... FOR UPDATE or an atomic UPDATE statement ✓
  • C. Increasing the query timeout
  • D. Caching the counter in Redis
Correct answer: B. Row locking (SELECT ... FOR UPDATE) or an atomic `UPDATE counter = counter + 1` serializes the read-modify-write so no update is lost.
Your service calls a flaky third-party API that sometimes times out. Which resilience pattern is most appropriate to stop hammering it while it's failing?
  • A. Circuit breaker ✓
  • B. Database sharding
  • C. Eager loading
  • D. Connection pooling
Correct answer: A. A circuit breaker trips after repeated failures and short-circuits further calls, giving the dependency time to recover instead of overwhelming it.
An ORM query loads 100 blog posts, then triggers a separate query for each post's author, resulting in 101 queries. What is this problem called and its typical fix?
  • A. Deadlock; resolved by retrying the transaction
  • B. N+1 query problem; resolved with eager loading / a JOIN ✓
  • C. Cache stampede; resolved by adding a TTL
  • D. Race condition; resolved with a mutex
Correct answer: B. This is the classic N+1 problem, fixed by eager-loading the related authors in a single JOIN or batched query.
You are designing a JWT-based auth system. Where should the token's signature be verified?
  • A. On the client before sending the request
  • B. On the server for every protected request ✓
  • C. Only once at login, then trusted for the session
  • D. Inside the database via a trigger
Correct answer: B. The server must verify the JWT signature on each protected request, since the client cannot be trusted and the token could be tampered with.
A message queue delivers messages with at-least-once semantics, so a consumer may receive the same message twice. What should the consumer be designed to be?
  • A. Stateless
  • B. Idempotent ✓
  • C. Synchronous
  • D. Transactional
Correct answer: B. An idempotent consumer produces the same result whether a message is processed once or multiple times, safely handling duplicate delivery.
You have a query that filters on WHERE status = 'active' AND created_at > ? and it does a full table scan. What is the most effective single index to add?
  • A. Separate index on status only
  • B. Separate index on created_at only
  • C. A composite index on (status, created_at) ✓
  • D. A composite index on (created_at, status)
Correct answer: C. A composite index leading with the equality column (status) then the range column (created_at) lets the engine seek the equality and range-scan efficiently.
Two concurrent transactions each read a balance, then update it based on the read value, causing one update to be overwritten. Which anomaly is this?
  • A. Dirty read
  • B. Lost update ✓
  • C. Phantom read
  • D. Non-repeatable read
Correct answer: B. A lost update occurs when one transaction's write is silently overwritten by another that read the same prior value.
In a REST API, which status code best indicates that a POST successfully created a new resource?
  • A. 200 OK
  • B. 201 Created ✓
  • C. 202 Accepted
  • D. 204 No Content
Correct answer: B. 201 Created signals successful creation, ideally with a Location header pointing to the new resource.
What problem does database connection pooling primarily solve?
  • A. It encrypts data in transit
  • B. It avoids the overhead of repeatedly opening and closing connections ✓
  • C. It guarantees ACID compliance
  • D. It replaces the need for indexes
Correct answer: B. Pooling reuses a set of open connections, avoiding the costly handshake and teardown on every request.
In JWT-based authentication, where is it safest to store the token in a browser to mitigate XSS token theft?
  • A. localStorage
  • B. An HttpOnly, Secure cookie ✓
  • C. A global JavaScript variable
  • D. sessionStorage
Correct answer: B. An HttpOnly cookie is inaccessible to JavaScript, mitigating token theft via XSS (though CSRF protections are then needed).
Which caching strategy writes to the cache and the database synchronously on every write?
  • A. Write-back
  • B. Write-through ✓
  • C. Cache-aside
  • D. Read-through
Correct answer: B. Write-through updates cache and datastore together on each write, keeping them consistent at the cost of write latency.
A message queue consumer must guarantee a message is processed exactly once, but the broker offers at-least-once delivery. What is the standard mitigation?
  • A. Increase the queue's TTL
  • B. Make the consumer operation idempotent ✓
  • C. Disable acknowledgements
  • D. Use a smaller batch size
Correct answer: B. Since at-least-once can redeliver, making processing idempotent ensures duplicates cause no harmful side effects.
What does the N+1 query problem refer to in an ORM?
  • A. Executing one query that returns N+1 rows
  • B. Running one query for a list, then one additional query per item ✓
  • C. A query that requires N+1 joins
  • D. An off-by-one error in pagination offset
Correct answer: B. The N+1 problem fires one query for the parent list and then N extra queries (one per item) for related data; eager loading fixes it.
Which HTTP header enables a client to cache a response but revalidate it with the server before reuse?
  • A. Cache-Control: no-store
  • B. Cache-Control: no-cache ✓
  • C. Cache-Control: immutable
  • D. Cache-Control: private
Correct answer: B. no-cache allows storing but forces revalidation with the origin before serving, unlike no-store which forbids storage entirely.
In an eventually consistent distributed system, what does 'read-your-own-writes' consistency guarantee?
  • A. All nodes see writes in the same order
  • B. A user always sees the effect of their own prior writes ✓
  • C. Writes are never lost
  • D. Reads always return the latest global value
Correct answer: B. Read-your-own-writes ensures a client observes its own updates immediately, even if other clients may see stale data.
A query filtering on WHERE email = ? is slow on a large users table. What is the most direct fix?
  • A. Add a LIMIT clause
  • B. Create an index on the email column ✓
  • C. Switch the table to MyISAM
  • D. Increase the connection pool size
Correct answer: B. An index on the filtered column lets the engine avoid a full table scan, directly addressing the lookup cost.
In JWT-based authentication, why is it problematic to store sensitive data in the token payload?
  • A. The payload is encrypted but slow to decode
  • B. The payload is only Base64URL-encoded, not encrypted, so anyone can read it ✓
  • C. Payloads cannot hold strings
  • D. It doubles the token's signature size
Correct answer: B. A standard JWT payload is merely Base64URL-encoded and signed, not encrypted, so its contents are readable by anyone holding the token.
What isolation-level anomaly is prevented by SERIALIZABLE but allowed by REPEATABLE READ in many databases?
  • A. Dirty reads
  • B. Lost updates only
  • C. Phantom reads (in strict SQL-standard REPEATABLE READ) ✓
  • D. Uncommitted writes
Correct answer: C. Under the SQL standard, REPEATABLE READ permits phantom reads whereas SERIALIZABLE prevents them by fully isolating transactions.
You must ensure that debiting one account and crediting another either both succeed or both fail. Which mechanism guarantees this?
  • A. A database transaction with commit/rollback ✓
  • B. A retry loop in application code
  • C. A read replica
  • D. A unique constraint
Correct answer: A. Wrapping both writes in a transaction gives atomicity: either both operations commit or the whole unit rolls back.
An endpoint is being hit far more than expected, degrading the service. Which technique directly limits per-client request volume?
  • A. Connection pooling
  • B. Rate limiting (e.g., token bucket) ✓
  • C. Database sharding
  • D. Gzip compression
Correct answer: B. Rate limiting caps how many requests a client may make in a time window, protecting the service from abuse or overload.
In an N+1 query problem with an ORM, what is the standard remedy?
  • A. Add more replicas
  • B. Use eager loading / a JOIN to fetch related rows in one query ✓
  • C. Increase the ORM cache TTL
  • D. Disable lazy evaluation globally
Correct answer: B. Eager loading (via JOIN or batched IN queries) fetches related records in a single round trip instead of one query per parent row.
Which HTTP status code is the correct semantic response when a request conflicts with the current state of the resource, such as a duplicate unique field?
  • A. 400 Bad Request
  • B. 409 Conflict ✓
  • C. 422 Unprocessable Entity
  • D. 429 Too Many Requests
Correct answer: B. 409 Conflict specifically signals that the request could not be completed due to a conflict with the resource's current state.
To safely handle a payment webhook that may be delivered more than once, the endpoint should be designed to be:
  • A. Stateless
  • B. Idempotent using a unique event/idempotency key ✓
  • C. Asynchronous only
  • D. Cached at the CDN
Correct answer: B. Idempotency (deduplicating on a unique key) ensures repeated delivery of the same webhook does not cause duplicate side effects.
What is the main advantage of using a message queue (e.g., RabbitMQ/SQS) between two services?
  • A. It guarantees SQL ACID transactions across services
  • B. It decouples producer and consumer, enabling async processing and load leveling ✓
  • C. It eliminates the need for a database
  • D. It automatically encrypts all data at rest
Correct answer: B. A queue decouples producer and consumer so they can scale and fail independently, buffering bursts and enabling asynchronous work.
When hashing user passwords for storage, which approach is correct?
  • A. MD5 with no salt for speed
  • B. A slow adaptive hash like bcrypt/argon2 with a per-user salt ✓
  • C. AES encryption with a shared key
  • D. SHA-256 once, unsalted
Correct answer: B. Passwords should use a deliberately slow, salted adaptive hash (bcrypt/scrypt/argon2) to resist brute-force and rainbow-table attacks.

Hard round 30 questions

A payment API receives duplicate POST /charge requests because the client retries on a 504 gateway timeout. Charges must never be double-applied. The request carries a client-generated `Idempotency-Key`. Which server implementation actually guarantees exactly-once effect under concurrent retries?
  • A. On each request, SELECT the key; if absent, process the charge and then INSERT the key with the result
  • B. Wrap the charge in a transaction and rely on the DB's default READ COMMITTED isolation to serialize the two requests
  • C. INSERT the idempotency key with a UNIQUE constraint FIRST in the same transaction as the charge; on duplicate-key violation, return the stored prior response ✓
  • D. Hash the request body and skip processing if an identical body was seen in the last 60 seconds
Correct answer: C. Inserting the unique key first makes the database's uniqueness constraint the concurrency gate, so exactly one transaction commits the charge and retries hit the duplicate-key path, whereas check-then-act (option 0) has a race window between SELECT and INSERT.
A hot cache key holding a homepage product list expires. Within milliseconds thousands of concurrent requests miss and all hit the database, which collapses. Besides the immediate outage, which mitigation prevents recurrence WITHOUT weakening correctness the way plain 'never expire' would?
  • A. Increase the connection pool size so the database can absorb the simultaneous rebuild queries
  • B. Use a per-key distributed lock/single-flight so only one request rebuilds the value while others briefly wait or serve the stale value ✓
  • C. Switch the cache eviction policy from LRU to LFU so hot keys are evicted less often
  • D. Shorten the TTL so the key refreshes more frequently and is never deeply stale
Correct answer: B. Single-flight (mutex/lease per key) collapses the stampede to a single database rebuild while other callers wait or serve stale, directly eliminating the thundering herd; a bigger pool just lets more queries pile on and a shorter TTL makes stampedes more frequent.
Two transactions run concurrently under a database using MVCC snapshot isolation (e.g. Postgres REPEATABLE READ). Both read the current seat count (0 booked of 1), both see a seat available, and both INSERT a booking. What actually happens, and why is this the classic gap in snapshot isolation?
  • A. One INSERT blocks until the other commits, then sees the updated count and aborts itself
  • B. Both commit successfully; snapshot isolation does not detect this write-skew because the two writes touch different rows than the ones read ✓
  • C. The second commit fails automatically with a serialization error because MVCC guarantees serializability
  • D. Both are rolled back because a phantom row was inserted by a concurrent transaction
Correct answer: B. This is write skew: each transaction reads a snapshot and writes rows the other did not read, so snapshot isolation (short of true SERIALIZABLE / SSI) allows both to commit, violating the invariant, which is why you need SELECT ... FOR UPDATE, a serializable level, or a materialized conflict row.
A Kafka consumer group processes orders. Each poll returns a batch of 500; the consumer commits offsets AFTER the whole batch is processed. A consumer instance crashes after processing 300 of 500 records but before committing. Assuming default at-least-once configuration, what happens on rebalance?
  • A. The 300 processed records are skipped and processing resumes at record 301, giving exactly-once
  • B. All 500 records are redelivered to another consumer, so the first 300 are processed twice ✓
  • C. The uncommitted 300 records are lost permanently because their offsets were fetched
  • D. Kafka replays only the 200 unprocessed records because it tracks per-record acks like a traditional queue
Correct answer: B. Kafka commits offsets per partition, not per record, so with no commit for the batch the new owner re-reads from the last committed offset and reprocesses all 500 — hence at-least-once delivery requires idempotent processing to tolerate the 300 duplicates.
Two transactions deadlock repeatedly in production: T1 updates row A then row B; T2 updates row B then row A. The database detects the cycle and aborts one victim, but throughput still suffers from frequent retries. Which fix eliminates the deadlock cycle itself rather than just handling its symptom?
  • A. Raise the deadlock detection timeout so the database waits longer before choosing a victim
  • B. Enforce a consistent global lock-acquisition order (always lock A before B) in all code paths ✓
  • C. Lower the isolation level to READ UNCOMMITTED so the updates no longer take row locks
  • D. Wrap each transaction in an application-level retry loop with exponential backoff
Correct answer: B. A deadlock requires a circular wait; acquiring resources in a consistent global order makes a cycle impossible, whereas retries and longer timeouts only cope with deadlocks after they form and READ UNCOMMITTED still takes write locks.
A write-heavy 'user activity feed' table is sharded by `shard = hash(user_id) % N`. A handful of celebrity users generate 40% of all writes, saturating a few shards. You must rebalance without downtime and stop the hot partitions. What is the soundest change?
  • A. Switch the shard key to `hash(timestamp)` so writes spread evenly across shards over time
  • B. Increase N and rehash everything at once during a maintenance window to rebalance load
  • C. Use a composite/compound shard key such as hash(user_id, bucket) that splits a hot user's writes across several sub-partitions ✓
  • D. Add read replicas to the hot shards so the write load is distributed across the replicas
Correct answer: C. Salting the key with a per-user bucket spreads a single hot user's writes across multiple partitions, curing the hotspot; timestamp keys create a moving write hotspot, and replicas do not absorb write load.
In a Saga using choreography (services react to each other's events with no central coordinator), the flow is Order → Payment → Inventory → Shipping. Inventory fails and emits a compensation event. Six months later you must add a Fraud-check step between Payment and Inventory. Which drawback of choreography does this expose most sharply?
  • A. Choreography cannot implement compensating transactions, so partial rollback is impossible
  • B. The distributed control flow is implicit across many services, making it hard to reason about, add steps to, and debug the end-to-end sequence ✓
  • C. Choreography forces synchronous calls, so adding a step increases end-to-end latency linearly
  • D. Events in choreography cannot carry a correlation ID, so tracing the saga is impossible
Correct answer: B. Choreography scatters the workflow logic across event handlers with no single place that describes the sequence, so understanding and modifying the flow is hard — the readability/maintainability tradeoff orchestration addresses by centralizing control.
An HTTP/1.1 backend service opens a new TCP connection per outbound call to a downstream dependency under high load and you observe rising latency and TIME_WAIT socket exhaustion. Migrating the client to HTTP/2 with a connection pool helps most because of which specific mechanism?
  • A. HTTP/2 compresses response bodies, reducing bytes transferred per call
  • B. HTTP/2 multiplexes many concurrent requests over a single long-lived TCP connection, avoiding per-request connect and TIME_WAIT churn ✓
  • C. HTTP/2 uses UDP instead of TCP, eliminating the TCP handshake entirely
  • D. HTTP/2 removes the need for TLS, cutting the handshake round-trips
Correct answer: B. HTTP/2 stream multiplexing lets many concurrent requests share one persistent connection, removing per-request TCP/TLS handshakes and the TIME_WAIT accumulation from connection churn; it does not use UDP (that's HTTP/3) nor drop TLS.
A service protects a slow downstream with a circuit breaker plus retries: 3 retries with exponential backoff on every failed call. During a downstream brownout, the breaker is configured to open at 50% error rate, but the outage still cascades and amplifies. What is the most likely root cause of the amplification?
  • A. The retries multiply load onto the already-struggling downstream (a retry storm) faster than the breaker trips, so aggregate traffic spikes 4x ✓
  • B. The exponential backoff jitter makes retries too slow, so the breaker never sees enough failures to open
  • C. Circuit breakers are incompatible with retries and must never be combined
  • D. The 50% threshold is too low, so the breaker opens prematurely and blocks healthy traffic
Correct answer: A. Unbounded retries stacked on a failing dependency multiply request volume (a retry storm) and amplify the overload, which is why retries need a shared retry budget, jitter, and to be suppressed while the breaker is open.
You need optimistic concurrency for a `wallets` table to prevent lost updates on balance edits. Which SQL pattern correctly detects a concurrent modification and lets the application retry, rather than silently overwriting?
  • A. UPDATE wallets SET balance = balance - 10 WHERE id = 1
  • B. UPDATE wallets SET balance = :new, version = version + 1 WHERE id = 1 AND version = :read_version, then check affected-rows = 1 ✓
  • C. SELECT balance FROM wallets WHERE id = 1 FOR UPDATE, then UPDATE with the new balance
  • D. UPDATE wallets SET balance = :new WHERE id = 1 AND balance = balance
Correct answer: B. The version-guarded UPDATE affects zero rows if another writer bumped the version since your read, signaling a conflict to retry — that compare-and-set is the essence of optimistic locking, while option 2 is pessimistic and option 0/3 can silently lose the concurrent update.
Under PostgreSQL's default READ COMMITTED isolation, a transaction runs the same range query twice and gets different row counts. Which phenomenon is NOT prevented at this level?
  • A. Dirty read
  • B. Phantom read ✓
  • C. Cascading rollback
  • D. Torn write
Correct answer: B. READ COMMITTED prevents dirty reads but still permits phantom and non-repeatable reads, since each statement sees a fresh snapshot.
In the CAP theorem, a network partition occurs between two replicas that both accept writes. To keep the system Available, which property must be sacrificed?
  • A. Partition tolerance
  • B. Consistency ✓
  • C. Durability
  • D. Isolation
Correct answer: B. During a partition, a system must choose between Consistency and Availability; staying available means tolerating temporary inconsistency.
You use optimistic concurrency with a version column. A client sends UPDATE ... SET v=v+1 WHERE id=? AND v=?. The update affects 0 rows. What does this indicate?
  • A. The row was deleted by a foreign key cascade
  • B. A concurrent transaction modified the row first ✓
  • C. The database index is corrupt
  • D. The isolation level is too high
Correct answer: B. Zero affected rows means the version no longer matches, signaling a concurrent modification that the client must retry against fresh data.
A service experiences cascading failures when a downstream dependency slows down and threads block waiting on it. Which pattern most directly prevents this?
  • A. Retry with exponential backoff
  • B. Circuit breaker ✓
  • C. Database sharding
  • D. Content negotiation
Correct answer: B. A circuit breaker trips after repeated failures/timeouts, failing fast and freeing threads instead of letting them pile up on a slow dependency.
In Kafka, a consumer group's partition is reassigned mid-batch and offsets were committed before processing completed. What is the resulting risk?
  • A. Messages are duplicated
  • B. Messages are lost (not reprocessed) ✓
  • C. The partition becomes read-only
  • D. The broker rejects the commit
Correct answer: B. Committing offsets before processing means a rebalance can skip unprocessed messages, causing data loss; commit after processing for at-least-once.
Two transactions each hold a lock the other needs, and the database aborts one. What guarantees this abort will eventually happen automatically?
  • A. Two-phase commit
  • B. Deadlock detection via a wait-for graph ✓
  • C. Write-ahead logging
  • D. Multiversion concurrency control
Correct answer: B. The engine builds a wait-for graph and, on detecting a cycle, chooses a victim transaction to abort, breaking the deadlock.
A REST endpoint must remain safe to retry after a client timeout without creating duplicate charges. Which mechanism is the industry-standard solution?
  • A. A server-side rate limiter
  • B. An idempotency key stored and checked per request ✓
  • C. A longer HTTP timeout
  • D. Switching from POST to PUT
Correct answer: B. An idempotency key lets the server detect a retried request and return the original result instead of re-executing the side effect.
In a database using MVCC, long-running read transactions can cause storage bloat. Why?
  • A. They hold exclusive write locks on every row
  • B. They prevent vacuuming of old row versions still visible to them ✓
  • C. They rewrite the entire table on commit
  • D. They duplicate indexes for isolation
Correct answer: B. Old tuple versions cannot be reclaimed while an open transaction might still need to see them, so long readers block vacuum/GC and bloat storage.
You need strictly ordered, exactly-once side effects across a distributed transaction spanning two microservices. Which pattern trades a distributed lock for eventual consistency with compensations?
  • A. Two-phase commit (2PC)
  • B. Saga pattern ✓
  • C. Leader election
  • D. Bloom filter
Correct answer: B. The Saga pattern sequences local transactions with compensating actions on failure, avoiding a blocking distributed lock at the cost of eventual consistency.
A hash-based sharding scheme rehashes all keys whenever a node is added, causing massive data movement. Which technique minimizes this reshuffling?
  • A. Range partitioning
  • B. Consistent hashing ✓
  • C. Round-robin assignment
  • D. Composite indexing
Correct answer: B. Consistent hashing maps nodes and keys onto a ring so adding/removing a node only remaps keys near that node, minimizing data movement.
Two concurrent transactions read a counter = 5, each add 1, and write 6, losing an update. Which approach prevents this lost update without full table locking?
  • A. Setting isolation to READ UNCOMMITTED
  • B. Optimistic concurrency using a version column with a conditional UPDATE ✓
  • C. Adding an index on the counter column
  • D. Using a larger connection pool
Correct answer: B. Optimistic concurrency (compare-and-set on a version/value) makes the write fail if the row changed since it was read, preventing lost updates.
In a distributed system, the CAP theorem states that during a network partition you must choose between:
  • A. Latency and throughput
  • B. Consistency and availability ✓
  • C. Durability and atomicity
  • D. Sharding and replication
Correct answer: B. CAP says that when a partition (P) occurs, a system must sacrifice either consistency or availability; it cannot guarantee both.
Why can adding an index on a low-cardinality boolean column often fail to help (and the planner ignore it)?
  • A. Boolean columns cannot be indexed
  • B. The optimizer estimates a large fraction of rows match, making a sequential scan cheaper than random index lookups ✓
  • C. Indexes require unique values
  • D. B-trees do not support equality lookups
Correct answer: B. When an index would return a large fraction of the table, random I/O per row makes a sequential scan cheaper, so the planner skips the index.
In an eventually consistent system using async replication, a user updates their profile then immediately reads it and sees stale data. What consistency guarantee would fix this specific case?
  • A. Strong consistency across all nodes
  • B. Read-your-writes (session) consistency ✓
  • C. Causal consistency for unrelated writes
  • D. Monotonic reads only
Correct answer: B. Read-your-writes consistency guarantees a client always sees its own prior writes, resolving the stale self-read after an update.
A service under load exhausts its database connection pool and requests hang. Which combination best mitigates cascading failure?
  • A. Unbounded connection creation plus infinite timeouts
  • B. Bounded pool with fast-fail timeouts and a circuit breaker ✓
  • C. Disabling connection pooling entirely
  • D. Switching all queries to SELECT *
Correct answer: B. A bounded pool with timeouts prevents unbounded resource use, and a circuit breaker sheds load fast so failures don't cascade.
In two-phase commit (2PC), what is the fundamental availability weakness?
  • A. It cannot handle more than two participants
  • B. If the coordinator fails after prepare, participants may block indefinitely holding locks ✓
  • C. It requires all nodes to share one clock
  • D. It only works on a single database
Correct answer: B. 2PC is a blocking protocol: a coordinator crash after the prepare phase can leave participants holding locks with no way to safely decide.
You need exactly-once processing semantics from an at-least-once delivery queue. What is the standard practical approach?
  • A. Enable higher QoS on the broker
  • B. Make consumers idempotent and deduplicate on a message/business key ✓
  • C. Increase the visibility timeout to infinity
  • D. Use larger batch sizes
Correct answer: B. True exactly-once delivery is generally infeasible; the practical pattern is at-least-once delivery plus idempotent consumers that dedupe by key.
A hot partition in a sharded database, caused by a monotonically increasing shard key, is best resolved by:
  • A. Adding read replicas to that shard
  • B. Choosing a shard key with high, evenly distributed cardinality (e.g., hashing the key) ✓
  • C. Increasing the shard's page cache
  • D. Lowering the isolation level
Correct answer: B. Hashing or otherwise randomizing the shard key spreads writes evenly across shards, eliminating the hotspot from sequential keys.
In a high-throughput write path, why might an append-only log-structured merge (LSM) tree outperform a B-tree storage engine?
  • A. LSM trees never need compaction
  • B. LSM converts random writes into sequential writes and buffers in memory, improving write throughput ✓
  • C. B-trees cannot store more than 4KB pages
  • D. LSM eliminates the need for a write-ahead log
Correct answer: B. LSM trees batch writes in memory and flush sequentially, turning costly random I/O into sequential I/O, which boosts write-heavy workloads.
When implementing cursor-based (keyset) pagination instead of OFFSET/LIMIT on a large table, the main benefit is:
  • A. It supports arbitrary jump-to-page navigation
  • B. Constant-time page fetches because it seeks by an indexed key rather than scanning and discarding offset rows ✓
  • C. It removes the need for an ORDER BY
  • D. It guarantees no duplicate rows regardless of concurrent inserts
Correct answer: B. Keyset pagination seeks directly via an indexed column, avoiding the growing scan-and-discard cost that makes large OFFSET values slow.

Prep for another role

Questions are original, written and independently verified for HireHire's role interview quizzes. They reflect the kind of knowledge Backend Developer interviews test, not any specific company's questions. HireHire maps live tech & IT jobs across India, updated regularly. Last updated: August 2026.