R
Railwayβ€’14mo ago
babadudi

File Upload Timeout

Hi! I'm running a Django app on a Starter Plan. I want to upload a larger file (70MB) but I get a timeout. I increased timeout for gunicorn to 7 minutes. But, get timeout after 5 - I guess its the the Apache timeout. How would I go about changing Apache timeout on Railway platform? Also, why is it that it is taking so much time to upload? Would a switch to Developer Plan help with the speed? Or, if you guys have any other solution that could help me speed up the upload speed that would be great! Thanks in advance πŸ™‚
42 Replies
Percy
Percyβ€’14mo ago
Project ID: 3b89960c-3369-4735-a08b-a5a6c2349a83
babadudi
babadudiβ€’14mo ago
3b89960c-3369-4735-a08b-a5a6c2349a83 @Brody Tagging you as advised in other thread. Thx πŸ™‚
Brody
Brodyβ€’14mo ago
railway does not use Apache, they use something called envoy, envoy is a proxy that forwards all external traffic to your app, and nothing about envoy is configurable by the user, this 5 minute limit is set by railway on all post requests but I'm sure you have fast internet and it likely wouldn't normally take you 5 minutes to upload a 70mb file. this is where the second problem comes in to play, railways envoy proxy was slightly misconfigured and this resulted in the unintentional speed throttling of upload speeds to a maximum of 10 megabits/s when making requests with http 2, this accidental speed limit only effects http 2 based requests there is no way to change the time limit for single post requests what so ever. but you can side step around the accidental throttling by using cloudflare in front of your app, cloudflare will use http 1.1 to connect to your app, and there is no throttling issues with http 1.1 thus no throttling and to answer another question, all this applies the same for the developer plan too @babadudi - if you need me to clarify anything, just ask
babadudi
babadudiβ€’14mo ago
Thanks for the detailed answer. Yeah, I already switched to Developer Plan and can see that its the same. And yes, could you please provide more info on how to do the Cloudflare setup?
Brody
Brodyβ€’14mo ago
do you own a custom domain?
babadudi
babadudiβ€’14mo ago
yes
Brody
Brodyβ€’14mo ago
who did you buy it from
babadudi
babadudiβ€’14mo ago
its a Czech provider
Brody
Brodyβ€’14mo ago
okay, you will have to change over to using cloudflare's nameservers (you do not have to transfer the domain) let me send you a guide on how to do that, one sec https://developers.cloudflare.com/dns/zone-setups/full-setup/setup/ can you send me your custom domain, just so I can track your progress
babadudi
babadudiβ€’14mo ago
But, Im a bit sceptical if this is the issue. Even if it would be uploading with 10mbs it should be uploaded in 1 minute
Brody
Brodyβ€’14mo ago
okay so what's your upload speed? like from speedtest.net
babadudi
babadudiβ€’14mo ago
9MBs
Brody
Brodyβ€’14mo ago
do you have insomnia on your computer?
babadudi
babadudiβ€’14mo ago
no should I download it?
Brody
Brodyβ€’14mo ago
do you think you could download it for this, I have a utility hosted on railway that will give you your real upload speed to railway
babadudi
babadudiβ€’14mo ago
ok
Brody
Brodyβ€’14mo ago
let me know when you got that downloaded
babadudi
babadudiβ€’14mo ago
got it So what should I do? πŸ™‚
Brody
Brodyβ€’14mo ago
one sec
babadudi
babadudiβ€’14mo ago
sure
Brody
Brodyβ€’14mo ago
just had to hop on my computer open insomnia application -> preferences -> request / response -> request timeout, set it to 0 dont change anything else
babadudi
babadudiβ€’14mo ago
got it
Brody
Brodyβ€’14mo ago
do you have a 20-30mb file on hand? doesnt matter what it is at all
babadudi
babadudiβ€’14mo ago
Yes
Brody
Brodyβ€’14mo ago
send that file in a post request to https://utilities.up.railway.app/upload as a binary file, then show me what the response says when it completes
babadudi
babadudiβ€’14mo ago
uploaded file size 29.07 Megabytes server received file in 79.70 seconds average upload speed 0.36 Megabytes/s or 2.92 Megabits/s note: this endpoint has a throttler set to 50.00 Megabits/s
Brody
Brodyβ€’14mo ago
yep 2.92 megabits /s
babadudi
babadudiβ€’14mo ago
yeah but upload to my app is definitely slower
Brody
Brodyβ€’14mo ago
what tech stack
babadudi
babadudiβ€’14mo ago
I tried to upload various file sizes and I could upload maximum 60MB it the 5 minute timeout django, gunicorn
Brody
Brodyβ€’14mo ago
oh i figured i prob should ask, what are you doing with these uploaded files
babadudi
babadudiβ€’14mo ago
loading them to a Buffer and then parsing data. Its an xml file
Brody
Brodyβ€’14mo ago
memory buffer, i wonder where the slowdown is coming from in this case, you are more limited by your own code than railway since you can upload to my endpoint faster than you can upload to yours
babadudi
babadudiβ€’14mo ago
Not sure, because I added some logging for debugging and I dont even hit the code that handles what happens after a POST request is sent. But yeah, that is weird πŸ˜„
babadudi
babadudiβ€’14mo ago
And I dont even see '1' printed out and I get a timeout
Brody
Brodyβ€’14mo ago
well yeah the connection would be terminated at 5 mins and your code would bail before it does anything with the data hold on just a moment where are you uploading these files from
babadudi
babadudiβ€’14mo ago
Either from an url or a file through a form
Brody
Brodyβ€’14mo ago
show me the url that these requests are being sent to
Brody
Brodyβ€’14mo ago
okay you are using https, all good there so yeah you are running into the limitations of your own code before you are running into the throttling limits of railway, might be worth it to search around for your problem on stack overflow and alike, since at the moment its not a railway issue
babadudi
babadudiβ€’14mo ago
Ok. Thanks a lot for help πŸ™‚
Brody
Brodyβ€’14mo ago
no problem!