How does messaging work in WhatsApp?



WhatsApp is a real-time messaging application, which makes use of Ejabberd (XMPP) server. This server facilitates instant message transfer between two or many users at any given second.

 Ejabberd is a Rock Solid, Massively Scalable, Infinitely Extensible XMPP Server, written mainly in the Erlang programming language.

Ejabberd (http://www.ejabberd.im/) is the parent, this is XMPP server which provides quite good features of open source, Whatsapp uses some modified version of this, facebook 

Messaging also uses a modified version of this. Some more chat applications likes Samsung's 
ChatOn, Nimbuzz messenger all use ejabberd based ones and Erlang solutions also have modified version of this ejabberd which they claim to be highly scalable and well tested with more performance improvements and renamed as MongooseIM.

Ejabberd is the server which has most of the featured implemented when compared to other. Since it is built in Erlang it is highly scalable horizontally.

For the database management Mnesia DB comes into play. Mnesia is a multiuser distributed DBMS which happens to be the default DB of ERLANG. Thus by using Mnesia, the app is able to achieve quicker request responses, thereby improving the overall efficiency.

FreeBSD is the operating system upon which WhatsApp is laid upon. Improvising on the ERLANG based applications and optimizing FreeBSD, WhatsApp is able to achieve better throughput. For storing multimedia files, the app uses an exclusive web server YAWS.