nghttp2 / nghttp2

nghttp2 - HTTP/2 C Library and tools
https://nghttp2.org
Other
4.64k stars 872 forks source link

Slow nghttpx performance #467

Open nubela opened 8 years ago

nubela commented 8 years ago

I'm running nghttpx w/ the following command

$ nghttpx -s -f0.0.0.0,443 --no-via -b 0.0.0.0,55555 --npn-list=spdy/3.1 --fastopen=1 --backend-request-buffer=128K --backend-response-buffer=128K -n 1 /workspace/certs/server.key /workspace/certs/bundle.crt

However, the downloads and even normal requests become significantly slower under testing:

test                                result
-------------------------------  ---------
(control) round trip latency      0.185
(http) round trip latency         0.189081
(spdy) round trip latency         0.386639
(control) download speed (10mb)   0.203217
(http) download speed (10mb)      1.83027
(spdy) download speed (10mb)     12.1785

Slow connections via requests

If you look at the first 3 tests, this simple tests merely download a small html file and then closes it. With both proxy and non-proxy (first 2 tests), it takes an average of 0.18s to complete the request.

But with nghttpx, it is 0.38s.

Slow download speed

If you look at the download speed in the last 3 tests:

(control) download speed (10mb) --> Download 10mb file without any proxy (http) download speed (10mb) --> Download 10mb file WITH http proxy (spdy) download speed (10mb) --> Download 10mb file WITH nghttpx (spdy) proxy via a proxy backend

You can see a huge difference of 6-10x slower download speed in downloading a 10mb file.


How can I improve these stats?

tatsuhiro-t commented 8 years ago

10mb download speed is strangely slow. In my environment, it finished a lot faster. I'm interested in how you measured these numbers. http proxy case is plain Tcp and not over TLS, right? Were you using high latecy network?

nubela commented 8 years ago

No, the network is of the network in a digitalocean droplet. HTTP Proxy is plain TCP (via Squid).

The download numbers for http proxy == downloading 10mb file via squid proxy. Download numbers for SPDY == downloading 10mb file via nghttpx with the previous squid proxy.

I was using spdycat to download the file.

On Sat, Jan 2, 2016 at 10:58 AM, Tatsuhiro Tsujikawa < notifications@github.com> wrote:

10mb download speed is strangely slow. In my environment, it finished a lot faster. I'm interested in how you measured these numbers. http proxy case is plain Tcp and not over TLS, right? Were you using high latecy network?

— Reply to this email directly or view it on GitHub https://github.com/tatsuhiro-t/nghttp2/issues/467#issuecomment-168359779 .

tatsuhiro-t commented 8 years ago

That would be a product of flow control. Have you tried chrome or Firefox to download that file? They use larger flow control window size.

ayanamist commented 8 years ago

@nubela I think you can use nghttp instead of spdycat and set window-bits larger to try again.

nubela commented 8 years ago

@ayanamist There doesn't seem to be a way to specify proxy settings with nghttp, unlike spdycat:

 -p, --proxy=<HOST> Use this host as a SPDY proxy
 -P, --proxy-port=<PORT>
                   Use this as the port of the SPDY proxy if
                   one is set

@tatsuhiro-t I'm trying to build an integration tests (via CLI), which is why I'm using CLI tools. Is there a way to increase flow control window size in spdycat? Or alternatives for that? Or can I use Chrome/Firefox to replicate spdycat via CLI?

tatsuhiro-t commented 8 years ago

spdycat has -w option to change stream-level flow control window size, but it lacks a flag to change connection-level window size, so we cannot disable flow control here.

nghttp has no proxy related options. You can workaround it by rewriting some header fields. For example, to get http://example.com via h2 proxy operated on localhost:3000:

$ nghttp -H ':authority: example.com' -H ':scheme: http' https://localhost:3000/

Note that nghttp only support h2, and does not support spdy.