Skip to content

fix(gsm): bound the outbound SMS queue and return 503 on saturation #252

Description

@Adamskiee

GSM-fastapi/serial_worker.py:72 creates self._send_queue = queue.Queue() with no maxsize. Under sustained load the queue grows without limit — no backpressure, no load shedding.

Compounding: api.py:306 send_sms is a sync FastAPI endpoint blocking up to 60s (api.py:324); _send_and_log blocks up to 120s (api.py:152). FastAPI runs sync endpoints in the anyio threadpool (default 40 workers), so ~40 concurrent SMS requests exhaust the pool and the whole GSM service stops responding — including /health (api.py:208), which is also sync.

Fix: give _send_queue a maxsize, and return HTTP 503 when full instead of blocking or growing unbounded.

Related: #227 (rate limiting).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendgsmGSM-module SMS gateway

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions