Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Setup lab

rocky-01: this server transmitted
rocky-02: this server recvied
rocky-03: this server collect metrics and display thourgh grafana

optional to this test, just run quick manual apply

sudo sysctl -w net.core.somaxconn=65535
sudo sysctl -w net.ipv4.tcp_max_syn_backlog=65535
sudo sysctl -w net.core.netdev_max_backlog=65535
sudo sysctl -w net.core.rmem_max=16777216
sudo sysctl -w net.core.wmem_max=16777216
sudo sysctl -w net.core.rmem_default=1048576
sudo sysctl -w net.core.wmem_default=1048576
sudo sysctl -w net.core.optmem_max=65535
sudo sysctl -w net.ipv4.tcp_rmem="4096 1048576 16777216"
sudo sysctl -w net.ipv4.tcp_wmem="4096 1048576 16777216"
sudo sysctl -w net.ipv4.tcp_slow_start_after_idle=0
sudo sysctl -w net.ipv4.tcp_fin_timeout=15
sudo sysctl -w net.ipv4.tcp_keepalive_time=300
sudo sysctl -w net.ipv4.tcp_keepalive_intvl=30
sudo sysctl -w net.ipv4.tcp_keepalive_probes=5
sudo sysctl -w net.ipv4.tcp_max_tw_buckets=1440000
sudo sysctl -w net.ipv4.tcp_syncookies=1
sudo sysctl -w net.ipv4.tcp_timestamps=1
sudo sysctl -w net.ipv4.tcp_sack=1
sudo sysctl -w net.ipv4.tcp_window_scaling=1
sudo sysctl -w net.ipv4.ip_local_port_range="1024 65535"
sudo sysctl -w net.ipv4.ip_forward=1
sudo sysctl -w fs.file-max=2097152
sudo sysctl -w fs.nr_open=2097152
sudo sysctl -w vm.dirty_ratio=20
sudo sysctl -w vm.dirty_background_ratio=10
sudo sysctl -w vm.overcommit_memory=1
sudo sysctl -w kernel.pid_max=4194304
sudo sysctl -w kernel.threads-max=4194304

After apply sysctl just running script install nginx server bash nginx/install-nginx.sh
Create file 100kb and 1MB for nginx testing

# Create 100KB test file in nginx web root
dd if=/dev/zero of=/var/www/html/100KB.bin bs=100K count=1

# Create 1MB test file in nginx web root
dd if=/dev/zero of=/var/www/html/100MB.bin bs=1M count=1

After that install wrk on server transmitted

we will test with those commands below

wrk -t4 -c1000 -d60s --timeout 10s http://<ip-server>/500KB.bin
wrk -t4 -c1000 -d60s --timeout 10s http://<ip-server>/1MB.bin

Test with 1k connection - 500KB (1 min)

So prepare for this benchmark we draw grafana dashboard show all values we need monitor. This chart in this

Result running test

Running 1m test @ http://<ip-server>/500KB.bin
  4 threads and 1000 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.83s   777.23ms   8.46s    81.77%
    Req/Sec    86.43     38.41   580.00     77.74%
  20572 requests in 1.00m, 10.05GB read
Requests/sec:    342.42
Transfer/sec:    171.33MB

500kb_1
500kb_1
So with 500kb it easy pass. Some analyst this chart

Time TCP Memory File Descriptors Retransmits Timeouts
10:07:00 5 MB → 192 MB 750 → 2,000 0 → 13K 0 → 110
10:08:00 192 MB → 5 MB 2,000 → 750 13K → 0 110 → 0
  • 110 timeouts out of 20,572 requests = 0.53% timeout rate
  • Most likely connection establishment timeouts, not transfer timeouts
  • May indicate initial SYN backlog overflow during connection ramp-up
  • 10-second timeout threshold in wrk config caught slow handshake

Test with 1k connection - 1MB (5 mins)

So when CDN working chunks file split range 1-50mb therefore we will test with 1mb (limit by hardware :( )

Running 5m test @ http://<ip-server>/1MB.bin
  4 threads and 1000 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.30s     2.68s   10.00s    80.34%
    Req/Sec   145.20    156.23     0.95k    83.30%
  170602 requests in 5.00m, 167.13GB read
  Socket errors: connect 0, read 0, write 0, timeout 3782
Requests/sec:    568.49
Transfer/sec:    570.29MB

500kb_1
500kb_1

TCP's retransmission mechanism is compensating:
├─ Packet lost → TCP detects → Retransmits
├─ Eventually succeeds (97.8% of time)
├─ Only 2.2% give up after max retries
└─ System keeps chugging despite ring buffer limitation

Timeout Root Cause (3,782 failures):
NIC Ring Buffer Overflow: The primary culprit

  • Default ring buffer size (typically 256-512 slots) insufficient
  • At 1,000 concurrent connections × 1MB payloads = massive packet burst
  • When ring buffer full → packets dropped → TCP retransmits → timeout if max retries exceeded

SYN Backlog Overflow: Possible during initial connection surge

  • net.ipv4.tcp_max_syn_backlog=65535 may still overflow briefly

Issue about ring buffer (we cant increase because hitting limit hardware)

Expected impact of ring buffer increase:

  • Reduce packet drops from burst traffic
  • Lower retransmission rate significantly
  • Decrease timeout errors (possibly from 2.2% to <0.5%)
  • Smoother throughput without micro-bursts

Result:

  • Kernel tuning is working correctly
  • Problem is upstream of TCP layer (NIC ring buffers)
  • Current sysctl parameters are appropriate; don't increase further
  • Focus optimization on hardware layer (NIC) not kernel layer

Command use:

# watch network
watch -n 1 'ss -s && echo "---" && netstat -s | grep -E "overflow|drop" | head -5'

# watch cpu
mpstat -P ALL 1

# watch network drops
watch -n1 'echo "=== Packet Drops ==="; ethtool -S eth0 | grep drop; echo "=== SYN Overflows ==="; netstat -s | grep overflowed'

# check network eth
ethtool -g eth0

Resource links

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages