skip to Main Content

I have an Nginx proxy server. When an HTTP/2 request comes to the server and does not find anything in cache, the server makes an outbound request to the origin server using HTTP/1.1. Is there a performance degradation on the server when it converts from one version of the protocol to another? How does this compare to HTTP/1.1 to Nginx and HTTP/1.1 to the origin server? Is there a way to measure the overhead?

3

Answers


  1. I don’t think their is a performance degrade. One way to measure the impact (since I can’t test for you, you will have to do it) is to use AJAX, send a http/1.1 request and measure the response time. Then compare it to the time it takes to send http/2 requests. Do it multiple times.
    That’ll help you.

    But, beware, their may be a potential security problem.
    That is, their will be no point in even installing an SSL/TLS certificate. So is so because, the info that the NGINX server will send will then be open to hackers. Probably.

    Login or Signup to reply.
  2. Strictly speaking there is performance degradation, since one protocol is binary, other one textural. So proxy must convert, that takes resources, time – you can expect degradation by default.

    In general however that can be much more complicated. Say your proxy is used by slow mobile connection. Who cares about a bit of conversion if your app is gaining huge bust after that conversion? Or maybe your proxy had gzip conversion for http/1.1, and that speed gain is not that big, on the other hand maybe performance degradation is not that big?

    Can you measure that? Perhaps. Question is what for? I would measure something as close to real case as possible. I would automate that measurement to see where real performance is.

    My only warry in your case is CPU of the proxy – just measure it to see changes over time, and setup notifications – like "if cpu is over 80% for longer then 5 min".

    Other than all of that. Http2 brings two ways communication, as well as push. My assumption is that it is not your case, since you are comparing 1.1 and 2. For me I would go with http2 everywhere, unfortunately nginx is not supporting http2 and backend side. Fingers crossed to see that soon!

    Login or Signup to reply.
  3. Yes, going from HTTP2 to HTTP 1.1 degrades performance, primarily due to protocol-imposed transport conversions. For example, you lose the following transport optimizations:

    • Single connection
    • Request/response multiplexing
    • Header compression

    Additionally, as Michal mentioned, HTTP 1.1 messages are textual while HTTP2 messages are binary.

    HTTP2 multiplexes requests and responses over a single connection. However, HTTP 1.1 only affords persistent connections and request/response pipelining, which is not even comparable. For example, pipelining forces a FIFO order of message exchanges, which causes blocking.

    To achieve any similar throughput levels, the proxy will have to open a connection pool to each backend. Those pools could be large or small, but considering resource allocations, TCP handshakes, TLS handshakes, etc., per connection and you start to get the idea of how much overhead we’re talking about.

    Measure the difference between "throughput in" on cache hits and "throughput out" on cache misses, e.g. "protocol conversion throughput penalty" is ~23 tps. (You should also know your average cache miss penalty in terms of time.)

    Key metrics

    • Throughput in versus throughput out
    • Average cache miss penalty
    • Cache hit and cache miss ratios

    Unless your cache miss ratio is high, I wouldn’t worry about this.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search