cloudflare/rakelimit
소개
A fair-share ratelimiter implemented in BPF
개발 도구측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- +1
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalRakelimit
A multi-dimensional fair-share rate limiter in BPF, designed for UDP. The algorithm is based on Hierarchical Heavy Hitters, and ensures that no party can exceed a certain rate of packets. For more information please take a look at our blog post.
Usage
To activate rakelimit create a new instance and provide a file descriptor and a rate limit that you think the service in question won't be able to handle anymore:
conn, err := net.ListenPacket("udp4", "127.0.0.1:0")
if err != nil {
tb.Fatal("Can't listen:", err)
}
udpConn := conn.(*net.UDPConn)
// We don't want to allow anyone to use more than 128 packets per second
ppsPerSecond := 128
rake, err := New(udpConn, ppsPerSecond)
defer rake.Close()
// rate limiter stays active even after closing
That's all! The library now enforces rate limits on incoming packets, and it happens within the kernel.
Requirements
The library should be go-gettable, and has been tested on Linux 5.11.
You may have to increase optmem_max depending on your distribution:
sudo sysctl -w net.core.optmem_max=22528
You will need a clang-12 binary if you want to recompile the filter. Simply run go generate in the root of the project.
Limitations
- IPv6 doesn't support options
- requires tweaking of optmem
- not tested in production
Testing
go test .
관련 프로젝트 살펴보기
불러오는 중…