Dannyboy
Dannyboy

Reputation: 2052

end to end HTTP2 - with haproxy, apache and varnish - possible? needed?

I have an application that's setup like this:

HAPROXY -> VARNISH -> APACHE (MOD_EVENT) -> PHP_FPM (REDIS + MYSQL)

Haproxy for TLS termination, varnish for cache.

I've enabled http2 in haproxy, varnish and apache:

Haproxy: added alpn h2,http/1.1 to frontend, added proto h2 to backend
Varnish: Added this flag: -p feature=+http2
Apache: installed mod_http2 and added Protocols h2 h2c http/1.1.

What i'm understanding from documentation is that haproxy supports end-to-end http2, varnish only supports http2 on frontend.

So after varnish -> http2 request becomes http 1.1 and apache receives http1.1 requests as I've confirmed through the logs.

My question is:
Should I strive to have end-to-end http2? Is that a desirable thing to do for performance? or should I just not even enable http2 on backend haproxy connection since varnish won't pass it through anyways?

I've been thinking about it for some time. In theory once HTTP2 connection reaches HAPROXY -> I think we probably wont benefit from HTTP2 multiplexing anymore as the rest of the request travels within datacenter... and network latencies are so much smaller within datacenter right? Just curious if anyone else ran into same question.

Upvotes: 2

Views: 914

Answers (1)

Thijs Feryn
Thijs Feryn

Reputation: 4818

The main reason why we use HTTP/2 is to prevent head-of-line blocking. The multiplexing aspect of H2 helps reduce the blocking.

However, when Varnish communicates with the origin server, the goal is to cache the response and avoid sending more requests to the origin.

The fact that HTTP/1 is used between Varnish and the origin shouldn't be a big problem, because Varnish is the only client that is served there. The head-of-line blocking will hardly ever occur.

Upvotes: 2

Related Questions