Chatting about chat servers
Chat servers have many powerful and scalable protocols around which they can be designed, like XMPP or IRC. These are battle-tested concepts which have enabled the creation of a lot of excellent systems. But these protocols are not trivial to implement yourself, and at the end of the day, chat server functionality can simply take text from a message one person creates and send it to many other people.
So, instead of using these protocols (which is otherwise a great idea with a long track record of success) we are going to write something a lot simpler. It won't be anywhere near as proven, but it will allow us to show a number of important concepts without getting into the weeds of protocol implementation.
That being said, we do recommend taking a look at these protocols, as getting a better understanding of them would be an excellent learning experience.
Why are we making a chat server?#
You may be wondering why we have chosen to create a chat server. It doesn't entirely fit into the theme of the other applications we have built in this book. Our key value server and canary deployment server are more of building blocks for web applications, while the chat server is more of an application itself. Well, the chat server will allow us to talk about a number of important concepts in this chapter. The first is relational data and SQL. Relational data is incredibly common in web development, as websites and applications tend to involve concepts that have relationships. For example, messages are sent by users, and users send messages. That's a relation, and being able to properly store and retrieve it is important.