Flood Semaphore

Component ID

2232747

Component name

Flood Semaphore

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Downloads

465

Component created

Component changed

Component body

This module provides an API that implements semaphores using flood API.

A semaphore is more than a lock. A lock is usually used in a binary
situation, it is either locked or it is not. A semaphore is used to
control the number of concurrent things that can happen.

The best use case example for using a semaphore is when a PHP process
calls a third party service for data. This is a potential bottleneck.
Web servers have some limit to the number of processes. And every PHP
process waiting on a third party service is another process just
waiting. If you have too many waiting PHP processes, the web server
will hang and stop serving other pages.

One frequent solution to this is to force the third party calls onto
the client in JavaScript. But for cases where authentication is
required, keeping this server side is the only option.

To guard against this potential bottleneck, use a semaphore around
any calls that trigger a third party offsite request from within PHP.