📊 Notification Delivery Sequence Flow

Main flow from match event to user notification delivery

← Scroll horizontally to see full diagram →
🏟️
Match Venue
Event Source
🚪
API Gateway
Nginx + PHP
Redis
Cache + Dedup
🐰
RabbitMQ
Message Broker
⚙️
Workers
Batch Processor
🔥
Firebase
FCM + Push
📱
User Device
Web/iOS/Android
Phase 1:
Event Ingestion
~5-10ms
POST /events/match
SETNX event:{id} (dedup)
OK / EXISTS
Phase 2:
Queue Routing
~2-5ms
AMQP Publish → notification.events exchange
Topic routing to queues:
• notifications.web
• notifications.ios
• notifications.android
• notifications.email
202 Accepted
Phase 3:
Batch Processing
~50-100ms
loop [for each platform queue]
Basic.Consume (prefetch: 100)
GET user_prefs + device_tokens
Cached preferences & tokens
Batching:
Collect up to 500 device tokens per FCM request
alt [by platform]
[platform = web/ios/android]
[platform = email] [else → DLQ]
Phase 4:
External Delivery
~100-300ms
par [parallel delivery]
POST /fcm/send (multicast)
200 OK + delivery receipts
APNs/FCM Push
Phase 5:
User Receives
~10-50ms
📱 Push Notification
Displayed to User
✅ End-to-End:
P50: ~200ms
P95: <500ms
P99: ~800ms
Basic.Ack (batch)
Async: Log delivery status to PostgreSQL for analytics & retry tracking
⚠️ Error Handling:
• FCM 500 → Retry with exponential backoff (10s min)
• FCM 429 → Wait for retry-after header (default 60s)
• Token invalid (400/404) → Remove from DB, do not retry
• Timeout (10s) → Re-queue with jittering
• Max retries → Move to DLQ
Diagram Legend
Request / Command
Response / Return
loop
Loop (iteration)
alt
Alternative (conditional)
par
Parallel execution

World ChessBoxing Championship - Notification Sequence Diagram

Event → API (PHP) → RabbitMQ (php-amqplib) → Workers (Redis lookup) → Firebase FCM → User

Marvin the Martian
"This technology and infrastructure is better than my Illudium Q-36 Explosive Space Modulator!" ✓ Marvin the Martian Approved