
1. How do you handle concurrent updates in microservices?
Answer:Use 3 approaches:
- Optimistic Locking
- Add version field
- Reject if version mismatch
- Pessimistic Locking
- Lock resource during update
- Slower but safer
- Idempotency
- Unique request ID
- Prevent duplicate updates
"I prefer optimistic locking with retries for scalability."
2. A service is sending incorrect events. How do you prevent system-wide impact?
Answer:- Validate schema (contract-based design)
- Ignore invalid events
- Use idempotency
- Apply circuit breaker
- Monitor logs & alerts
3. How do you trace a request across multiple services?
Answer:- Generate Trace ID
- Pass via headers
- Log the same ID in all services
- OpenTelemetry
- Jaeger
- Zipkin
"Distributed tracing is critical for debugging microservices."
4. Messages are stuck in queue. How do you debug?
Answer:- Check poison message
- Restart failed consumers
- Increase worker instances
- Optimize slow APIs
- Control producer rate
5. Internal service exposed publicly. How do you secure it?
Answer:- Use API Gateway
- Enable service-to-service auth (JWT)
- Apply rate limiting
- Restrict network access
"Zero trust even inside microservices."
6. How do you roll out a feature to only 10% users?
Answer:- Use hash(userId) % 100
- Enable for subset (e.g., 0โ9)
- Consistency
- Controlled rollout
7. Too many inter-service calls โ high latency. Fix?
Answer:- API Composition layer
- Use caching (Redis)
- Avoid redundant calls
- Use async communication
"Chatty services kill performance."
8. How do you break a monolith into microservices safely?
Answer:- Identify bounded contexts
- Extract gradually
- Use strangler pattern
- Maintain backward compatibility
9. Users face latency globally. Solution?
Answer:- Deploy in multiple regions
- Use Geo-routing
- Add CDN & caching
- Use DB replication
10. How do you ensure high reliability for critical systems?
Answer:- Multiple service instances
- Data replication
- Retry + failover
- Strong validation + transactions
11. Design system for millions of requests/sec
Answer:- Stateless services
- Horizontal scaling
- Load balancer
- Async processing (Kafka)
- DB sharding + replicas
12. CPU spike in production. How do you debug?
Answer:- Check recent deployments
- Analyze traffic spike
- Identify heavy APIs
- Optimize DB queries
13. How to design real-time systems (chat/notifications)?
Answer:- Use WebSockets
- Message queue (Kafka/RabbitMQ)
- Store messages in DB
- Handle offline users
14. Third-party API failures. How to handle?
Answer:- Add timeouts
- Retry with limits
- Circuit breaker
- Fallback responses
- Show cached data if API fails
15. One request triggers 50+ service calls. Good design?
Answer:Problems:
- High latency
- Failure risk
- System overload
- API aggregation
- Caching
- Data denormalization
16. Microservices vs Monolith under high latency?
Answer:- Microservices suffer due to network calls
- Monolith may perform better
"Microservices are not always the best choice."
17. How do you test microservices?
Answer:- Unit Testing
- Integration Testing
- End-to-End Testing
18. How to scale without downtime?
Answer:- Blue-Green deployment
- Rolling updates
- Read replicas
- Gradual traffic shift
19. How do you handle schema changes?
Answer:- Backward compatible changes
- Add new fields first
- Gradual migration
- Remove old fields later
Pro Interview Strategy (Very Important)
When answering:- Start with problem understanding
- Give 2โ3 approaches
- Mention trade-offs
- Add real-world example
Quick Summary
| Area | Key Concept |
|---|---|
| Consistency | Optimistic locking, idempotency |
| Reliability | Retry, circuit breaker |
| Scalability | Stateless + horizontal scaling |
| Observability | Trace ID, logging |
| Performance | Caching, async processing |