Backend Engineer · interview questions
Backend Engineer interview questions: scenario
From the role's core and recommended topics, most asked first. Filter by the kind of answer the question wants.
API Design Core 1
Caching Core 4
- How do you keep cache and database consistent on writes?
- Your Redis cluster has one shard at 100% CPU while others idle. What's likely and how do you fix it?
- How do you keep in-process L1 caches on many pods consistent?
- After adding a Redis cache, users sometimes see stale or wrong data. How do you investigate and fix it?
Databases & Transactions Core 1
Testing Core 4
Database Concurrency & Scaling Recommended 7
- Most asked Two customers buy the last item at the same moment and both orders are confirmed. What happened, and how do you prevent it?
- Most asked After a deploy, logs show hundreds of 'deadlock detected' errors per hour on checkout. Walk through how you'd investigate.
- Most asked Your service throws 'connection pool exhausted' errors but database CPU is only 20%. What's going on?
- A 20 ms ALTER TABLE caused a multi-minute outage. Explain and prevent it.
- An API's deep pages are slow and a sync job sees duplicate and missing rows. What would you change?
- You have 14 services autoscaling against one Postgres and hit 'too many clients'. What's the long-term fix?
- Your read replicas lag 40 seconds during a nightly import. What do you do?
Performance & Scalability Recommended 1
Logging & Observability Recommended 2
Web Framework Internals Recommended 5
- What does PHP-FPM's capacity depend on, and why can it fail with low CPU usage?
- Scenario: users get 504 errors but your application logs show those requests succeeding. What is happening?
- Scenario: after moving to an async framework, every endpoint becomes slow whenever one partner API is slow. Why?
- Scenario: an API returns 500 instead of 401 for expired tokens. In which frameworks have you seen this and why?
- Scenario: one new endpoint leaked other customers' data while forty others were fine. How do you prevent this class of bug?
Design Patterns Recommended 8
- Most asked Scenario: your checkout supports card and PayPal, and the business adds a new payment provider every quarter. How would you design it?
- Most asked Scenario: when an order is placed, several systems (email, inventory, analytics, loyalty) must react, and more will be added. How do you design it?
- Scenario: you need undo/redo in a drawing or text editor. Which pattern would you use?
- Scenario: a third-party SDK you must use has a completely different interface from the rest of your code. What do you do?
- Scenario: a class has a constructor with ten parameters, many optional. How would you improve it?
- Scenario: you need to add caching and logging to an existing service without modifying it. How?
- Scenario: every method of an `Order` class starts with a switch on `status`. How would you refactor it?
- Scenario: product categories contain products and subcategories to any depth, and you need totals per category. Which pattern fits?