Home > Blockchain >  503 Server Unavailable after user uploads many files. Is this an httpRuntime setting?
503 Server Unavailable after user uploads many files. Is this an httpRuntime setting?

Time:11-30

My C# ASP.net MVC site allows users to upload many photos at a time (using dropzone.js). After uploading about 80 files the user started receiving a 503 Server Unavailable error.

They waited a few minutes, retried the files that failed and the rest uploaded (about 20).

How can I prevent the server from doing this?

When it happened, the rest of the site remained operational.

TIA!

CodePudding user response:

A 503 Server Unavailable error under load typically means you've crossed some resource limit on your server. There's two ways to fix this:

  • Change the client, so it doesn't reach this limit (or at least not quickly). For dropzone specifically I'd add throttling logic to it so that when a user drops a 100 photos all at once-- your logic will process these in batches (e.g. five at a time).
  • Change the server, so this limit is higher. Without more information about your infrastructure it's difficult to tell what's causing the current bottleneck. It could be as simple as scaling up the CPUs/RAM of your host.

CodePudding user response:

503 Server unavailable means, your application is not scalable and breaking to handle further requests. Couple of suggestions to fix this issue.

  1. Vertical scaling
  2. Horizontal Scaling
  3. Revisit the Architecture

Even before going through these points, I suggest to "load test" your current app and create bench-marking. Means start testing application for 100 files per minute, 200, 300 ... and identify at which number it is breaking/throwing 503 error. You can use simple JMeter kind of tools for this.

And also define your target requirement. like 10K files per hour or 100 files per minute...

Vertical Scaling: Based on your bench marking results from load test, you can start fine tuning RAM/CPU/IO capacity of the existing machine. Example if you are using containers , you can increase the allocated hardware resources. And repeat the test until it satisfies your target requirement.

Horizontal Scaling Based on your bench marking results from load test, start adding more nodes to your cluster. And repeat the test.

Revisit the Architecture The above two options talks about infra fine tuning without modifying application architecture. But your requirement is "file uploading" which is IO task not CPU bound. So to achieve greater scalability with optimal resources you can consider re architecture the application either using "NodeJS" or "C# Reactive X" (https://github.com/dotnet/reactive). These are Reactive style programming which will provide you non-blocking async processing capabilities.

  • Related