Report this

What is the reason for this report?

Occasional 502 Bad Gateway When Uploading

Posted on February 6, 2015

Hello,

I’m new to running and maintaining my own server.

I noticed that in my web app, uploading images at a fast speed (i.e. consecutively without waiting for the previous images to finish uploading) sometimes causes my web app to crash with a 502 Bad Gateway error.

Once I refresh the page after this error, everything is OK.

If I upload at normal speeds, everything is fine.

In development mode/localhost, pace of upload is never a problem.

Is this an app issue? Or a server issue? Is this caused by not having a powerful-enough server?

If this is caused by a weak server. How can I tell? Also how do I figure out what I need to upgrade Droplets to in order to prevent this issue?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I think you need to change your php process settings, as you are using nginx I assume you are using php-fpm? check how many children, and max_spare_server are you running. You may need some tweaks.

also check with top/htop how much memory are you consuming in your droplet, is is near the top of it, you may need an upgrade, but also can be you have too many php processes running for your amount of ram available, so again you may need some tweaks there.

Thank you EpicCDN,

I’m actually using Node.JS and the app is a Meteor.JS app. And the uploads are happening via whatever way GraphicsMagick uses.

Could you please help me understand how to do these tasks?

  • How can I check “how many children” and “maxspareserver” are running?
  • How can I check top/htop memory I am consuming?

Also since the posting of this topic, I did upgrade. The problem happens slightly less but I it didn’t stop completely. I find that this happens especially more if I continuously upload images that are 7 to 14 mbs big at somewhat quick speeds.

If I do not wait for each upload to finish, this problem is particularly worse.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.