Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure / Image request 502 (Bad gateway) error - intermittent

I'm working on http://www.lovethesales.com - and have come up against an annoying issue.

As you'll probably be able to see for yourself on the homepage, sometimes, and intermittently, image requests will fail with a 502 Bad Gateway error. This seems to happen in all browsers - (you can see the red failed requests in the Chrome developer tools, for example)

The resource in question /imageproxy can never return anything other than a 200, or a 304.

1) This page (set to show 500 results) never seems to have broken images, even though it's making similar / the same requests, but showing even more of them:

http://www.lovethesales.com/sales/?take=500

2) If you CTRL + refresh - it's always fine, it's only if you do a 'soft' headers refresh do you receive a 502 error. (Just clicking the refresh button)

The handler is a standard IHttpHandler, registered as follows:

<add name="ImageProxy" path="/home/imageproxy*" verb="*" type="LoveTheSales.Handlers.ImageProxy" resourceType="Unspecified" preCondition="integratedMode" />

Any advice / ideas on how to tack this down would be most appreciated.

Cheers, Dave

[EDIT] I have managed to recreate the issue on my test Azure instance (only me using it) - and, after turning on full web/request logging - I can see that the 502 requests are never even making it to my application - they aren't even in the logs. I guess this must be an Azure error?

[EDIT 2] This also happens on non-Imageproxy requests, so, simple static images too

like image 313
Dave Bish Avatar asked Nov 10 '22 07:11

Dave Bish


1 Answers

a few things i tend to do with issues like this

1) Make a fiddler trace. This issue seems hard to reproduce for some users/circumstances. tools like Fiddler allows you to record exactly what is happening. Especialy interesting would be what (if anything) is different between failing and succeeding requests/responses

2) Make it so the user don't notice it. For example a jquery error handler that just resubmits the request. I've had it happen just once (of course before i turned on fiddler myself). If the issue is rare enough maybe it's just good enough to handle that 0.1% of the cases where it goes wrong gracefully.

3) perform a serious load test (locally). if you look here http://blog.wouldbetheologian.com/2014/07/502-bad-gateway-error-on-azure-websites.html there might be a underlying causes that crashes your app pool. This would not get logged, a new instance gets spinned up but you get a 502 requests on requests to your old instance.

Especially this last case is something that would fit the little i can see of your scenario.

like image 197
Batavia Avatar answered Nov 14 '22 22:11

Batavia