Hi.
I have been testing warp and nginx with a minimal content (just a "hello world" message) and noticed warp is very slow, but I'm not sure if the slowness is related to warp or something I'm doing wrong.
The nginx config and content:
nginx -v
nginx version: nginx/1.16.1
cat /etc/nginx/nginx.conf
worker_processes auto;
worker_cpu_affinity auto;
events {
worker_connections 10000;
}
http {
access_log off;
keepalive_timeout 65;
server {
listen 8080 default_server;
...
cat /usr/share/nginx/html/index.html
Hello World
curl -v http://localhost:8080
* Trying ::1:8080...
* TCP_NODELAY set
* connect to ::1 port 8080 failed: Connection refused
* Trying 127.0.0.1:8080...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.65.3
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx/1.16.1
< Date: Thu, 30 Apr 2020 22:43:42 GMT
< Content-Type: text/html
< Content-Length: 12
< Last-Modified: Thu, 30 Apr 2020 21:16:45 GMT
< Connection: keep-alive
< ETag: "5eab403d-c"
< Accept-Ranges: bytes
<
Hello World
* Connection #0 to host localhost left intact
The warp stuff:
rustc --version
rustc 1.43.0-nightly (2890b37b8 2020-03-06)
cat examples/hello.rs
#![deny(warnings)]
use warp::Filter;
#[tokio::main]
async fn main() {
let routes = warp::any().map(|| "Hello World");
warp::serve(routes).run(([0, 0, 0, 0], 8080)).await;
}
cargo build --release
sudo ./target/release/examples/hello
# using sudo just to get all kernel configurations
curl -v http://localhost:8080
* Trying ::1:8080...
* TCP_NODELAY set
* connect to ::1 port 8080 failed: Connection refused
* Trying 127.0.0.1:8080...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.65.3
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< content-type: text/plain; charset=utf-8
< content-length: 11
< date: Thu, 30 Apr 2020 22:43:13 GMT
<
* Connection #0 to host localhost left intact
Environment
lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 43 bits physical, 48 bits virtual
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: AuthenticAMD
CPU family: 23
Model: 24
Model name: AMD Ryzen 7 3700U with Radeon Vega Mobile Gfx
Stepping: 1
CPU MHz: 1295.685
CPU max MHz: 2300.0000
CPU min MHz: 1400.0000
BogoMIPS: 4591.23
Virtualization: AMD-V
L1d cache: 32K
L1i cache: 64K
L2 cache: 512K
L3 cache: 4096K
NUMA node0 CPU(s): 0-7
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb hw_pstate sme ssbd sev ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 xsaves clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif overflow_recov succor smca
lsb_release -a
LSB Version: core-4.1-amd64:core-4.1-noarch
Distributor ID: Fedora
Description: Fedora release 30 (Thirty)
Release: 30
Codename: Thirty
Finally, the tests using wrk!
wrk
results (avg, after three intervaled tests) for nginx
./wrk -t10 -c1000 -d10s --latency http://127.0.0.1:8080/
Running 10s test @ http://127.0.0.1:8080/
10 threads and 1000 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 14.48ms 16.27ms 285.61ms 90.53%
Req/Sec 8.12k 1.59k 15.99k 78.23%
Latency Distribution
50% 10.07ms
75% 16.66ms
90% 29.94ms
99% 72.74ms
807992 requests in 10.10s, 190.29MB read
Requests/sec: 79976.39
Transfer/sec: 18.84MB
wrk
results (avg) for warp
./wrk -t10 -c1000 -d10s --latency http://127.0.0.1:8080/
Running 10s test @ http://127.0.0.1:8080/
10 threads and 1000 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 32.43ms 2.92ms 41.16ms 70.49%
Req/Sec 3.08k 325.14 3.97k 72.20%
Latency Distribution
50% 32.07ms
75% 34.20ms
90% 36.97ms
99% 39.35ms
306502 requests in 10.06s, 37.41MB read
Requests/sec: 30474.16
Transfer/sec: 3.72MB
(using wrk compiled by sources on Fedora30 with Clang 8.0)
Notice warp is about three times slower than nginx.
P.S. 1.: I did more tests using ApacheBench and JMeter with five machines (clients) connected to an external server remotely (with some limits due to internet bandwidth) providing a larger content (around 150 kB), but got slower results in warp again. 😕
P.S. 2: Notice the nginx.conf
on top of this message. How to apply those configs in warp? (specially worker_processes
, worker_cpu_affinity
and worker_connections
).
Why?
I don't know if there is any specific configuration to increase the warp speed. I would appreciate it and retest to get better results.
TIA for any help!