@@ -442,9 +442,9 @@ simultaneous requests (e.g. three servers of a company hitting your API at the
442442same time). Rate limiters use :doc: `locks </lock >` to protect their operations
443443against 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
446446you 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