R

Railway

βœ‹ο½œhelp

Join Server

File Upload Timeout

Bbabadudi5/18/2023
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 πŸ™‚
Bbabadudi5/18/2023
3b89960c-3369-4735-a08b-a5a6c2349a83
Bbabadudi5/18/2023
@Brody Tagging you as advised in other thread. Thx πŸ™‚
Bbrody5/18/2023
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
Bbrody5/18/2023
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
Bbrody5/18/2023
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
Bbrody5/18/2023
and to answer another question, all this applies the same for the developer plan too
Bbrody5/18/2023
@babadudi - if you need me to clarify anything, just ask
Bbabadudi5/18/2023
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?
Bbrody5/18/2023
do you own a custom domain?
Bbabadudi5/18/2023
yes
Bbrody5/18/2023
who did you buy it from
Bbabadudi5/18/2023
its a Czech provider
Bbrody5/18/2023
okay, you will have to change over to using cloudflare's nameservers (you do not have to transfer the domain)
Bbrody5/18/2023
let me send you a guide on how to do that, one sec
Bbrody5/18/2023
can you send me your custom domain, just so I can track your progress
Bbabadudi5/18/2023
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
Bbrody5/18/2023
okay so what's your upload speed?
Bbrody5/18/2023
like from speedtest.net
Bbabadudi5/18/2023
9MBs
Bbrody5/18/2023
do you have insomnia on your computer?
Bbabadudi5/18/2023
no
Bbabadudi5/18/2023
should I download it?
Bbrody5/18/2023
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
Bbabadudi5/18/2023
ok
Bbrody5/18/2023
let me know when you got that downloaded
Bbabadudi5/18/2023
got it
Bbabadudi5/18/2023
So what should I do? πŸ™‚
Bbrody5/18/2023
one sec
Bbabadudi5/18/2023
sure
Bbrody5/18/2023
just had to hop on my computer
open insomnia
application -> preferences -> request / response -> request timeout, set it to 0
Bbrody5/18/2023
dont change anything else
Bbabadudi5/18/2023
got it
Bbrody5/18/2023
do you have a 20-30mb file on hand? doesnt matter what it is at all
Bbabadudi5/18/2023
Yes
Bbrody5/18/2023
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
Bbabadudi5/18/2023
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
Bbrody5/18/2023
yep 2.92 megabits /s
Bbabadudi5/18/2023
yeah but upload to my app is definitely slower
Bbrody5/18/2023
what tech stack
Bbabadudi5/18/2023
I tried to upload various file sizes and I could upload maximum 60MB it the 5 minute timeout
Bbabadudi5/18/2023
django, gunicorn
Bbrody5/18/2023
oh i figured i prob should ask, what are you doing with these uploaded files
Bbabadudi5/18/2023
loading them to a Buffer and then parsing data. Its an xml file
Bbrody5/18/2023
memory buffer, i wonder where the slowdown is coming from
Bbrody5/18/2023
in this case, you are more limited by your own code than railway
Bbrody5/18/2023
since you can upload to my endpoint faster than you can upload to yours
Bbabadudi5/18/2023
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.
Bbabadudi5/18/2023
But yeah, that is weird πŸ˜„
Bbabadudi5/18/2023
And I dont even see '1' printed out and I get a timeout
Bbrody5/18/2023
well yeah the connection would be terminated at 5 mins and your code would bail before it does anything with the data
Bbrody5/18/2023
hold on just a moment
Bbrody5/18/2023
where are you uploading these files from
Bbabadudi5/18/2023
Either from an url or a file through a form
Bbrody5/18/2023
show me the url that these requests are being sent to
Bbrody5/18/2023
okay you are using https, all good there
Bbrody5/18/2023
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
Bbabadudi5/18/2023
Ok. Thanks a lot for help πŸ™‚
Bbrody5/18/2023
no problem!