Good questions in interview
- Posted
- 7 May 2025
Summary
I encountered various specific technical questions during my recent backend interviews, covering Java, Spring Boot, system design, Kafka, and low-level design, and provided my approaches to solving them.
How it went
π During my recent backend interviews, I encountered some intriguing questions I came across. Here's some of them :
β Java + Spring Boot Q: How do you configure thread pools in Spring Boot to ensure efficient task execution under high load? β Used ThreadPoolTaskExecutor to manage thread pools. β Tuned corePoolSize and maxPoolSize based on whether tasks were CPU-bound or IO-bound. β Adjusted keepAliveTime to recycle idle threads and reduce resource usage.
π System Recovery with Backlog Processing Q: Your app handles 100 RPS and each task takes 100ms. A 5-minute outage means 30K pending tasks. Once restored, how do you process backlog + new incoming traffic in 5 minutes? β Needed to support 200 RPS (100 backlog + 100 new). β Designed executor with sufficient thread pool and queue capacity. β Discussed scaling strategies: using separate executors to meet deadlines.
π§© Singleton Injecting a Request-Scoped Bean Q: Why does injecting a @RequestScope bean into a singleton fail in Spring Boot? β Request-scoped beans are instantiated per HTTP request, but singleton beans are created at app startup. π§ Fixes: Used ObjectFactory, Provider, or enabled proxying for lazy injection.
π @RefreshScope in Spring Cloud Q: What is the role of @RefreshScope in dynamic configuration updates? β Allows runtime refresh of beans when config values change in Spring Cloud Config. β Works with Spring Cloud Bus to auto-propagate config changesβno app restart needed.
π© Kafka Q: If a Kafka consumer fails to process a message, how do you retry it 5 times and eventually discard it? β Built retry logic using separate retry topics with increasing backoff. β After 5 attempts, failed messages are sent to a Dead Letter Queue (DLQ) for logging or manual handling. β Ensures fault-tolerance without losing messages silently.
π§± LLD β Canvas Fill Tool ποΈ Design an MS Paint-like canvas fill backend: Q: Users can draw closed shapes. If they click inside, the entire shape should be filled. Clicking outside fills only that pixel. β Tracked shape boundaries. β Used Flood Fill Algorithm (DFS/BFS) to propagate fill from clicked pixel until boundaries are hit. β Ensured scalability for large canvases and concurrent fill operations.
βοΈ Infra & System Design π¦ PostgreSQL Internals Q: How does PostgreSQL optimize query execution and data retrieval? β Discussed B-Tree and GIN indexes.
π Kubernetes Service Discovery Q: Pod IPs change frequently. How do services reliably discover and communicate with each other? β Kubernetes assigns a stable ClusterIP to each service.
π¬ Designing a Pub/Sub System Q: How do you implement a loosely-coupled publisher-subscriber architecture? β Used Observer Pattern, Event Bus libraries, or message brokers like Kafka/RabbitMQ.
Questions asked (8)
- 01
System Recovery and Backlog Processing
System Design
Your app handles 100 RPS and each task takes 100ms. A 5-minute outage means 30K pending tasks. Once restored, how do you process backlog + new incoming traffic in 5 minutes?
- 02
Injecting Request-Scoped Bean into Singleton in Spring Boot
Other
Why does injecting a @RequestScope bean into a singleton fail in Spring Boot?
- 03
Role of @RefreshScope in Spring Cloud
Other
What is the role of @RefreshScope in dynamic configuration updates?
- 04
Kafka Consumer Retry and Dead Letter Queue
System Design
If a Kafka consumer fails to process a message, how do you retry it 5 times and eventually discard it?
- 05
Low-Level Design: MS Paint-like Canvas Fill Backend
Data Structures & Algorithms
Users can draw closed shapes. If they click inside, the entire shape should be filled. Clicking outside fills only that pixel.
- 06
PostgreSQL Query Optimization
System Design
How does PostgreSQL optimize query execution and data retrieval?
- 07
Kubernetes Service Discovery
System Design
Pod IPs change frequently. How do services reliably discover and communicate with each other?
- 08
Designing a Loosely-Coupled Pub/Sub System
System Design
How do you implement a loosely-coupled publisher-subscriber architecture?