🍃

Spring Boot & Microservices

Spring Boot core, dependency injection, REST APIs, JPA/Hibernate, transactions, Spring Security, and the microservices patterns — service discovery, API gateway, resilience, messaging — that hold a distributed system together.

Spring Boot Core

HikariCP & Connection Pool

Dependency Injection & Core

Spring MVC vs WebFlux vs Virtual Threads

Kafka: Producer, Consumer & Idempotency

Q

How do you achieve Kafka producer idempotency and exactly-once processing?

advancedPro

Tests whether you know enable.idempotence alone only prevents duplicate writes at the broker, not end-to-end exactly-once.

Q

A database update succeeds, but publishing the corresponding Kafka event fails. How do you maintain consistency?

advancedPro

Tests whether you know this is the classic dual-write problem, and that the Outbox Pattern is the real fix, not a retry loop.

Q

What happens if a Kafka consumer processes a message successfully but crashes before committing the offset?

advancedPro

Tests whether you know the message will be redelivered, which is exactly why consumer-side idempotency is non-negotiable.

Q

Kafka consumer lag suddenly spikes in production. What do you check first?

advancedPro

Tests whether you know to check for GC pauses freezing poll(), slow downstream calls in the consumer, or an actual rebalance loop.

Q

One Kafka partition is overloaded while others sit idle. What could cause this?

advancedPro

Tests whether you know a poorly chosen partition key (like a low-cardinality field) creates a hot partition.

Q

Why do Kafka consumer groups keep rebalancing every few minutes, and how do you minimize the disruption?

advancedPro

Tests whether you know session timeouts, slow processing exceeding max.poll.interval.ms, and static membership all factor in.

Q

You have 10 consumers in a group but only 3 Kafka partitions. How many consumers actually process messages?

intermediatePro

Tests whether you know partition count is a hard ceiling on consumer parallelism within a group — the extra 7 sit idle.

Q

A Kafka message reaches the Dead Letter Topic. How do you safely reprocess it after fixing the underlying issue?

advancedPro

Tests whether you know to replay from the DLT deliberately rather than just deleting and hoping the source retries.

Q

What is enable.auto.commit=false and why do senior engineers prefer it over the default?

advancedPro

Tests whether you know manual commit lets you commit only after successful processing, avoiding silent message loss.

Q

How do you implement a transactional Kafka producer in Spring Boot for exactly-once semantics?

advancedPro

Tests whether you know transactional.id and KafkaTransactionManager, and what read_committed means for downstream consumers.

Q

What is the significance of max.poll.records and max.poll.interval.ms in preventing consumer rebalancing?

advancedPro

Tests whether you know a slow batch that exceeds max.poll.interval.ms triggers a rebalance even though the consumer is still alive.

Q

A payment service's Kafka consumer lag jumps from 500 to 2 million messages in 30 minutes with unchanged producer throughput, and your SLA requires 5-second processing. How do you diagnose and fix it?

advancedPro

Tests whether you can reason through a real high-stakes production incident, not just recite the theory around lag.

Q

Design exactly-once semantics for a fund-transfer payment microservice — no double debit, no lost credit.

expertPro

Tests whether you can combine idempotent producers, Kafka transactions, and a transactional outbox into one coherent design.

Hibernate Internals

Redis & Caching

Q

How do you prevent a cache stampede when using Spring's @Cacheable annotation?

advancedPro

Tests whether you know @Cacheable alone doesn't coalesce concurrent misses, and what actually does (locking, soft TTL).

Q

Redis is down. Should your application also go down? How would you design the fallback?

advancedPro

Tests whether you know caching should degrade gracefully to the database, not become a hard dependency that takes down the app.

Q

How would you solve the cache invalidation problem when multiple service instances are running?

advancedPro

Tests whether you know local in-memory caches need a coordination mechanism (pub/sub or shared cache) to stay consistent across instances.

Q

What are the different Redis eviction policies and when would you choose each?

advancedPro

Tests whether you know the tradeoffs between allkeys-lru, volatile-lru, allkeys-lfu, and the noeviction default.

Q

How do you implement distributed locking using Redis — SETNX vs Redisson?

advancedPro

Tests whether you know the difference between a raw atomic SETNX-with-TTL lock and a library that handles renewal and edge cases for you.

Q

What is the problem with a distributed lock expiring before the job holding it completes?

advancedPro

Tests whether you know a second process can acquire the 'freed' lock while the first is still working, causing double-processing.

Q

What is a Redis pipeline and how does it improve performance?

advancedPro

Tests whether you know batching commands avoids paying a network round trip for every single Redis call.

Q

What is the difference between Redis Cluster and Redis Sentinel?

advancedPro

Tests whether you know one shards data across nodes for scale while the other provides high availability via failover for a single dataset.

Q

How do you handle cache warming after a deployment or Redis restart to avoid a cold-cache traffic spike hitting the database?

advancedPro

Tests whether you know to proactively pre-populate hot keys instead of letting production traffic discover the cold cache.

Q

What is cache penetration — requests for keys that don't exist, each falling through to the database? How do you fix it with a Bloom Filter?

advancedPro

Tests whether you know a Bloom Filter can cheaply reject requests for keys that provably don't exist, before they ever reach the DB.

Q

After enabling caching, your database load drops as expected, but memory usage keeps climbing. What might be wrong?

advancedPro

Tests whether you know unbounded cache growth (no TTL, no max size) silently turns a cache into a memory leak.

Transactions & Concurrency

Distributed Transactions & Saga

Q

What is the Two-Phase Commit (2PC) protocol and why is it not recommended for microservices?

advancedPro

Tests whether you know 2PC's blocking coordinator model doesn't scale and creates a single point of failure across services.

Q

When would you use the Saga pattern, and how would you handle a compensation transaction that itself fails?

advancedPro

Tests whether you've thought past the happy path — what happens when the undo step doesn't work either.

Q

Payment succeeds, but the Order Service crashes right after. How do you recover safely without losing money or the order?

advancedPro

Tests whether you can reason through a concrete Saga recovery scenario, not just define the pattern abstractly.

Q

How do you achieve exactly-once business processing on top of an at-least-once messaging system?

expertPro

Tests whether you know the trick isn't stopping duplicates from arriving — it's making processing idempotent so duplicates are harmless.

Q

What is the dual-write problem in microservices, and how does the Outbox Pattern solve it?

advancedPro

Tests whether you know writing to a DB and publishing an event are two separate operations that can't be made atomic without help.

Q

How does the Transactional Outbox Pattern work with Debezium or Change Data Capture (CDC)?

advancedPro

Tests whether you know CDC tails the database's own write-ahead log to publish outbox rows, instead of a fragile polling loop.

Q

How do you handle outbox table growth in a high-throughput system?

advancedPro

Tests whether you know to prune published rows and index the table correctly so it doesn't become its own bottleneck.

Q

What is eventual consistency, and how would you explain it to a non-technical business stakeholder?

advancedPro

Tests whether you can translate a technical consistency model into a concrete business-facing tradeoff.

Q

How do you test distributed transactions in a microservices architecture?

advancedPro

Tests whether you know this needs dedicated integration environments and event-assertion tooling, not just unit tests per service.

Q

What is the difference between the Outbox Pattern and the Saga Pattern — are they complementary or competing?

advancedPro

Tests whether you know Outbox solves reliable event publishing while Saga solves multi-step business transaction coordination — they're often used together.

Q

How do you implement the Inbox Pattern for idempotent message consumption?

advancedPro

Tests whether you know tracking processed message IDs in a dedicated table is the consumer-side mirror of the Outbox Pattern.

API Design, Performance & Resilience

Q

An API works perfectly with 100 concurrent users but times out at 10,000, even though CPU sits at only 40%. Why?

expertPro

Tests whether you know low CPU with high failure at scale usually points to thread pool or connection pool saturation, not compute.

Q

Average API latency is 200ms, but p99 is 8 seconds. What is the real problem, and why does average latency hide it?

advancedPro

Tests whether you know averages mask tail latency, and that a small fraction of very slow requests is often the actual production issue.

Q

Retries are making an outage worse instead of better. How does a retry storm actually happen, and how do you prevent it?

advancedPro

Tests whether you know synchronized retries without jitter can pile onto an already-struggling service and push it further down.

Q

When would you use a Circuit Breaker, a Retry, a Timeout, and a Bulkhead pattern — and how do they combine?

advancedPro

Tests whether you know these four resilience patterns solve different failure modes and are usually layered together, not chosen one at a time.

Q

Where would you store an idempotency key, and how do you handle two concurrent requests arriving with the same key?

advancedPro

Tests whether you've thought through the race condition of two identical requests landing at nearly the same instant.

Q

The same resource is updated from two devices simultaneously. How do you prevent one update from silently overwriting the other?

advancedPro

Tests whether you know optimistic locking (a version check) catches this cleanly without holding a lock the whole time.

Q

Two users try to book the last available seat at the exact same moment. How do you prevent double booking?

advancedPro

Tests whether you can pick correctly between optimistic locking, pessimistic locking, or an atomic decrement for this exact scenario.

Q

How would you process a 5GB CSV file upload without causing an OutOfMemoryError?

advancedPro

Tests whether you know to stream and process the file line by line instead of loading it entirely into memory first.

Q

How would you trace one request as it flows across five microservices and millions of log entries?

advancedPro

Tests whether you know a propagated correlation ID plus distributed tracing is what makes this actually possible.

Q

Your API's SLA is 1 second, but a downstream dependency's timeout is set to 2 seconds. What's wrong with this design?

advancedPro

Tests whether you know timeout budgets must cascade correctly — a downstream timeout longer than your own SLA guarantees you'll breach it.

Q

How do you implement API versioning — URI versioning vs header versioning vs media type versioning — and what are the tradeoffs of each?

advancedPro

Tests whether you know the practical implications each approach has for clients, caching, and backward compatibility.

Design Patterns for Distributed Systems

SOLID Principles in Practice

Q

Your PaymentService has 15 if-else branches for different payment types. Which SOLID principle is being violated, and how would you refactor it?

advancedPro

Tests whether you can spot an Open/Closed Principle violation in real code and know Strategy pattern is the standard fix.

Q

Can a class with only a single method still violate the Single Responsibility Principle?

advancedPro

Tests whether you know SRP is about reasons to change, not method count — a single method can still mix multiple concerns.

Q

When does implementing the Open/Closed Principle become over-engineering?

advancedPro

Tests whether you know abstracting for change that will never actually happen just adds indirection with no payoff.

Q

What happens when a child class compiles fine but returns unexpected results compared to its parent contract?

advancedPro

Tests whether you know this is a Liskov Substitution violation even without a compile error — the contract broke silently.

Q

What problems do 'fat interfaces' create in large systems, and how would you split one without breaking existing consumers?

advancedPro

Tests whether you know a bloated interface forces implementers to depend on methods they don't use, and how to migrate safely.

Q

What is the difference between Dependency Injection and Dependency Inversion? Does using @Autowired automatically guarantee DIP?

advancedPro

Tests whether you know DI is a mechanism while DIP is a design principle, and injecting a concrete class still violates DIP.

Q

How do SOLID principles apply at the microservice level, not just the class level — is SRP applicable to service boundaries?

advancedPro

Tests whether you can map object-oriented design principles onto architectural decisions about service decomposition.

Q

Looking at a 2000-line service class, which SOLID violations would you expect to find first, and how would you start refactoring it?

advancedPro

Tests whether you have a practical, prioritized approach to untangling a real legacy God class, not just theory.

Kubernetes & Production Ops

Q

Your Kubernetes pod keeps restarting, but application logs show no clear error. How would you debug it?

advancedPro

Tests whether you know to check kubectl describe, previous container logs, OOMKilled status, and probe configuration.

Q

What is the difference between liveness, readiness, and startup probes in Kubernetes, and why does confusing liveness with readiness matter for Spring Boot?

intermediatePro

Tests whether you know a common pitfall: using the same health endpoint for both can cause unnecessary pod restarts.

Q

What is a CrashLoopBackOff and how do you debug it?

advancedPro

Tests whether you know Kubernetes' exponential backoff behavior for repeatedly-crashing containers and how to find the root cause fast.

Q

What is a PodDisruptionBudget and why is it important during rolling deployments?

advancedPro

Tests whether you know it prevents voluntary disruptions (like node drains) from taking down too many replicas at once.

Q

How do you implement graceful shutdown in a Spring Boot microservice running in Kubernetes so in-flight requests aren't dropped?

advancedPro

Tests whether you know server.shutdown=graceful, a SIGTERM handler, and a preStop hook all need to work together.

Q

One pod consistently receives 80% of the traffic while the remaining pods stay nearly idle. Why might this happen?

advancedPro

Tests whether you know client-side connection reuse or a misbehaving load-balancing algorithm can defeat even distribution.

Q

A scheduled job runs once locally but five times after scaling to five pods. How do you prevent this duplicate execution?

advancedPro

Tests whether you know a @Scheduled job needs a distributed lock (or ShedLock) to run exactly once across a clustered deployment.

Q

Your Spring Boot application takes 5 minutes to start in production but only 20 seconds locally. How do you debug it?

advancedPro

Tests whether you know to check DB connectivity latency, DNS resolution, and autoconfiguration scanning under production networking.

Q

What is the difference between resource requests and resource limits in Kubernetes, and what happens if limits are exceeded?

advancedPro

Tests whether you know exceeding a CPU limit throttles the pod while exceeding a memory limit gets it OOMKilled outright.

Database Migrations