System Design - Push Notification System for New Posts
[ OK ]72f3d8ab-059b-4e17-a3ac-6a19b76429f8 — full content available
[ INFO ]category: System Design difficulty: unknown freq: first seen: 2026-03-13
[UNKNOWN][SYSTEM DESIGN]
$catproblem.md
System Design - Push Notification System for New Posts
You are tasked with designing a notification system that sends push notifications to followers when an author publishes a new post. The system should handle the following requirements:
Followers and Devices: Followers may have multiple devices, and the system should support sending notifications to all of their devices.
Notification Preferences: Followers can mute or disable notifications. The system should respect these preferences.
Authors and Posts: Some authors may have a large number of followers, and the system should efficiently handle the notification process for these authors.
Scalability: The system should be scalable to handle a large number of users, devices, and notifications.
Examples:
User A follows User B and User C.
User B publishes a new post.
User A should receive a push notification on all their devices, unless they have muted or disabled notifications for User B.
Constraints:
The system should be able to handle a high volume of notifications in a short period.
The system should minimize the latency between a post being published and the notification being sent.
The system should be fault-tolerant and handle failures gracefully.
Hints:
Consider using a publish/subscribe model for efficient notification delivery.
Use caching to store user preferences and device information.
Implement rate limiting to prevent abuse and ensure system stability.
Solution:
Data Model:
User: Contains user information, including their device tokens and notification preferences.
Post: Contains post information, including the author and publication date.
Follower: Represents the relationship between a user and an author they follow.
Notification Service:
When a post is published, the notification service is triggered.
The service queries the follower table to find all users following the author of the post.
For each user, the service checks their notification preferences and device tokens.
If a user has not muted or disabled notifications, the service sends a push notification to all their devices.
Scalability:
Use a message queue to handle the high volume of notifications and ensure they are processed in order.
Implement sharding to distribute the load across multiple database instances.
Use a caching layer to store user preferences and device tokens for fast access.
Fault Tolerance:
Implement retries for failed notifications with exponential backoff.
Monitor the system for failures and alert the team if issues arise.
Use a distributed database to ensure data is replicated and can be recovered in case of a failure.
By following these guidelines, you can design a robust and scalable push notification system for new posts that meets the requirements outlined in the problem statement.