Skip to content

Commit c149fe9

Browse files
committed
minor #15363 [RateLimiter] Closes #15034 adds information about the lock being nullable (0x346e3730)
This PR was merged into the 5.3 branch. Discussion ---------- [RateLimiter] Closes #15034 adds information about the lock being nullable Closes #15034 by adding documentation about the ability to make the lock factory null to disable this behavior. It also adds a "new in sf 5.3" text about the login throttling that has it disabled by default. Commits ------- abfb19d Closes \#15034 adds information about the lock being nullable
2 parents e93b922 + abfb19d commit c149fe9

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

rate_limiter.rst

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,9 @@ simultaneous requests (e.g. three servers of a company hitting your API at the
442442
same time). Rate limiters use :doc:`locks </lock>` to protect their operations
443443
against these race conditions.
444444

445-
By default, Symfony uses the global lock configured by ``framework.lock``), but
445+
By default, Symfony uses the global lock configured by ``framework.lock``, but
446446
you can use a specific :ref:`named lock <lock-named-locks>` via the
447-
``lock_factory`` option:
447+
``lock_factory`` option (or none at all):
448448

449449
.. configuration-block::
450450

@@ -459,6 +459,9 @@ you can use a specific :ref:`named lock <lock-named-locks>` via the
459459
# use the "lock.rate_limiter.factory" for this limiter
460460
lock_factory: 'lock.rate_limiter.factory'
461461
462+
# or don't use any lock mechanism
463+
lock_factory: null
464+
462465
.. code-block:: xml
463466
464467
<!-- config/packages/rate_limiter.xml -->
@@ -481,6 +484,14 @@ you can use a specific :ref:`named lock <lock-named-locks>` via the
481484
lock-factory="lock.rate_limiter.factory"
482485
/>
483486
487+
<!-- limiter-factory: or don't use any lock mechanism -->
488+
<framework:limiter name="anonymous_api"
489+
policy="fixed_window"
490+
limit="100"
491+
interval="60 minutes"
492+
lock-factory="null"
493+
/>
494+
484495
<!-- ... -->
485496
</framework:rate-limiter>
486497
</framework:config>
@@ -498,9 +509,16 @@ you can use a specific :ref:`named lock <lock-named-locks>` via the
498509
499510
// use the "lock.rate_limiter.factory" for this limiter
500511
->lockFactory('lock.rate_limiter.factory')
512+
513+
// or don't use any lock mechanism
514+
->lockFactory(null)
501515
;
502516
};
503517
518+
.. versionadded:: 5.3
519+
520+
The login throttling doesn't use any lock since Symfony 5.3 to avoid extra load.
521+
504522
.. _`DoS attacks`: https://cheatsheetseries.owasp.org/cheatsheets/Denial_of_Service_Cheat_Sheet.html
505523
.. _`Apache mod_ratelimit`: https://httpd.apache.org/docs/current/mod/mod_ratelimit.html
506524
.. _`NGINX rate limiting`: https://www.nginx.com/blog/rate-limiting-nginx/

0 commit comments

Comments
 (0)