Previously we published guide on how to enable HTTP/2 on Apache, of course we published other guides like cache aware server push. mod_http2 Enables HTTP/2, has settings which are usually kept as default. In this guide we will talk around the possibilities to tweak Apache HTTP/2 settings aka optimise module mod_http2. mod_http2 module relies on libnghttp2 to provide the core http/2 engine and present is experimental. It is very important to understand that the directives can change behaviours from default which may not be suitable to test on a production server hosting serious live website.
Apache HTTP/2 Settings : Optimize Module mod_http2
The first directive is known, it is used to activate HTTP/2 and used with mod_ssl block and virtual server block :
1 | Protocols h2 http/1.1 |
The above settings make http/1.1 as first option, http/2 as second option. The below settings will work on server configuration file unless otherwise specified, some works on virtual host file as well.
---
HTTP/2 has a Direct Mode, and can be made on or off with :
1 2 | H2Direct on H2Direct off |
Default settings is ON. Maximum number of active streams per HTTP/2 session can be adjusted with :
1 | H2MaxSessionStreams 100 |
Default is 100. You can lower down to 50 or even 20. Obviously, the maximum number of seconds http/2 workers will remain idle until shut down that can be changed too :
1 | H2MaxWorkerIdleSeconds 600 |
600 is default value, you can change to lower value like 20. We can change the maximum and minimum number of worker threads to use per child process :
1 2 | H2MaxWorkers 20 H2MinWorkers 10 |
There is a security and cipher related settings to toggle security checks on HTTP/2 connections in TLS mode, which is by default kept to off and safe to keep to off :
1 | H2ModernTLSOnly off |
We can toggle HTTP/2 push on or off, default is on :
1 2 | H2Push on H2Push off |
There is a H2PushPriority directive, which is important to force before or after, select type of thing :
1 2 3 4 5 6 | H2PushPriority * After 16 H2PushPriority text/css Interleaved 256 H2PushPriority application/json Before H2PushPriority application/json 32 H2PushPriority image/jpeg before H2PushPriority text/css interleaved |
The directives to serialise HTTP/2 requests usually not good for performance (it falls back to http/1.1) :
1 2 | H2SerializeHeaders on H2SessionExtraFiles 10 |
We can set the maximum number of outgoing data bytes buffered in memory for an active streams with this directive :
1 | H2StreamMaxMemSize 65536 |
Above is default value, you can change to higher value like 128000
.
We have warm up and cool down directive :
1 2 | H2TLSCoolDownSecs 0 H2TLSWarmUpSize 0 |
The above warm up and cool down directives are what Google’s peoples say TLS record optimisation in context of Nginx.
We can control toggle of the usage of the HTTP/1.1 upgrade method for switching to HTTP/2 :
1 2 | H2Upgrade on H2Upgrade off |
We can set the size of the window for flow control from client to server to limit the amount of data the server has to buffer. This affects only request bodies :
1 | H2WindowSize 128000 |
These are what officially known.
Tagged With http2 settings , Apache httpd mod_http2 H2MaxWorkers , apache settings http 2 , H2ModernTLSOnly off , how to configure H2Push off , http2_module apache , mod http2 , mod_http2