Emergency Messaging
14x faster SMS alerts, within carrier rules | CheckPoint Business Intelligence | private company project, sanitized
context
The platform texts workers: muster and evacuation orders, safety alerts, invitations, and links to their own pages. A single alert can fan out to thousands of recipients through Twilio, and the messages have to respect the US carrier rules for application-to-person traffic (A2P 10DLC), consent and opt-out (TCPA), and the per-second limits of the sending numbers.
problem
The sender was provisioned for 100 messages per second, but the platform submitted about 6.7 per second: every send cost about 3 seconds, because a worker thread spun up its own event loop, hit a blocking database gate, created a new HTTP client per message and wrote its logs inline, and the fan-out ran one recipient at a time. Emergency bodies also contained one character outside the GSM-7 alphabet, which silently switched them to UCS-2 encoding and split every alert into three segments: a 5,000-recipient blast meant 15,000 segments. The delivery webhooks had never run, and one bad day produced 6,825 failed MMS.
what I did
- Measured segment counts with the repo's own encoder and gave the 15 message composers fit-in-one-segment ladders with short links, so emergency bodies always go out as a single GSM-7 segment.
- Wrote a segment-based token-bucket governor that spends sending capacity in segments, keeps an interactive reserve so a blast never starves one-off messages, and retries through the Messaging Service.
- Moved sending onto persistent worker event loops with a pooled HTTP client, and raised bulk concurrency from 20 to 40.
- Wired the delivery and inbound webhooks that had never run, with signature checks that fail closed, and the STOP suppression list.
- Replaced MMS with link messages: a short SMS pointing to a public, rate-limited page served by nginx, with the message content behind it.
stack
Python FastAPI Twilio Redis SQL Server nginx
outcome
- Submission from 6.7 to 88-133 messages per second in production (14x): a 500-recipient blast in about 5 s instead of 75 s, and the cost of one send from 3 s to about 410 ms.
- A 5,000-recipient emergency alert costs 5,000 segments instead of 15,000: a third of the carrier charges.
- Every message goes out within the sender's limits, with consent and opt-out handled by the platform rather than by hand.
Sanitized case study -- no customer names, phone numbers, account identifiers, or hostnames.