notexOPENOverview
Notex/Systems/Design a chat system

Design a chat system

Always free to read

In this chapter we explore the design of a chat system. Almost everyone uses a chat app. Figure 12-1 shows some of the most popular apps in the marketplace. A chat app performs…

12

DESIGN CASE STUDIES

Design a chat system

13 LESSONS · 24 MIN
  1. 12.01Design a chat systemIn this chapter we explore the design of a chat system. Almost everyone uses a chat app. Figure 12-1 shows some of the most popular apps in the marketplace. A chat app performs…READING1 MIN
  2. 12.02Step 1 - Understand the problem and establish design scopeIt is vital to agree on the type of chat app to design. In the marketplace, there are one-on-one chat apps like Facebook Messenger, WeChat, and WhatsApp, office chat apps that…READING2 MIN
  3. 12.03Step 2 - Propose high-level design and get buy-inTo develop a high-quality design, we should have a basic knowledge of how clients and servers communicate. In a chat system, clients can be either mobile applications or web…READING2 MIN
  4. 12.04PollingAs shown in Figure 12-3, polling is a technique that the client periodically asks the server if there are messages available. Depending on polling frequency, polling could be…READING1 MIN
  5. 12.05Long pollingBecause polling could be inefficient, the next progression is long polling (Figure 12-4). In long polling, a client holds the connection open until there are actually new…READING1 MIN
  6. 12.06WebSocketWebSocket is the most common solution for sending asynchronous updates from server to client. Figure 12-5 shows how it works. WebSocket connection is initiated by the client.…READING1 MIN
  7. 12.07High-level designJust now we mentioned that WebSocket was chosen as the main communication protocol between the client and server for its bidirectional communication, it is important to note…READING4 MIN
  8. 12.08Data modelsJust now, we talked about using key-value stores as our storage layer. The most important data is message data. Let us take a close look. Message table for 1 on 1 chat Figure…READING2 MIN
  9. 12.09Step 3 - Design deep diveIn a system design interview, usually you are expected to dive deep into some of the components in the high-level design. For the chat system, service discovery, messaging…READING1 MIN
  10. 12.10Service discoveryThe primary role of service discovery is to recommend the best chat server for a client based on the criteria like geographical location, server capacity, etc. Apache Zookeeper…READING1 MIN
  11. 12.11Message flowsIt is interesting to understand the end-to-end flow of a chat system. In this section, we will explore 1 on 1 chat flow, message synchronization across multiple devices and…READING3 MIN
  12. 12.12Online presenceAn online presence indicator is an essential feature of many chat applications. Usually, you can see a green dot next to a user’s profile picture or username. This section…READING3 MIN
  13. 12.13Step 4 - Wrap upIn this chapter, we presented a chat system architecture that supports both 1-to-1 chat and small group chat. WebSocket is used for real-time communication between the client…READING2 MIN

References

Step 4 - Wrap up
  1. Erlang at Facebook: https://www.erlangfactory.com/upload/presentations/31/EugeneLetuchy-ErlangatFacebook.pdf
  2. Messenger and WhatsApp process 60 billion messages a day: https://www.theverge.com/2016/4/12/11415198/facebook-messenger-whatsapp-numbermessages-vs-sms-f8-2016
  3. Long tail: https://en.wikipedia.org/wiki/Long_tail
  4. The Underlying Technology of Messages: https://www.facebook.com/notes/facebookengineering/the-underlying-technology-of-messages/454991608919/
  5. How Discord Stores Billions of Messages: https://blog.discordapp.com/how-discordstores-billions-of-messages-7fa6ec7ee4c7
  6. Announcing Snowflake: https://blog.twitter.com/engineering/en_us/a/2010/announcingsnowflake.html
  7. Apache ZooKeeper: https://zookeeper.apache.org/
  8. From nothing: the evolution of WeChat background system (Article in Chinese): https://www.infoq.cn/article/the-road-of-the-growth-weixin-background
  9. End-to-end encryption: https://faq.whatsapp.com/en/android/28030015/
  10. Flannel: An Application-Level Edge Cache to Make Slack Scale: https://slack.engineering/flannel-an-application-level-edge-cache-to-make-slack-scaleb8a6400e2f6b
KEEP EXPLORING

One note leads to another.

Back to the library →
⌕
Search across the entire library ⌘ K