No, WhatsApp is not made using Python. WhatsApp was created in 2009 by Brian Acton and Jan Koum, former employees of Yahoo. It was built using Erlang, a programming language created by Ericsson in 1986 for building massively scalable soft real-time systems. Erlang is particularly well-suited for applications that require high concurrency, distribution and fault tolerance.
Why was Erlang chosen to build WhatsApp?
There are a few key reasons why the WhatsApp engineering team selected Erlang to build their messaging app:
- Scalability – Erlang utilizes the actor model for concurrency. This allows it to distribute workload across multiple cores and servers. WhatsApp needs to handle billions of messages sent daily across over 1.5 billion users. Erlang provides the scalability required for this level of throughput.
- Real-time performance – Erlang was designed for systems that require soft real-time response rates. Its concurrency model and messaging architecture allow it to process requests with low latency critical for real-time applications.
- Availability – Erlang provides built-in features for high availability. Things like hot code swapping allow software updates without any downtime. WhatsApp is expected to provide always-on service and minimize disruptions.
- Fault tolerance – Erlang isolates errors and faults using its supervisor trees. This compartmentalization ensures failures in one process don’t bring down the whole system. WhatsApp needs to be highly fault tolerant given how much it relies on unstable mobile networks.
- Distributed nature – Erlang provides primitives for distributed computing within its syntax and standard libraries. This makes it easier to scale across multiple machines. WhatsApp runs on thousands of distributed servers.
Erlang’s strengths in scalability, low-latency, high availability and fault tolerance make it a great choice for building a massively distributed messaging system like WhatsApp. While other languages like Python can support these features, Erlang was designed from the ground up specifically for these use cases.
Why wasn’t Python used to build WhatsApp?
While Python is an extremely versatile general purpose programming language used for all kinds of applications, it does have some limitations that make it unsuitable as the primary language for building a messaging platform like WhatsApp:
- Performance – Python’s dynamic nature comes with performance costs for some use cases. WhatsApp needs to handle millions of concurrent connections and messages in real-time. Python’s performance is not on par with static compiled languages like Erlang for these scenarios.
- Concurrency – Python’s concurrency constructs like the GIL aren’t designed for massive concurrency and distributed computing. Erlang has concurrency as a core principle of the language.
- Scalability – Python can scale horizontally but becomes complex without native language level support. Erlang provides language level scalability constructs.
- Fault tolerance – While Python has some fault tolerance libraries, Erlang was built for fault tolerance from the ground up with features like supervision trees.
- Soft real-time – Python is not designed for soft real-time systems that require predictable response times. Erlang provides real-time responsiveness at low latencies.
Python is an amazing general purpose language. But for a messaging platform like WhatsApp with specific infrastructure needs like massive concurrency, distribution, fault tolerance and soft real-time performance, Erlang is a more purpose-built choice.
What are the components of WhatsApp built with?
While Erlang is the primary language used to build WhatsApp, the app has several components built using other languages and technologies:
- Client apps – The Android, iOS and Web clients of WhatsApp are built using Java, Objective-C/Swift and JavaScript respectively. These allow WhatsApp to run natively on these platforms.
- Admin panel – The admin portal used by WhatsApp to manage the platform is built using PHP. The frontend utilizes ReactJS.
- Multimedia storage – WhatsApp uses Hadoop clusters built in Java to store billions of images and videos sent by users.
- User database – User account data including contacts is stored in a MySQL relational database. This provides efficient storage and querying of structured user data.
- Message database – Billions of messages sent daily are stored and indexed in HBase, a NoSQL database built on Hadoop. This allows massive scalability with high availability.
- Caching layer – Memcached is used extensively to cache data from the databases to improve performance and reduce load on persistent storage.
- Load balancers – HAProxy software load balancers distribute incoming requests across Erlang VM nodes.
- OS layer – The Erlang VMs run on top of Linux in WhatsApp’s datacenters. The high performance and stability of Linux helps improve Erlang VM performance.
So in summary, while Erlang powers the core messaging platform, WhatsApp uses a mix of languages and technologies like Java, PHP, JavaScript, Objective-C, MySQL, HBase, Hadoop and Linux to build out its complete infrastructure.
What are the main technical challenges WhatsApp faces?
As one of the largest messaging platforms in the world, WhatsApp faces some significant technical challenges sustaining and scaling its infrastructure:
- Billions of concurrent connections – WhatsApp needs to handle billions of devices connecting to their service concurrently.
- Billions of messages sent daily – On average, over 100 billion messages are sent over WhatsApp per day.
- Low latency for messages – Users expect messages to be delivered instantly with minimal delays.
- Media content – WhatsApp needs to handle sending large volumes of media files like images and videos.
- Cross-platform experience – The WhatsApp user experience needs to be consistent across Android, iOS, Web and other platforms.
- Offline support – WhatsApp needs to gracefully handle devices abruptly losing connectivity and transitioning between online and offline states.
- Security – Encrypting messages end-to-end and preventing abuse on platform is vital to maintaining trust.
- Reliability – WhatsApp cannot afford prolonged downtime given its importance as a real-time communication platform.
WhatsApp engineering has to constantly optimize and scale their systems to meet these challenges. From sharding their databases, running load tests, improving server efficiency to building in redundancy, they utilize a variety of techniques to ensure WhatsApp runs smoothly through user growth and technological shifts.
Major WhatsApp features built with Erlang
Here are some of the major WhatsApp features that are built using Erlang:
- Messaging – The core messaging functionality including sending, receiving and storing text messages relies on Erlang.
- Notifications – The notification system to instantly alert users of new messages uses Erlang’s real-time capabilities.
- Group chat – WhatsApp support for groups with up to 256 participants is built atop Erlang’s scalability.
- Media sharing – The ability to send and share photos, videos and voice messages relies on Erlang’s distribution.
- Locations – WhatsApp’s sharing of real-time locations taps into Erlang’s concurrency and distribution strengths.
- Offline support – Queuing and buffering messages when offline leverages Erlang’s fault tolerance.
- End-to-end encryption – The voice and video call encryption is powered by Erlang’s reliability and security.
- Syncing across devices – Keeping message history and data in sync across multiple devices utilizes Erlang’s distribution.
Nearly all of WhatsApp’s core messaging capabilities and real-time performance benefits from Erlang’s proficiency in concurrency, distribution and fault tolerance. This provides the foundation for the fast, reliable and scalable user experience WhatsApp is known for.
Conclusion
In summary, WhatsApp is built primarily using Erlang, not Python. Erlang provides the concurrency, scalability, real-time performance and fault tolerance required by a massive messaging platform like WhatsApp. While Python is an extremely versatile language, its technical strengths did not match WhatsApp’s specific infrastructure needs as closely as Erlang. However, WhatsApp does utilize Python and many other technologies like MySQL, HBase, JavaScript, PHP and Java to build out its full-stack infrastructure. The engineering team continues to scale WhatsApp reliably using Erlang to support over a billion daily users across the globe.