-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow read DoS prevention #1715
Comments
@b3b I'm wondering why |
|
On a testing host, memory consumption for sockets when only single slow client is connected: $ cat /proc/net/sockstat
sockets: used 242
TCP: inuse 44 orphan 1 tw 0 alloc 80 mem 51987
UDP: inuse 2 mem 1
UDPLITE: inuse 0
RAW: inuse 0
FRAG: inuse 0 memory 0 |
Checked with Tempesta config: listen 80 proto=http;
server 127.0.0.1:8000;
cache 0;
keepalive_timeout 50;
frang_limits {
http_header_chunk_cnt 10;
http_body_chunk_cnt 30;
client_header_timeout 10;
client_body_timeout 25;
} Curl commands:
|
@b3b probably the problem is in that we ignore TCP send buffers and just retransmit packets from a backend server as they appear, so if a client connection is significantly slower than the server's one, then we hit the TCP OOM issues. I.e. this is the subject for #488 . Could you please post the Send-Q values and clarify what we have on the backend - is the request page is large? |
@krizhanovsky Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 130966 127.0.0.1:8000 127.0.0.1:54420 ESTABLISHED And for the second, long part: Proto Recv-Q Send-Q Local Address Foreign Address State
tcp6 0 209649764 192.168.1.1:80 192.168.1.2:48300 FIN_WAIT1 |
Motivation
Because of high memory usage per each connection, possible denial of service exists when large resources are consumed by slow clients.
Related issues: #498 , #1714
Testing
Scenario to reproduce
Host1 (slow clients):
Start a lot of slow (1 byte per second) downloads:
curl --output /dev/null -H 'Connection: close' --parallel-max 999 --parallel --parallel-immediate 'http://tempesta-host/[1-10000]' --limit-rate 1B
Host2 (legitimate client):
Try to access resource:
curl -v --output /dev/null http://tempesta-host
Depending on the load, result could be:
curl: (52) Empty reply from server
Tempesta
cat /proc/net/sockstat
show high value of TCP memory usagess -l
show highSend-Q
valuesTCP: out of memory -- consider tuning tcp_mem
tempesta.cfg
Backend
Backend on port 8000 should return a large response.
Tested on 200MB, larger responses could trigger #1714
Scenario for quick reproduction
sysctl -w net.ipv4.tcp_mem='100 100 100'
curl -v --output /dev/null http://127.0.0.1 --limit-rate 1B
curl -v --output /dev/null http://127.0.0.1
The text was updated successfully, but these errors were encountered: