Spring / Resilience4j Interview questions
When should you use RateLimiter instead of Bulkhead?
Use RateLimiter when the constraint is a rate over time - calls per second or per minute - such as respecting a third-party API's documented rate limit or protecting a downstream system from a traffic burst.
Use Bulkhead instead when the constraint is concurrency at any given instant - how many calls can be in flight simultaneously - such as preventing one slow dependency from consuming every thread in a shared pool.
A useful way to tell them apart: a RateLimiter would still reject the 101st call in a second even if the previous 100 all completed instantly, while a Bulkhead would happily allow 1,000 calls per second as long as no more than, say, 10 are ever running at the exact same moment.
More Related questions...