Industry Insights

The One 502 in 20,000

June 26, 2025
Admin

For as long as we can remember, our load balancer has thrown the occasional 502. Roughly one in every 20,000 requests would fail — a tiny blip in the grand scheme of things.

Given the bigger infrastructure challenges we were dealing with, this wasn’t worth chasing – until it was.

In DevOps, even the smallest cracks eventually demand attention.

That moment came yesterday: one of our critical APIs failed – the first time in three years (that we know of).

We started investigating.

A quick Google search – “ELB gunicorn 502” – led us straight to the fix.

The root cause?

  • ELB’s idle connection timeout is 60 seconds by default.
  • Gunicorn’s keep-alive timeout is just 2 seconds.

Gunicorn was closing the connection well before ELB was ready to let go.

All we had to do was set longer keep-alive value when starting gunicorn

gunicorn --keep-alive 65

It is even mentioned in the docs of gunicorn to use a longer value!

Five minutes later, the pull request was merged & deployed. Immediately the problem vanished too.

Sometimes, the fix really is on the first page of Google – if you just google for the right thing.

Latest from DPDzero

Insights on collections, credit risk, and India's lending ecosystem.

Product Updates
August 12, 2026
Naveen

Digital Debt Collections: Building an Omnichannel Strategy That Improves Recovery Rates

Industry Insights
July 14, 2026
Admin

Digital Personal Data Protection Act – How will it impact the Lending Industry

Industry Insights
August 29, 2025
Nahush Dc

How online Real-Money Gaming addiction fuelled a wave of debt

Subscribe

Get the latest insights on what’s shaping Collections.