Thundering herd problem

Short description: Resource allocation problem in computer science

The thundering herd problem is a performance-degrading phenomenon in computer science and computer networking that occurs when a large number of processes or threads are simultaneously awakened, typically in response to a specific event or the availability of a resource. However, only one process is able to respond to the event or access the new resource, causing most other processes to fail and go back to sleep. This unnecessary awakening consumes CPU and other system resources, potentially reducing overall performance and slowing the process that succeeds.[1]

When the thundering herd problem occurs while attempting to access a cache, it is often referred to as a cache stampede.[2]

## Contents

* 1 Mitigation
* 2 See also
* 3 References
* 4 External links

## Mitigation

The Linux kernel serializes responses for requests to a single file descriptor, so only one thread or process is woken up.[3] For `epoll()` in version 4.5 of the Linux kernel, the EPOLLEXCLUSIVE flag was added. Thus several epoll sets (different threads or different processes) may wait on the same resource and only one set will be woken up. For certain workloads this flag can give significant processing time reduction.[4]

Similarly in Microsoft Windows, I/O completion ports can mitigate the thundering herd problem, as they can be configured such that only one of the threads waiting on the completion port is woken up when an event occurs.[5]

In systems that rely on a backoff mechanism (e.g. exponential backoff), the clients will retry failed calls by waiting a specific amount of time between consecutive retries. In order to avoid the thundering herd problem, jitter can be purposefully introduced in order to break the synchronization across the clients, thereby avoiding collisions. In this approach, randomness is added to the wait intervals between retries, so that clients are no longer synchronized.

## See also

* Process management (computing)
* Lock convoy
* Sleeping barber problem
* TCP global synchronization
* Cache stampede

## References

1. ↑ "Thundering Herd Problem". http://www.catb.org/jargon/html/T/thundering-herd-problem.html. Retrieved 9 July 2019.
2. ↑ Platform, The Tech (2023-06-06). "How to prevent cache Stampede ( thundering herd) problems" (in en). https://www.thetechplatform.com/post/how-to-prevent-cache-stampede-thundering-herd-problems.
3. ↑ "Does the Thundering Herd Problem exist on Linux anymore". https://stackoverflow.com/a/23002010/56280.
4. ↑ Madars, Vitolins (2015-12-05). "EPOLLEXCLUSIVE Linux Kernel patch testing" (in en). https://mvitolin.wordpress.com/2015/12/05/endurox-testing-epollexclusive-flag/.
5. ↑ "IO Completion Ports — Matt Godbolt's blog". https://xania.org/200807/iocp.

## External links

* A discussion of this observation on Linux
* Better Retries with Exponential Backoff and Jitter

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Thundering herd problem. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Thundering_herd_problem&oldid=4228310"