As of February, 2017 WhatsApp crossed 1.2 billion users globally. Ever wondered how a team of just 55 engineers at WhatsApp is able to manage a billion of users?
A simple answer -> Erlang
Erlang is a functional language paradigm which is used for complete backend stack of WhatsApp. WhatsApp basically uses ejabberd XMPP Application server for backend implementation of WhatsApp messenger which is a open source project developed in Erlang.
Now what is so special about Erlang or the implementation of ejabberd server? Also, Going to little bit deeper, there is a huge difference the way processes are created in Erlang and other languages and that is the reason processes in Erlang are so light weight.
- Massively scalable : It has massive concurrency, can handle upto 2, 000, 000 users on one node
- Fault tolerant : In a real-time system, we know that errors will occur and things will break and so do the erlang engineers. To prevent this, Erlang has strong tools to minimize the errors and recover from them as early as possible.
- OS created processes: Erlang processes (known as green threads) are created by Erlang VM, instead of OS
- Context switching: Switching between processes, one process knows the Pid of process it switches to, so there is no role of scheduler to play, hence making it O(1) operation.
- Process Isolation: Processes are completely isolated due to which there is no need to implement mutexes so as to prevent deadlock situations.
The scalability mentioned above is gained in a way Erlang system creates processes.
The following properties of Erlang processes helps it achieving such high scalability :
- They are lightweight (grow and shrink dynamically)
- They are fast to create and destroy
- The scheduling overhead is very low
- There is no shared space between processes, and the only way they can communicate is through message passing
You can expand the idea in this way – The Erlang VM is operated by one OS process, and Erlang VM can create as many processes as per need, so one OS process is controlling many Erlang processes, that’s why there is no overhead on Operating System and everything is taken care of by Erlang Virtual Machine.
Since you require very less number of systems to handle billion of users, so you need less number of engineers.
This article is contributed by Mandeep Singh. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.