Package com.netflix.eureka
Class RateLimitingFilter
- java.lang.Object
-
- com.netflix.eureka.RateLimitingFilter
-
- All Implemented Interfaces:
jakarta.servlet.Filter
@Singleton public class RateLimitingFilter extends java.lang.Object implements jakarta.servlet.FilterRate limiting filter, with configurable threshold above which non-privileged clients will be dropped. This feature enables cutting off non-standard and potentially harmful clients in case of system overload. Since it is critical to always allow client registrations and heartbeats into the system, which at the same time are relatively cheap operations, the rate limiting is applied only to full and delta registry fetches. Furthermore, since delta fetches are much smaller than full fetches, and if not served my result in following full registry fetch from the client, they have relatively higher priority. This is implemented by two parallel rate limiters, one for overall number of full/delta fetches (higher threshold) and one for full fetches only (low threshold).The client is identified by
AbstractEurekaIdentity.AUTH_NAME_HEADER_KEYHTTP header value. The privileged group by default contains:-
EurekaClientIdentity.DEFAULT_CLIENT_NAME- standard Java eureka-client. Applications using this client automatically belong to the privileged group. -
EurekaServerIdentity.DEFAULT_SERVER_NAME- connections from peer Eureka servers (internal only, traffic replication)
EurekaServerConfig.isRateLimiterThrottleStandardClients()property.Rate limiting is not enabled by default, but can be turned on via configuration. Even when disabled, the throttling statistics are still counted, although on a separate counter, so it is possible to measure the impact of this feature before activation.
Rate limiter implementation is based on token bucket algorithm. There are two configurable parameters:
- burst size - maximum number of requests allowed into the system as a burst
- average rate - expected number of requests per second
-
-
Constructor Summary
Constructors Constructor Description RateLimitingFilter()RateLimitingFilter(EurekaServerContext server)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()voiddoFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain)voidinit(jakarta.servlet.FilterConfig filterConfig)
-
-
-
Constructor Detail
-
RateLimitingFilter
@Inject public RateLimitingFilter(EurekaServerContext server)
-
RateLimitingFilter
public RateLimitingFilter()
-
-
Method Detail
-
init
public void init(jakarta.servlet.FilterConfig filterConfig) throws jakarta.servlet.ServletException- Specified by:
initin interfacejakarta.servlet.Filter- Throws:
jakarta.servlet.ServletException
-
doFilter
public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws java.io.IOException, jakarta.servlet.ServletException- Specified by:
doFilterin interfacejakarta.servlet.Filter- Throws:
java.io.IOExceptionjakarta.servlet.ServletException
-
destroy
public void destroy()
- Specified by:
destroyin interfacejakarta.servlet.Filter
-
-