System Design - Design Like/Unlike/Favorite System
[ OK ]b485181f-1f78-4a27-917a-f7d50c22fd1c — full content available
[ INFO ]category: System Design difficulty: unknown freq: first seen: 2026-05-28
[UNKNOWN][SYSTEM DESIGN]High Frequency
$catproblem.md
Design Like/Unlike/Favorite System
Problem Statement
Design a like/unlike system for Roblox Marketplace items, games, or experiences. Users should be able to like or favorite an item, unlike or unfavorite it, check whether they already liked an item, and retrieve a list of liked or favorited items. Consider the scalability, consistency, and performance of the system.
Constraints
High volume of users and items.
High read and write throughput.
Real-time updates for liked/favorited status.
Consistency across different regions and data centers.
Examples
User A likes item X.
User B checks if they have liked item Y.
User C retrieves a list of their liked items.
User D unfavorites item Z.
Hints
Use a distributed database to handle high read and write throughput.
Consider using caching for frequently accessed data.
Implement rate limiting to prevent abuse of the system.
Use a publish-subscribe model to update liked/favorited status in real-time.
Solution
Database Design:
Use a NoSQL database like Cassandra or MongoDB to handle high write throughput and horizontal scaling.
Store user likes/favorites in a separate collection/table with user ID, item ID, and timestamp.
Use a composite key (user ID, item ID) for efficient lookups.
Caching:
Implement caching using Redis or Memcached to store frequently accessed data like user likes/favorites.
Set an expiration time for cache entries to ensure consistency with the database.
Real-time Updates:
Use a publish-subscribe model like Apache Kafka or RabbitMQ to broadcast updates to interested parties when a user likes/favorites an item.
Use WebSockets or long polling to push updates to the client in real-time.
Rate Limiting:
Implement rate limiting to prevent abuse of the like/unlike system.
Use a token bucket or leaky bucket algorithm to control the rate of requests per user.
Consistency:
Use eventual consistency to ensure data is replicated across different regions and data centers.
Monitor replication lag and adjust the caching strategy accordingly.
API Design:
Design RESTful APIs for like/unlike and favorite/unfavorite operations.
Use JSON or XML for request and response payloads.
Implement authentication and authorization to ensure secure access to the APIs.
Monitoring and Logging:
Monitor the system's performance and error rates using tools like Prometheus or Datadog.
Log requests and responses for debugging and auditing purposes.
By following these steps, you can design a scalable, consistent, and performant like/unlike and favorite/unfavorite system for Roblox Marketplace items, games, or experiences.