Fix slow upload issue with HTTP/2

Fix slow upload issue with HTTP/2

Fix slow upload issue with HTTP2.webp


When HTTP/2 is enabled on the webserver, uploads are very slow, topping out at slightly over 1MByte/s, despite both client and server offering vastly more bandwidth. Once HTTP2 was disabled, upload speeds were improved by a factor of over x10.

All PHP/DB optimizations are in place, and more. The CPU load on server and client remains low, IO load on the DB and storage remains low. Issue is observed during large file uploads, so DB overhead isn't the issue.

Solution:
  • For apache, add the H2WindowSize 1048576 parameter
  • For nginx,add the http2_body_preread_size 1048576; parameter
Both of these can be set as global parameters.

Example with Apache2:
Bash:
sudo a2enmod http2

sudo nano /etc/apache2/mods-enabled/http2.conf

#Add line H2WIndowSize
Protocols h2 h2c http/1.1
H2WindowSize 1048576

Then restart apache2 server.
sudo systemctl reload apache2
 
Top