Skip to content

Glific: Fix HTTP 520 errors #1142

Closed

Description

@kartpop

Is your feature request related to a problem?
Glific is experiencing intermittent HTTP 520 errors (~5–6 times per day) on the POST /api/v1/llm/call endpoint. The issue likely arises from idle-timeout settings in the connection layer rather than application code, affecting overall reliability.

More details here

Describe the solution you'd like

  • Update Dockerfile to add --timeout-keep-alive 180 to the uvicorn CMD.
  • Modify core/rate_monitor.py to include socket_timeout=1 and socket_connect_timeout=1 for the Redis client.
  • Raise ALB connection idle timeout to 120s.
  • Enable access logs to S3 for future diagnostics.
Original issue

Context

Glific intermittently receives HTTP 520s (~5–6/day) on POST /api/v1/llm/call across multiple orgs. App logs show healthy sub-second processing and complete job-enqueue traces for the affected windows — the failures probably happen at the connection layer (Cloudflare ↔ ALB ↔ uvicorn), not in application code. Low traffic (~1.2 req/min) means keepalive connections sit idle constantly, triggering the classic idle-timeout race with default settings.

Ref: internal investigation doc (debug.md), Glific report from Priyanshu, 2026-08-18 failures.

Code changes

  • Dockerfile: add --timeout-keep-alive 180 to the uvicorn CMD (must exceed ALB idle timeout)
  • core/rate_monitor.py: add socket_timeout=1, socket_connect_timeout=1 to the Redis client — currently it can block requests indefinitely

Ops changes (done/tracking)

  • ALB: raise connection idle timeout to 120s (> Cloudflare's 90s origin keepalive)
  • ALB: enable access logs to S3 to diagnose the next occurrence (will cost extra - decide if should be done now or later)

Activity

  1. changed the title [-]Intermittent Cloudflare 520s on Glific-facing endpoints — connection-layer hardening[/-] [+]Glific: Fix HTTP 520 errors[/+] on Aug 20, 2026
  2. moved this from To Do to In Progress in Kaapi-devon Aug 25, 2026
  3. moved this from In Progress to Closed in Kaapi-devon Aug 27, 2026
  4. moved this from Closed to In Progress in Kaapi-devon Aug 28, 2026
  5. Prajna1999 commented on Aug 28, 2026

    @Prajna1999
    Collaborator

    With this 1sec socket_timeout if Redis is just slow (GC pause, network blip, connection pool exhaustion) rather than down, calls will time out and raise redis.exceptions.TimeoutError/ConnectionError . Need some more testing to check what should be the ideal number for our use case

  6. self-assigned this
    on Aug 28, 2026
  7. moved this from In Progress to Closed in Kaapi-devon Aug 31, 2026
  8. closed this as completedby moving to Closed in Kaapi-devon Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

  • Status
    Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions