Skip to content

Commit 5a67b62

Browse files
committed
Minor rewords
1 parent 2d126db commit 5a67b62

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

rate_limiter.rst

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -356,18 +356,15 @@ the :class:`Symfony\\Component\\RateLimiter\\Reservation` object returned by the
356356
}
357357
}
358358

359-
Storing Rate Limiter State: Caching
360-
-----------------------------------
359+
Storing Rate Limiter State
360+
--------------------------
361361

362-
All rate limiter policies require to store the state of the rate limiter
363-
(e.g. how many hits were already made in the current time window). This
364-
state is stored by default using the :doc:`Cache component </cache>`.
362+
All rate limiter policies require to store their state(e.g. how many hits were
363+
already made in the current time window). By default, all limiters use the
364+
``cache.rate_limiter`` cache pool created with the :doc:`Cache component </cache>`.
365365

366-
The default cache pool used by all limiters is ``cache.rate_limiter``. You
367-
can modify this cache pool by :ref:`defining a "rate_limiter" pool <cache-create-pools>`.
368-
369-
You can also override the pool for a specific limiter using the ``cache_pool``
370-
option:
366+
Use the ``cache_pool`` option to override the cache used by a specific limiter
367+
(or even :ref:`create a new cache pool <cache-create-pools>` for it):
371368

372369
.. configuration-block::
373370

@@ -428,19 +425,19 @@ option:
428425
Instead of using the Cache component, you can also implement a custom
429426
storage. Create a PHP class that implements the
430427
:class:`Symfony\\Component\\RateLimiter\\Storage\\StorageInterface` and
431-
set the ``storage_service`` setting of each limiter to the service ID
428+
use the ``storage_service`` setting of each limiter to the service ID
432429
of this class.
433430
434431
Using Locks to Prevent Race Conditions
435432
--------------------------------------
436433
437-
Rate limiting can be affected by race conditions, if the same limiter is
438-
applied to simultaneous requests (e.g. 3 servers of the same client call
439-
the same API). To prevent these race conditions, the rate limiting
440-
operations are protected using :doc:`locks </lock>`.
434+
`Race conditions`_ can happen when the same rate limiter is used by multiple
435+
simultaneous requests (e.g. three servers of a company hitting your API at the
436+
same time). Rate limiters use :doc:`locks </lock>` to protect their operations
437+
against these race conditions.
441438
442-
By default, the global lock (configured by ``framework.lock``) is used. You
443-
can use a specific :ref:`named lock <lock-named-locks>` via the
439+
By default, Symfony uses the global lock configured by ``framework.lock``), but
440+
you can use a specific :ref:`named lock <lock-named-locks>` via the
444441
``lock_factory`` option:
445442
446443
.. configuration-block::
@@ -502,3 +499,4 @@ can use a specific :ref:`named lock <lock-named-locks>` via the
502499
.. _`NGINX rate limiting`: https://www.nginx.com/blog/rate-limiting-nginx/
503500
.. _`token bucket algorithm`: https://en.wikipedia.org/wiki/Token_bucket
504501
.. _`PHP date relative formats`: https://www.php.net/datetime.formats.relative
502+
.. _`Race conditions`: https://en.wikipedia.org/wiki/Race_condition

0 commit comments

Comments
 (0)