L4 vs L7 Stress Testing: What Actually Breaks First

작성자

카테고리:

← 피드로
DEV Community · zerodawnstress · 2026-08-16 개발(SW)

zerodawnstress

Stress testing a network service is not one discipline — it’s two. Layer 4 and Layer 7 tests break things in fundamentally different ways, and confusing them is the single most common mistake I see in infrastructure testing reports.

Here’s the mental model that finally made it click for me.

The Two Questions

Every stress test answers one of two questions:

  • L4: “Can the pipes and the connection machinery survive the volume?”
  • L7: “Can the application actually do its job under load?”

L4 attacks the delivery system — routers, firewalls, TCP stacks, conntrack tables. L7 attacks the business logic — web workers, TLS handshakes, database pools, render pipelines.

An analogy: L4 is blocking every road leading to a building. L7 is sending a thousand people to the reception desk to ask questions. Both overwhelm. They are not interchangeable.

What L4 Actually Consumes

Three distinct resources, and people constantly mix them up:

1. Bandwidth (Gbps). Raw bits per second. Determined by uplink capacity and any scrubbing capacity upstream.

2. Packets per second (PPS). This is where intuition fails. 1 Gbps of 64-byte packets is roughly 1.95 million PPS. The same 1 Gbps of 1400-byte packets is about 89,000 PPS — a 23x difference. Network gear processes packets, not bytes. A mid-range firewall that happily forwards 9 Gbps of large packets can fall over at 3 Gbps of small ones.

3. Connection state (conntrack / file descriptors). SYN floods and full TCP connection floods target the tables, not the bandwidth. A device can be at 4% CPU with an empty uplink and still be dying because its session table is full.

Quick conversion reference:

PPS ≈ Gbps × 125,000,000 / avg_packet_size_bytes

Enter fullscreen mode Exit fullscreen mode

What L7 Actually Consumes

Application-layer pressure targets computational cost:

  • Web workers / thread pools — request concurrency
  • TLS handshakes — asymmetric crypto is expensive on the server side, cheap on the client side (this asymmetry is the whole point of TLS-based tests)
  • Database connections — any endpoint that touches storage multiplies cost
  • Dynamic rendering — endpoints that build pages per-request

The metric that matters here is RPS (requests per second) combined with response-time degradation. Raw RPS means nothing without a latency baseline: 5,000 RPS at 40ms p95 is fine; 5,000 RPS at 4,000ms p95 means you already lost.

The Bottleneck Location Table

This is the cheat sheet I keep coming back to:

Symptom under load Bottleneck Layer Bandwidth saturated, service responsive Uplink / scrubbing L4 Low bandwidth, but device CPU spiking Firewall PPS limit L4 SYN_RECV queue climbing TCP backlog L4 Conntrack table full, drops everywhere Connection state table L4 Response times climbing, 5xx rising App workers / DB pool L7 TLS handshake failures rising Crypto offload exhausted L7 Cache hit ratio collapses Origin protection gap L7

The Three Mistakes

Testing only one layer. Defenses degrade differently per layer. A stack that survives 10 Gbps of UDP can die to 20k RPS of well-formed HTTPS requests. Test both, then test them mixed.

Reading peaks, ignoring sustained load. Surviving a 30-second spike is not the same as surviving 40 minutes. Thermal throttling, garbage collection pauses, and connection accumulation only show up under sustained pressure. Always record both peak and 10-minute sustained numbers.

No baseline. If you don’t know your p95 latency before the test, your test produced a number, not an answer.

A sane test sequence

  1. Baseline: normal-traffic latency percentiles for 10 minutes
  2. Single-method L4 runs — find each threshold separately
  3. Single-method L7 runs — same
  4. Mixed runs at ratios approximating your threat model
  5. Record: threshold (where degradation starts), cliff (where it collapses), recovery time after stopping

The threshold is more operationally useful than the cliff. Alerts should fire near thresholds; the cliff is where incident response has already failed.

Takeaway

Stop asking “how much traffic can we survive” and start asking “which resource exhausts first, and how do we see it before users do.” Layer 4 and Layer 7 give you different answers to that question — and you need both.

원문에서 계속 ↗