0

I'm trying to configure nginx to serve a small, completely static site.

Without HTTP/2 enabled, I get this graph in Chrome developer tools:

No HTTP/2

Here, we see very good TTFB and good throughput on the files. Starting from the seventh request though, we get some queueing on the browser's part because of its 6-connection limit. This is why I wanted to switch to HTTP/2 (among its other benefits).

Now, with HTTP/2 enabled (adding the http option in listen):

enter image description here

The first couple of requests are great, but then everything deteriorates quickly from there (latency and throughput/download speed).

All other parameters remained the same, and I'm seeing this behaviour consistenly.

My nginx configuration, if it helps: https://gist.github.com/alfredxing/12757c0f7f91c91a415b651fd9510ec4

Any ideas why this may be happening?

Alfred Xing
  • 133
  • 1
  • 8
  • Are you on the latest Nginx version? 1.11.4 I think is current. http2 is still new so is likely still evolving. You could use server push to accelerate this. The longer blue lines suggest download speed is slower. What happens if you do a few tests, and test from webpagetest.org using Chrome? – Tim Oct 04 '16 at 06:51
  • @Tim Yup, latest version. Ping to the server is consistently around 22ms, and general throughput (downloading a large binary test file) maxes out my home internet connection (I'm very close geographically to the server: Vancouver to Seattle). I'll definitely look into server push, though I don't think nginx open source supports it! – Alfred Xing Oct 04 '16 at 06:54
  • Interested in seeing what webpagetest.org does, especially it choosing a median result from say nine tests with http2 on and then nine with http2 off. Post a link to the tests once run, assuming you're ok sharing your domain name. Try the webpagetest.org Australia node to see what effect high latency has. – Tim Oct 04 '16 at 06:59
  • Here are the webpagetest results: (with HTTP2) https://www.webpagetest.org/result/161004_31_AZ7/ and (without HTTP2) https://www.webpagetest.org/result/161004_5H_AWC/. HTTP2 waterfall looks "cleaner", but it still seems like I'm taking a hit in download speed – Alfred Xing Oct 04 '16 at 07:25
  • 1
    My best guess is Nginx isn't doing http2 very well yet. The download time for each resource is quite high, with less connection overhead. Firefox is a little faster, but same pattern with http2 https://www.webpagetest.org/result/161004_4Z_ffa70bfb561eb8403fa4e56680c04c1e/ . Have you looked around for article or testing others have done on Nginx/http2? It may be that it's just not ready for widespread use yet. Have you tried SPDY? It's more mature. – Tim Oct 04 '16 at 08:14
  • Thanks for your comments! I'll definitely take a look around, though I have been investigating and haven't found much. I know Cloudflare uses HTTP/2 and it works pretty well for them, but then again have lots of custom internal patches to nginx... – Alfred Xing Oct 04 '16 at 08:34
  • 1
    Someone else found something similar: https://loadtestgo.com/blog/2015/10/08/nginx-http2 . There are also a few similar questiosn on server fault and related sites. – Tim Oct 04 '16 at 18:49

1 Answers1

0

An HTTP/2 server can behave differently than a plain HTTP/1.1 server. For one thing, the HTTP/2 server can see all the requests originating from the same client, and prioritize some of them differently.

dsign
  • 153
  • 8
  • Can you explain why this would result in the behaviour I see though? I know it behaves differently, but of all things I don't expect it to perform *worse*. – Alfred Xing Oct 04 '16 at 06:46