Skip to content

Work

Push Notification Pipeline

Notifications for 2M+ combined users without taking the server down.

Role
Designed and built
Metric
2M+ combined users
Stack
  • Python
  • Celery
  • Redis
  • PostgreSQL
  • Firebase Cloud Messaging

The problem

Notifications were sent by looping over users inside the API request. Under heavy traffic the request blocked, the server sometimes crashed, and Firebase rejected bursts with too-many-requests errors.

Before: requests hit one API that loops over users. The request blocks and Firebase answers with 429 Too Many Requests.

The design

After: the API stores the job in a Redis queue and answers 202 Scheduled. Celery workers, backed by PostgreSQL, drain the queue and send to Firebase. Workers scale with load.
  1. 01

    The API stores the job in a queue and immediately responds that the schedule is set.

  2. 02

    Celery workers on Redis, backed by PostgreSQL, drain the queue.

  3. 03

    Under heavy traffic, more workers are added; when it drops, workers are reduced.

Also on this page

Order API 1.2s → 0.4s via query optimization, PostgreSQL indexing and caching.

Order API0.4s · −67%
  • slow query
  • missing index
  • no cache
The Order API started at 1.2s. Fixing a slow query, a missing index and the lack of a cache brought it to 0.4s.

Key decisions

  • A queue instead of more servers: cheaper, and it absorbs spikes instead of failing under them.

  • Respond first, send later: the caller gets an answer in milliseconds regardless of audience size.

  • Scale workers, not the API: capacity follows load, and the web tier stays fast for shoppers.

Result

The API never blocks. A traffic spike makes the queue longer instead of crashing the server.

Next case study

Biometric Attendance Backend