ardatosun / loadbalancer

Simple Go Load Balancer
MIT License
5 stars 5 forks source link

added rate limiting #16

Closed ohyesgocool closed 1 month ago

ohyesgocool commented 1 month ago

Global Rate Limit:

A new configuration option global_requests_per_second has been added in config.yaml. This defines the default global rate limit (requests per second) that applies to all backends unless overridden at the backend level.

Backend-Specific Rate Limits:

Each backend can now specify its own rate limit using the backend_requests_per_second field in config.yaml. If a backend-specific rate limit is not defined, the global rate limit will be applied by default.

Rate Limiting Logic:

Implemented using the golang.org/x/time/rate package. The rate limiter is applied per backend, ensuring that requests exceeding the defined rate limit will receive an HTTP 429 Too Many Requests respon

ardatosun commented 1 month ago

closes #11