Connection Rate Limiting #961
Closed
abdallahsamabd
started this conversation in
Ideas
Replies: 1 comment
|
Considering this resolved, since the proposal itself was merged 👍 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Problem
Today Praxis supports a global
max_connectionsceiling per listener and request-level rate limiting via therate_limitfilter. However, there is no mechanism to limit connections from a single source IP. This leaves a gap:No per-IP concurrent connection limit — a single client can open thousands of connections and exhaust the listener's file descriptors, memory, and socket buffers, starving all other clients. The global
max_connectionsprotects the proxy from total overload but does not isolate tenants from each other.No per-IP new connection rate limit — a misbehaving client (buggy retry loop, port scanner, or attacker) can rapidly open and close connections, consuming CPU in handshake processing without any throttling. Request-level rate limiting does not help because the cost is incurred at connection establishment, before any HTTP request is parsed.
No configurable rejection behavior — when a connection is rejected, the proxy has no policy for how to signal the client. Operators may want a TCP RST (fast feedback), an HTTP 429 response (application-level signal), or a silent drop (stealth against scanners).
This leaves Praxis vulnerable to connection-layer attacks (slow-loris, connection floods, rapid reconnection storms) that request-level controls cannot mitigate. Operators must rely on external firewalls or OS-level iptables rules — which are harder to configure, less observable, and disconnected from the proxy's metrics pipeline.
Competing proxies address this at the infrastructure layer:
connection_limitnetwork filter with per-IP trackinglimit_conn_zone/limit_connfor per-IP concurrent limitsmaxconnper source via stick-tablesProposal
Add per-source-IP connection-level rate limiting at the listener layer, independent of request-level rate limiting:
Per-IP concurrent connection limit: Track active connections per source IP. Reject new connections once an IP exceeds a configurable threshold. Connections are tracked with O(1) lookup using a sharded concurrent hash map, and entries are reclaimed when connections close.
Per-IP new connection rate limit: Token bucket per source IP controlling how many new connections can be established per second. Prevents rapid reconnection patterns even when concurrent connection count stays low (e.g., rapid open/close cycles).
Configurable rejection behavior: Operators choose what happens when a connection is rejected:
tcp_reset— send RST immediately (fast client feedback)http_429— complete TLS handshake, send HTTP 429 response, then close (application-level signal for well-behaved clients)silent_drop— close without response (stealth against scanners)Metrics: Expose per-IP rejection counters (
praxis_connection_limit_rejected_total) with labels for reason (concurrent_limit,rate_limit) and action taken.Scope: Inbound client connections only. This does not cover upstream/cluster connection limits (separate concern) or distributed cross-instance rate state (future work).
Related
All reactions