DEV Community

Dexter G
Dexter G

Posted on

I will never walk into a backend interview without solving these 20 questions.

I failed more than 20 interviews in last 10 months

I saw many time my approach fell apart as soon as the interviewer asks a follow up question about what happens inside those boxes when traffic spikes.

I compiled this list based on the questions that actually get asked in real rooms. I failed many interviews because I did not know the answers to these. I ask them now because they are excellent filters and I think they separate the people who only know the vocabulary from the people who know how the systems behave under pressure.

You just need to understand the underlying mechanics well enough to discuss them conversationally.

Databases and query performance
Databases are where most applications spend most of their time. You need to know how to get data in and out efficiently when the tables get large.

1. What happens when you put an index on a random UUID column
A lot of developers use UUIDs for primary keys because it makes distributed generation easy. But standard UUIDs are random. Inserting random values into a B-tree index causes massive page fragmentation and forces the database to write to disk constantly. You should know why sequential IDs or time sorted UUIDs fix this.

2. How do you paginate through 50 million rows without using OFFSET?
Using OFFSET and LIMIT works for the first few pages. By page ten thousand, the database is scanning and discarding huge numbers of rows before returning your data. You need to be able to explain keyset pagination (cursor based pagination) and why it keeps query times flat regardless of the page depth.
**

  1. When would you use a composite index instead of two separate indexes?** If you frequently query a table using two columns together, creating an index on column A and an index on column B is usually the wrong move. The database typically only uses one index per table scan. You need to understand how a composite index on (A, B) works and why the order of the columns matters.

4. What is the N+1 query problem and how do you fix it?
This is the most common performance bug in modern applications that use ORMs. You query a list of users, and then as you loop through the users, the ORM fires a separate query to fetch each user’s profile. You need to be able to explain how to fix it using explicit joins or eager loading.

Concurrency and transactions
Distributed systems do things at the same time. Bad things happen when you do not manage that timing.

5. How do you prevent double booking a ticket in a distributed system
Checking if a seat is available and then booking it creates a race condition. You cannot solve this with a mutex in your application code if you are running multiple servers. You need to know how to use database level locks, like a SELECT FOR UPDATE statement, or an optimistic locking strategy with version numbers.

6. What is the difference between repeatable read and serializable isolation levels?
You do not need a PhD in database theory. But you do need to know that the default isolation level in Postgres allows certain types of race conditions, and you need to know when you have to crank the isolation level up to serializable to guarantee absolute correctness.

7. How do you implement a distributed lock without creating a single point of failure?
If multiple workers need exclusive access to a resource, they need a distributed lock. Using a single Redis instance works until that instance goes down. You should be familiar with algorithms like Redlock or systems like ZooKeeper that handle distributed consensus.

8. How do you implement idempotency for a payment retry endpoint?
Mobile networks drop connections. Clients will retry requests. If a client retries a payment request because they did not receive the success response, you cannot charge their card twice. You need to explain how to use idempotency keys and where to store them to guarantee exactly once processing.

Caching strategy
Everyone knows caching makes things faster. Interviewers want to know if you understand how caching makes things break.

9. What causes a cache stampede and how do you prevent it?
When a highly requested cache key expires, thousands of requests miss the cache simultaneously and hit the database at the exact same moment. The database falls over. You need to know how to prevent this using probabilistic early expiration or a lock to ensure only one thread regenerates the cache.

10. If you cache a user profile, how do you invalidate it when they update their email?
Cache invalidation is a genuinely hard problem. You need to explain the difference between a write-through cache and a cache-aside pattern, and discuss the tradeoffs of setting a short time-to-live versus explicitly deleting the key on every update.

11. Why might putting Redis in front of your database actually slow your system down?
Adding a network hop to check a cache takes a few milliseconds. If your cache hit rate is terrible, you are paying the network penalty on every request just to find out the data is not there, and then hitting the database anyway. You should know how to monitor and calculate cache hit ratios.

12. What eviction policy makes sense for a session store versus a content feed?
Caches run out of memory. When they do, they have to delete something to make room. Least Recently Used makes sense for a content feed. It is a terrible choice for a session store where you might log active users out randomly.

APIs and network architecture
Your API is a contract. You have to know how to change it safely and protect it from abuse.

13. How do you safely change the payload of a live API without breaking existing mobile clients?
Mobile apps live on user devices for years without being updated. If you change a response format and remove a field, old apps will crash. You need to understand API versioning via headers or URLs, and how to maintain backwards compatibility.

14. What is the difference between a sliding window log and a fixed window counter for rate limiting?
A fixed window counter lets clients burst double their allowed limit right at the boundary between two minutes. A sliding window smooths out the limit. You should be able to explain the mechanics and the memory tradeoffs of both approaches.

15. How do you design an endpoint that needs to upload a 5GB video file?
You cannot read a 5GB file into memory on your application server. It will kill the process. You need to explain streaming uploads, multipart chunking, or using pre assigned URLs to let the client upload directly to cloud storage.

16. How do you handle long running tasks in a synchronous API request?
If an endpoint triggers a PDF generation that takes forty seconds, the client connection will likely timeout. You need to explain the asynchronous worker pattern. The API returns a 202 Accepted with a job ID immediately, and the client polls a separate endpoint to check the status.

Message brokers and asynchronous processing
Real systems decouple work. You need to know what happens when those decoupled pieces fail.

17. Why would you choose RabbitMQ over Kafka, or vice versa?
They are not interchangeable. Kafka is a distributed log built for high throughput and replayability. RabbitMQ is a smart broker built for complex routing and task queues. You need to know which one fits your use case.

18. What happens if your Kafka consumer reads a message but fails to commit the offset?
The consumer will read the same message again when it restarts. Your processing logic has to be idempotent, or you will process the data twice.

19. How do you handle poison messages that repeatedly crash your workers?
If a malformed message causes a null pointer exception in your worker, the worker crashes, the message goes back to the queue, and another worker picks it up and crashes. You need to explain Dead Letter Queues and retry limits.

20. How do you ensure messages are processed in the exact order they were sent?

In a distributed queue with multiple consumers, order is almost impossible to guarantee because consumer A might take longer to process message 1 than consumer B takes to process message 2. You need to explain partitioning or routing keys that ensure related messages go to the same single consumer thread.

This list looks intimidating if you try to memorize it in a weekend but I think it is completely manageable if you take the time to understand the problems these concepts solve.

Every single one of these questions is about dealing with scale, failure, and reality. The database gets slow. The network drops. The users send bad data. Senior engineers spend their days mitigating these exact problems. For practicing questions, i generally do LCs, and some from here. and mainly brush up on basics like bytebytego and system design primer.

I would say try to understand the pain points. When you understand the pain points, the answers make sense.

Top comments (0)