Design a Webhook Delivery System
Problem Statement
Design a generic and scalable Webhook System** that allows a platform to notify external client systems (subscribers) in real-time when specific events occur.
For example:
The system should support event publishing, reliable delivery, retry on failure, and subscriber management.
🎯 Functional Requirements:
⚙️ Non-Functional Requirements:
🧱 Core Components:
ComponentResponsibility
Publisher API
Internal services use to emit events
Event Router/Queue
Pushes events to topic/queue for async processing
Webhook Registry
Stores subscriber info and delivery config
Delivery Workers
Pick events from queue and push to client endpoints
Retry Manager
Retries failed deliveries with backoff
DLQ Handler
Moves permanently failed messages for inspection
Logging/Monitoring
Tracks delivery metrics and errors
Security Layer
HMAC signing and validation for trusted delivery
📦 High-Level Flow:
🛢️ Database Schema (Simplified)
webhook_subscriptions
1bash
2CopyEdit
3id | client_id | event_type | endpoint_url | secret | is_activeevent_logs
1lua
2CopyEdit
3event_id | event_type | payload | created_at | retry_count | statusdlq
1nginx
2CopyEdit
3event_id | reason | last_attempt_time | payload🚀 Scalability and Reliability Strategies:
🔐 Security Considerations:
🧰 Suggested Tech Stack:
LayerTools
Event Queue
Kafka / RabbitMQ / SQS
Worker Execution
Node.js / Go / Java
Database
PostgreSQL / DynamoDB
Retry Scheduler
BullMQ / Sidekiq / Celery
Monitoring
Prometheus + Grafana
DLQ Storage
S3 / DynamoDB / Elasticsearch
Security
Vault for key storage
🔁 Example Event (Webhook Payload):
1json
2CopyEdit
3POST /webhook
4Headers:
5 X-Signature: HMAC-SHA256=abc123...
6
7Body:
8{
9 "event": "ORDER_PLACED",
10 "timestamp": 1658723423,
11 "data": {
12 "order_id": "ORD123",
13 "amount": 499.00
14 }
15}✨ Optional Extensions: