A user could publish a message to a publisher
Users could subscribe messages from the same publisher
List non-functional requirements for the system...
Estimate the scale of the system you are going to design...
publish_message(topic, message)
subscribe_to_message(topic, max_item_in_queue)
get_message(topic)
MessageDB
topic_name (primary key)
timestamp (sort key)
message
TopicDB
topic_name
subscriber_id: array
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
A message is being published to server, it will first goes to the Queue. The server may not be able to directly process the message. Therefore, it will first go to a queue. When the server is ready to process next message, it will get the first message from the queue. Next, it will first insert the message into the cache. There will be another service which periodically dump the Redis cache into the database. There shall also be a WAL to ensure if anything fails, we can recover the data.
When subscriber subscribes to a topic, a queue will be created. When a message is pushed, the timestamp will be put into the queue for each subscriber. When the subscriber is ready to get the message, it will get the timestamp from the queue and read the message from cache. Once the subscriber acknowledges the message, the timestamp will be removed from the queue.
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Explain any trade offs you have made and why you made certain tech choices...
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?