feat: reduce default bucket capacity for rate limiting

This commit is contained in:
2025-09-01 23:38:47 +03:00
parent 61775a6bb8
commit 45afc8fa31

View File

@@ -4,15 +4,16 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/redis/rueidis"
"net/http" "net/http"
"sipro-mps/internal/redis" "sipro-mps/internal/redis"
"sipro-mps/pkg/utils" "sipro-mps/pkg/utils"
"time" "time"
"github.com/redis/rueidis"
) )
const ( const (
defaultBucketCapacity = 10 // max burst size defaultBucketCapacity = 5 // max burst size
refillRate = 100.0 / 60000 // 300 requests per minute → 1 token per 200ms refillRate = 100.0 / 60000 // 300 requests per minute → 1 token per 200ms
tokenTTLMillis = 60000 // Redis key TTL: 60s tokenTTLMillis = 60000 // Redis key TTL: 60s
) )