. / V\ / ` / << | / | / | / | / \ \ / ( ) | | ________| _/_ | | <__________\______)\__)
migrate to Elixir & Erlang VM!
Hi Nejis, I completely move and re-build the website everything from scratch, at the first launch i use Flask tech stack and now it's using Elixir and Erlang VM!!
is that good? YES to be sure (even tho it's new program languange (2012))
>first i will show you 100s videos from Fireship about elixir
https://www.youtube.com/watch?v=Z_FHEFao-r8
"The Secret Language Scaling WhatsApp and Discord"
>Then this article :
https://favtutor.com/articles/whatsapp-discord-and-the-secret-to-handling-millions-of-concurrent-users/
The historical context of Erlang, its concurrency model, fault tolerance, and distribution capabilities. WhatsApp effectively scaled to over a billion daily active users with a minimal engineering team using Erlang, because it provides high scalability with a tiny footprint and supports hot-loading. Similarly, Discord leveraged Elixir for its chat infrastructure, allowing for efficient real-time communication.
So what's the good thing using Elixir and Erlang VM for this website?
Performance Benefits:
1. Lightning-Fast Response Times : The website now leverages the BEAM (Erlang Virtual Machine), known for its exceptional concurrency handling. Each user connection is managed by a lightweight process (not OS process), allowing thousands of simultaneous connections with minimal resource usage.
2. Fault Tolerance : The Erlang VM's supervisor system ensures that if any part of the application crashes, it's automatically restarted without affecting other parts. This means more uptime and reliability for users.
3. Hot Code Swapping: One of the most powerful features - I can deploy updates without stopping the server. This means zero-downtime deployments!
Practical Impact:
- Page load times reduced by ~40%
- Elixir/Erlang VM is approximately 30% more memory-efficient (flask running on 400 MB (idle state) while Elixir consume about 280 in the same condition)
- Ability to handle 6x (or) more concurrent users
- Improved reliability with 99.99% uptime
Future Benefits:
- Easy scaling for future growth
- Built-in support for distributed systems
- Robust foundation for adding real-time featuråes
- Lower hosting costs due to efficient resource usage
This migration from Flask to Elixir/Phoenix represents a fundamental improvement for better performance, reliability!
*corrention it's 35% more memory-efficient🔥🔥 since it's only consume 260mb ram in idle
good to read too how discord handle the request using elixir and erlang, same as nejiboard do 😎🦹🏼♀️
https://discord.com/blog/how-discord-scaled-elixir-to-5-000-000-concurrent-users
just test using 20k concurrent user using python code, the website can handle good even tho it makes cpu works 100% but the ram still stable at 340mb.
nb : this is artifical request test and simple, the real world challenge could be showing different result
Final Results: Total Requests: 20000 Successful Requests: 19919 Total Bandwidth Received: 339.83 MB Average Bandwidth per Request: 17.47 KB Total Duration: 95.65 seconds Average Speed: 3.55 MB/s root@server039564755:~/py#