mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-13 03:42:35 -06:00
816af5b6d4
This commit updates the OPA runtime to set the GOMAXPROCS environment variable if it was not previously set. The value is determined by looking at the cgroup CPU quota and determining how many CPUs that equals. This is important if OPA is running on hosts where the number of CPUs that the Go runtime would normally see is high compared to the CPU quota applied to the OPA process/container. If the ratio is high, then the Go runtime can't schedule the goroutines effectively and the process ends up getting throttled which can impact latency significantly. The results are quite promising. For example, this is the result from running the `vegeta` load test tool against v0.27.1 (using a sample HTTP API authorization policy and console decision logging enabled) w/ a CPU quota of "1.0". $ cat traffic.txt | vegeta attack --duration=60s --rate=500/1s | tee results.bin | vegeta report Requests [total, rate, throughput] 30000, 500.02, 500.01 Duration [total, attack, wait] 59.999207s, 59.9980205s, 1.1865ms Latencies [mean, 50, 95, 99, max] 18.860579ms, 1.104143ms, 123.456696ms, 222.282491ms, 393.8184ms Bytes In [total, mean] 2040000, 68.00 Bytes Out [total, mean] 28530000, 951.00 Success [ratio] 100.00% Status Codes [code:count] 200:30000 Error Set: And the same for this commit: $ cat traffic.txt | vegeta attack --duration=60s --rate=500/1s | tee results.bin | vegeta report Requests [total, rate, throughput] 30000, 500.02, 500.01 Duration [total, attack, wait] 59.9990695s, 59.9980199s, 1.0496ms Latencies [mean, 50, 95, 99, max] 1.818325ms, 1.038192ms, 4.078345ms, 13.789254ms, 219.8218ms Bytes In [total, mean] 2040000, 68.00 Bytes Out [total, mean] 28530000, 951.00 Success [ratio] 100.00% Status Codes [code:count] 200:30000 Error Set: Fixes #3328 Signed-off-by: Torin Sandall <torinsandall@gmail.com>