ardatosun / loadbalancer

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

added rate limiting #16

Closed ohyesgocool closed 6 days ago

ohyesgocool commented 6 days 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 6 days ago

closes #11