The thundering herd problem occurs when multiple concurrent requests cause cache misses for the same key, leading all requests to hit the database simultaneously and defeating the purpose of caching. The post demonstrates this issue with a Spring Boot application using Redis cache and Postgres database, then presents two solutions: distributed locking using Redis and in-process synchronization with CompletableFuture and ConcurrentHashMap. The distributed lock approach works across multiple nodes but requires additional network calls, while in-process synchronization is faster but only coordinates requests within a single node.

8m read timeFrom distributed-computing-musings.com
Post cover image
1 Comment

Sort: