Forums

502 backend error

I’m sending data via POST to a web app based on the first part of the Flask tutorial; computing with the scipy package; and returning a simple html page. This works fine with modest size datasets but results in a 502 backend error after several seconds when the dataset size gets too big - e.g. 5MB. The computation is actually successful, but there are no clues in any of the log files, and very little cpu seconds or storage space is used. I’m wondering if some other kind of limit is being exceeded - size? time? Any hints, thoughts, workarounds, advice, etc. would be greatly appreciated.

that sounds weird. So your computations completely finish? Try printing to stderr (you should see the prints in your webapp error logs) to try to see at what point exactly your webapp errors/throws a 502?

thanks. I sprinkled a few prints but all looks ok right up until final return '...' statement - this just for debugging; to be replaced eventually with render template. looks like computing took ~10 sec of real time but tiny cpu sec.

How much data are you returning? I'm wondering if you're hitting some limit on response size in our infrastructure.

This is what I don't understand, because I'm hardly returning anything. Ideally it would be a ~50 lines of html, including <img src="https://.../static/graph.png"... , but for debugging it's just a few characters in the return statement.

In any case, I think I have a workaround by just fetching static files individually...

If you like I could take a look at your code, just to see if there's anything there that looks odd. We can see your files from our side, but we always ask for explicit permission first.

Thanks to Giles' persistence and questioning, it turns out the unusually long headers (~3k) I was returning with the rendered template was the culprit. No more 502 error after taking this out.

Excellent! Thanks for confirming.