Thu Jun 07 2018

How does WhatsApp messaging service work?

Technology0 views
How does WhatsApp messaging service work?

WhatsApp being highly popular and the impact on today’s users is growing day-by-day, that's because it's the brilliant cross-platform functionality and user-friendly interface. It normally comes across 50 billion message transfers per day. More than 1 billion people in over 180 countries use WhatsApp to stay in touch with friends and family, anytime and anywhere. It offers simple, secure, reliable messaging and calling, available on phones all over the world. The major difference between regular SMS text messages and WhatsApp text messages is that WhatsApp is free.
WhatsApp was founded by Jan Koum and Brian Acton who had previously spent 20 years combined at Yahoo. WhatsApp joined Facebook in 2014 but continues to operate as a separate app with a laser focus on building a messaging service that works fast and reliably anywhere in the world.

It's playing the role as an inspiration for many developers who want to create an app just like WhatsApp. There are a plenty of expert developers in the market who create out a niche in the business world by designing online social messaging clone scripts, thereby helping out the aspiring entrepreneurs like you to flourish well in the online business market.

You might ever be wondering to know that what's going under the hood of WhatsApp and how this messaging app has managed its level of traffic. In this article, we are going to show you how WhatsApp messaging service work.

So, let’s start -

The setup is consist into three block. Those are -

Client facing app

  • App ( which involves all the UI and basic UX, Android/iOS/Windows)

  • Database to save data in device/work offline (SQLite/Realm)

  • Manage states for the device (i.e network change, calls, etc) and respond to messaging based events (API dependent and available in target OS)

  • Maintain a connection with the server (via Sockets, XMPP, MQTT)

  • Push Notifications (Firebase Cloud Messaging, Urban Airship, One Signal)

  • Media (video/picture) and location feature (Google Maps SDK, Android Media Framework API)

Messaging Channel

  • MQTT is for mobile devices and IoT (preferred, refer to Paho Project)

  • Socket for the desktop app (preferred)

  • XMPP can work in both depending on the scale (GCM uses this)

Server setup/infra to handle messaging transactions at scale

  • An infra that takes care of saving messages as they come/go

  • Load balancing on the server to manage scale when the number of connections increases/decrease

  • Id management to know which connection to use between two Id, maintaining the messaging logic

  • Topics setup to manage delivering messages as well as push notes

  • Database management - Mnesia DB handles the heavy-duty task of database management. Mnesia is a multi-user distributed DBMS which also happens to be the default DB of ERLANG. Mnesia helps achieve quicker request responses, thereby improving the overall efficiency. FreeBSD is the OS upon which WhatsApp is built. Improvising on the ERLANG based applications and optimizing FreeBSD, WhatsApp is able to achieve better performance. For storing multimedia files, the app uses an exclusive web server YAWS.

  • Error Handling to resilient to messages being lost and error in the network

  • End-to-end encryption, to maintain user privacy and make sure data is not sent in plain text over the air.

  • To handle all the above, coding the logic in one of the server side languages. Possible contenders would be NodeJS, Erlang, etc.

  • Have a cloud infrastructure, possibly Google Cloud Platform/AWS/Azure

  • API specifications based on the protocol(MQTT/XMPP/SOckets) used for messaging

  • Database - NoSQL (MongoDB/Aerospike) or SQL

  • End-to-End encryption

In order to create a WhatsApp-like chat app then there are huge technicalities that need to be considered from the start -

  • XMPP (Extensible Messaging and Presence Protocol)- handling the message delivery task, as we mentioned above.

  • Erlang – enabling bug fixes and updates frequently

  • Mnesia – multi-user distributed database management enabling quicker request responses

  • Bootstrap – front-end framework

These are only some of the specifics needed for its development.

Now, let’s check out the process -

  • Once WhatsApp is being installed, the users can register for WhatsApp by entering their mobile number. On entering the number, the user will be sent an OTP which once verified by the device will initiate the user to the chat screen.

  • It uses the Extensible Messaging and Presence Protocol (XMPP) for handling the message delivery task. The main key to the smooth data transfer lies with the message queue length.

  • ERLANG is the programming language used to code WhatsApp. Erlang is agile to adapting to instant updates and hotfixes. This is what helps WhatsApp to quickly push the changes to live implementation without requiring restarts.

  • DSL ensures network security and also helps in preventing private data transfer.

  • As and when the message is sent, WhatsApp’s end-to-end encryption ensures rock-solid for the safety of text & multimedia content.

  • When a sender sends messages, sender's phone does the encryption and send it to WhatsApp server.

  • It is queued on the server. The message waits in the queue until the recipient reconnects to receive the message.

  • As and when a message is delivered the sender gets notified by a double check mark near the message.

  • Now, receiver’s phone decrypts the messages and displays it.

  • After the delivery, the messages are instantly deleted from the server memory.

  • This instant deletion from server memory helps WhatsApp keep its resources to a bare minimum.

  • WhatsApp uses HTML5 WebSockets which communication technology which facilitates two-way communication.

  • Same as vise-verse. The server gets the replies from the receiver’s end, encrypts it and sends to your smartphone. Now, your phone decrypts the messages and displays it.

WhatsApp's other services

Audio & Video Calls

WhatsApp uses highly equipped headway technology rather than WebRTC. The Opus/SILK audio codec 16khz with 20 kbps bitrate and NAT (Network Address Translation) techniques are used to enable audio calling. The STUN server and Peer to Peer connection are the key elements included to boost and maintain authentication to the users.

Multimedia messages are sent by uploading the image, audio or video to be sent to an HTTP server and then sending a link to the content along with its Base64 encoded thumbnail (if applicable).

Location Sharing

WhatsApp integrates Google Maps Android API and Google Places API. This API is used for location sharing among the users. WhatsApp is enhanced according to their multiple needs.

Payment Module

  • UPI – Unified Payment Interface is one of the payment modules which is more secure, user-friendly and allows instant payment.

  • VPA – Virtual Payment Address will use the email address which is registered in the particular bank account that can be shared publicly instead of a bank account number and IFSC code.

  • MPIN – Mobile banking Personal Identification Number is a 4-6 digit security code used to authenticate all types of money transferred via UPI

 

Lastly says, chat and messaging is playing a vital role in various businesses it becomes imperative for every application to have an established real-time communication channel. On top, it is just matter of minutes to integrate such an awesome user-friendly functionalities/features with readily available chat and messaging SDKs.

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.