Back to course

Rate Limiting for Protection

Go (Golang) for Cloud-Native Microservices

Preventing Abuse

Rate limiting protects your microservice from brute-force attacks or buggy clients.

Using x/time/rate:

Go's official sub-repository provides a Token Bucket rate limiter. go limiter := rate.NewLimiter(1, 5) // 1 request per sec, burst of 5

if !limiter.Allow() { http.Error(w, "Too Many Requests", 429) return }