Skip to content

Commit 2a131c6

Browse files
committed
Optimize PostgreSQL benchmarks: emphasize --network=host impact and clarify nftables overhead reduction benefits
1 parent da3c4ad commit 2a131c6

1 file changed

Lines changed: 7 additions & 35 deletions

File tree

  • content/post/hidden-cost-rootless-container-networking

content/post/hidden-cost-rootless-container-networking/index.adoc

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -83,56 +83,28 @@ With --network=host:
8383

8484
Every JDBC packet traverses two extra kernel/userspace boundary crossings plus a userspace copy in the pasta process. For a chatty protocol like JDBC with small, frequent packets, this is devastating.
8585

86-
=== Bonus: nftables firewall overhead
87-
88-
Fedora's `firewalld` maintains 973 https://wiki.nftables.org/[nftables] rules that every packet traverses (`nf_hook_slow` -> `nft_do_chain`). This is independent of pasta — it affects any network traffic on the host. Disabling the firewall recovers another ~10% throughput. This matches findings from https://talawah.io/blog/extreme-http-performance-tuning-one-point-two-million/[prior work on extreme HTTP tuning] where iptables `nf_hook_slow` consumed ~18% of CPU in benchmarks.
86+
== The fix
8987

90-
== Why Quarkus is affected but Spring is not
88+
Run the PostgreSQL container with `--network=host` instead of port-mapping (`-p 5432:5432`). We added `DB_HOST_NETWORK=true` to the benchmark's https://github.com/quarkusio/spring-quarkus-perf-comparison/blob/main/scripts/infra.sh[infrastructure script].
9189

9290
[cols="2,1,1,1", options="header"]
9391
|===
9492
| Configuration | Quarkus TPS | Spring TPS | Ratio
9593

9694
| Default (pasta + nftables) | 15,504 | 13,062 | 1.19x
9795
| `--network=host` | 24,116 | 13,368 | 1.80x
96+
| `--network=host` + no nftables | 26,039 | 13,214 | 1.97x
9897
| Perf-lab (RHEL 9.6) | 24,472 | 11,783 | 2.08x
9998
|===
10099

101-
Removing pasta boosts Quarkus by 55% but Spring by only 2.3%. **The same absolute overhead hits the efficient framework harder.**
102-
103-
Pasta adds ~0.073 ms of kernel CPU per request to Quarkus (the difference between 0.231 and 0.158 ms/req) — that's **46% on top of its framework cost**. Quarkus is CPU-saturated, so every freed cycle translates directly to more requests. Spring spends far more CPU in its own framework code, so saving a small fraction of cycles on networking simply cannot help.
104-
105-
**The more CPU-efficient your framework is, the more you feel the infrastructure tax.**
106-
107-
== The fix
108-
109-
Run the PostgreSQL container with `--network=host` instead of port-mapping (`-p 5432:5432`). We added `DB_HOST_NETWORK=true` to the benchmark's https://github.com/quarkusio/spring-quarkus-perf-comparison/blob/main/scripts/infra.sh[infrastructure script].
100+
**With host networking, Quarkus throughput improves by 55% while Spring barely moves (+2.3%).** Disabling the firewall on top recovers another 8% for Quarkus, bringing the ratio from 1.19x back to 1.97x — close to the perf-lab's 2.08x.
110101

111-
[cols="2,1,1,1", options="header"]
112-
|===
113-
| Configuration | Quarkus TPS | vs Perf-lab | Ratio Q/S
114-
115-
| Default (pasta + nftables) | 15,504 | 63.4% | 1.19x
116-
| No nftables only | 16,105 | 65.8% | --
117-
| `--network=host` | 24,116 | 98.5% | 1.80x
118-
| `--network=host` + no nftables | 26,039 | 106.4% | --
119-
| Perf-lab (RHEL 9.6) | 24,472 | 100% | 2.08x
120-
|===
121-
122-
**With host networking, the local Fedora workstation matches the perf-lab.** The remaining gap to the perf-lab's 2.08x ratio is accounted for by nftables (Fedora's 973 rules vs RHEL's minimal ruleset) and minor kernel differences.
123-
124-
Per-request CPU cost confirms the picture:
102+
Fedora's `firewalld` maintains 973 https://wiki.nftables.org/[nftables] rules that every packet traverses (`nf_hook_slow` -> `nft_do_chain`). This is independent of pasta — it affects any network traffic on the host. Disabling the firewall recovers another ~10% throughput. This matches findings from https://talawah.io/blog/extreme-http-performance-tuning-one-point-two-million/[prior work on extreme HTTP tuning] where iptables `nf_hook_slow` consumed ~18% of CPU in benchmarks.
125103

126-
[cols="2,1", options="header"]
127-
|===
128-
| Configuration | CPU ms/req
104+
== Why Quarkus is affected but Spring is not
129105

130-
| Default pasta (15,504 TPS) | 0.231
131-
| Host networking (24,116 TPS) | 0.158
132-
| Perf-lab (24,472 TPS) | 0.158
133-
|===
106+
Pasta adds ~0.073 ms of kernel CPU per request to Quarkus — that's **46% on top of its framework cost**. Quarkus is CPU-saturated, so every freed cycle translates directly to more requests. Spring spends far more CPU in its own framework code, so saving a small fraction of cycles on networking simply cannot help. **The more CPU-efficient your framework is, the more you feel the infrastructure tax.**
134107

135-
With host networking, per-request cost **matches the perf-lab exactly**: 0.158 ms/req.
136108

137109
== Confirming the fix
138110

0 commit comments

Comments
 (0)