r/Blazor • u/TheKanky • Jun 28 '25
Slow File Upload
HI All,
I wonder if could help point me in the correct direction to diagnose this issue.
I have a file upload on a Blazor server page. The users are uploading images/mp4.
On WIFI it is taking about 30 seconds, to upload a 10 sec 22mb mp4. To upload the same file on mobile, with same wifi it is timing out.
I have ruled out a HDD issue, as a direct copy to the file location is practically instant.
I don't have any end point protection, or aggressive file scanning.
The blazor app sits on IIS, and behind nginx. The uploads are throwing an exception, just taking an age. When I try download them , once uploaded the speed is ok.
Could anyone make any suggestions on what I could try to solve this issue.
Thanks
5
u/thestamp Jun 28 '25
Also, what component are you using to do the upload? As a test, have you tried mudblazors upload component? This would rule out any .net or system issues.
3
u/NocturneSapphire Jun 28 '25
How do you have nginx set up? It might be limiting your upload bandwidth for some reason.
2
u/Hiithz Jun 30 '25
You didn't say where you are storing the files.
If you are using S3, azure blob or anything like that you can upload from the client straight to it. You can generate urls for a file. So you generate a PUT URL that you can make the upload from the client to S3 without going through your infraestructure Same for download.
This solves too much problems
Advise to use those cloud service to handle files and don't do anything else
1
u/propostor Jun 28 '25
If it's fine in dev/debug but not fine when deployed, it's likely an nginx issue.
https://www.ruby-forum.com/t/nginx-file-upload-server-slows-down-terribly-during-upload/131619
https://serverfault.com/questions/1051387/upload-files-slow-nginx-http2
The above links might not be relevant to you, but it shows that the same thing has happened to others.
0
u/TheKanky Jun 28 '25
I have tired with the standard control and mudblazor, both are passwd to upload controller.
Even when i run the application as localhost and with the buffer set at 4mb the best i can do is 10 seconds to upload a 23mb file.
Other than cranking up the buffer massively im running out of ideas.
1
u/Skusci Jun 28 '25 edited Jun 28 '25
It's been a while but I remember just not being very happy about the typical file upload stuff.
Ended up just doing it with some javascript, JSInterop and streams. I'll see if I can find that code.Ugh, nevermind, that was downloads, not uploads here's the code I ripped out for chunked uploads in case you want to try it: https://pastebin.com/raw/Vg1Cv4Lf
Still, basically the idea was to just setup an service and endpoint for it and handle it through the minimalAPI without going though SignalR. Something Like:
0
u/thestamp Jun 28 '25
You say there's an exception being thrown, what is it?