This article is a mirror article of machine translation, please click here to jump to the original article.

View: 5|Reply: 0

[Web] [Repost] Traefik vs Nginx Official Benchmark

[Copy link]
Posted on11 minutes ago | | |
What is Traefik?

Traefik is a modern seven-layer reverse proxy and load balancer, centered around a core concept — Service Discovery First.

The biggest difference from traditional reverse proxies (like Nginx) is that you don't need to manually write a large number of configuration files; Traefik proactively "observes" your runtime environment and automatically generates routing rules.

Because of the "service as configuration" feature, Traefik is especially suitable for these scenarios:

  • Docker / Docker Compose
  • Kubernetes(Ingress Controller)
  • Microservices architecture
  • Online services for small teams or independent developers

Simply put, if your service is "dynamic," Traefik is much less hassle-free than traditional reverse agents.

Benchmark

disposition

I want to thank exoscale.ch VincentBernat, who generously provided the infrastructure needed for benchmarking.

I tested it using 4 virtual machines, configured as follows:

32 GB of memory
8 CPU cores
10GB solid-state drive
Ubuntu 14.04 LTS 64-bit

Set up

A virtual machine is used to launch the benchmarking tool wrk
A virtual machine for Traefik (v1.0.0-beta.416) / nginx (v1.4.6)
Who is configuring two virtual machines for two backend servers in Go?
Each virtual machine has been tuned using the following restrictions:
Nginx

Below is the usage method for the Nginx configuration file /etc/nginx/nginx.conf:
Below are the Nginx virtual hosting configuration files used:
Traefik

The following are the files used for traefik.toml:
outcome
whoami:
wrk -t20 -c1000 -d60s -H "Host: test.traefik" --latency  http://IP-whoami:80/bench
Running 1m test @ http://IP-whoami:80/bench
20 threads and 1000 connections
Thread Stats   Avg      Stdev     Max   +/- Stdev
Latency    70.28ms  134.72ms   1.91s    89.94%
Req/Sec     2.92k   742.42     8.78k    68.80%
Latency Distribution
50%   10.63ms
75%   75.64ms
90%  205.65ms
99%  668.28ms
3476705 requests in 1.00m, 384.61MB read
Socket errors: connect 0, read 0, write 0, timeout 103
Requests/sec:  57894.35
Transfer/sec:      6.40MB

nginx:
wrk -t20 -c1000 -d60s -H "Host: test.traefik" --latency  http://IP-nginx:8001/bench
Running 1m test @ http://IP-nginx:8001/bench
20 threads and 1000 connections
Thread Stats   Avg      Stdev     Max   +/- Stdev
Latency   101.25ms  180.09ms   1.99s    89.34%
Req/Sec     1.69k   567.69     9.39k    72.62%
Latency Distribution
50%   15.46ms
75%  129.11ms
90%  302.44ms
99%  846.59ms
2018427 requests in 1.00m, 298.36MB read
Socket errors: connect 0, read 0, write 0, timeout 90
Requests/sec:  33591.67
Transfer/sec:      4.97MB

Traefik
wrk -t20 -c1000 -d60s -H "Host: test.traefik" --latency  http://IP-traefik:8000/bench
Running 1m test @ http://IP-traefik:8000/bench
20 threads and 1000 connections
Thread Stats   Avg      Stdev     Max   +/- Stdev
Latency    91.72ms  150.43ms   2.00s    90.50%
Req/Sec     1.43k   266.37     2.97k    69.77%
Latency Distribution
50%   19.74ms
75%  121.98ms
90%  237.39ms
99%  687.49ms
1705073 requests in 1.00m, 188.63MB read
Socket errors: connect 0, read 0, write 0, timeout 7
Requests/sec:  28392.44
Transfer/sec:      3.14MB

conclusion
Traefik's speed is clearly slower than Nginx's, but the gap isn't huge: Traefik handles 28,392 requests per second, while Nginx handles 33,591 requests per second, with a performance ratio of 85%. For a young project, that's pretty good :)!

Some areas for improvement:

Use GO_REUSEPORT monitors

Each CPU core runs a separate server instance GOMAXPROCS=1 (benchmarks show Traefik has much more context switching than nginx).

Original:The hyperlink login is visible.




Previous:Differences between QTS and QuTS Hero operating systems for NAS
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com