tus / tusd

Reference server implementation in Go of tus: the open protocol for resumable file uploads
https://tus.github.io/tusd
MIT License
2.92k stars 465 forks source link

Given nginx configuration slows down uploads over https #1106

Open namandureja opened 2 months ago

namandureja commented 2 months ago

Describe the bug The given nginx configuration in the official docs - nginx.conf slows down uploads over https. I setup tusd on my virtual machine and after proxying it through nginx, I noticed significant drop in upload speeds (a factor of 20). Initially I thought that it was happening due to some issue in ssl encryption or proxy buffering by nginx. But, after a bit of experimenting, it turned out that this line was the root cause - listen 443 http2 ssl; The 'http2' configuration slowed down the uploads by a huge factor. Once I removed it, the speeds were back to normal again, as fast as on http. Not sure if anyone else has faced this issue, but I thought it would be helpful for anyone running into this.

To Reproduce Steps to reproduce the behavior:

  1. Run tusd behind a proxy (nginx).
  2. Enable ssl and listen to 443 port with http2 configuration enabled.
  3. Test the upload speed.
  4. Disable the http2 configuration.
  5. Test the upload speed again.

Setup details Please provide following details, if applicable to your situation:

Acconut commented 2 months ago

Thanks for the report! I remember hearing something similar some time ago, but there were no concrete results at the time. We haven't noticed a slowdown from using HTTP/2, but we are also using HAProxy in our deployments, not Nginx. When looking for information on this, one can find many similar reports, for example:

It seems as if the default configuration for HTTP/2 on Nginx is not optimized for uploads. So this is not a bug in tusd, but rather the result of a missing configuration, as some people report tuning the configuration helped improve upload speed.

The last link from above also links to a CloudFlare article, which dives into the topic of upload speed with HTTP/2. I haven't read it fully yet, but it seems as if it provides some potential hints to optimize upload speed. I want to look more into this, but maybe you can also read into it a bit.