RE2 Programming

How is Discord is using Elixir?

What is Discord?
Discord is the most convenient way to communicate via audio, video, and text. It helps to keep in touch with your friends and communities by talking, chatting, and hanging out.
Discord is a platform for voice over IP, instant messaging, and digital distribution. Voice calls, video calls, text messaging, media, and files are used by users to interact in private chats or as part of “servers.” Servers are a collection of live chat rooms and voice chat channels that are available at all times.webstoc
Discord is using Elixir
When does Elixir come to picture?
Discord has been an early adopter of Elixir from its inception. The Erlang Virtual Machine was the ideal platform for the highly parallel, real-time system Discord wanted to construct. They built the first Discord prototype in Elixir, which is now the core of their infrastructure. The promise of Elixir was simple: gain access to the Erlang VM’s capability via a far more current and user-friendly language and toolset.
Currently, the system supports approximately five million concurrent users and millions of events every second.

How is Discord is using Elixir???

While Discord has a lot of features, the most of them comes down to pub/sub. Users connect to a WebSocket and launch a session process (a GenServer), which communicates with Erlang nodes executing guild (internal for “Discord Server”) processes located at a distance (also GenServers). When something is posted in a guild, it is broadcast to all of the sessions that are connected to it. When a user connects to a guild, the guild broadcasts their existence to all other linked sessions. This was a great strategy when we first started building Discord for gatherings of 25 or less.
Discord has utilized Elixir as the backbone of its chat system since the beginning. Discord was still trying to create a sustainable company when they first embraced the language, and they had a lot of questions and problems ahead of them. Elixir was essential in providing them with the technological flexibility they needed to expand their business, as well as serving as the foundation for their systems to function on a large scale.
“In terms of real-time communication, the Erlang VM is the ideal tool for the job,” Jake Heinz explained when Discord team was asked why they chose Elixir. “It’s a very flexible runtime for developing distributed systems, with great tools and reasoning.”, he added. The language was a natural fit in terms of technology.
Infrastructure of Chat:
Discord uses a cluster of 400-500 Elixir computers to power its chat messaging platforms. The fact that Discord’s chat infrastructure team consists of five engineers is maybe the most remarkable achievement. That’s right: five developers are in charge of 20+ Elixir services that can handle millions of simultaneous users and push dozens of millions of messages per second. Elixir also acts as the control plane for Discord’s audio and video services, or signaling, which allows users to interact with one another. C++ is then in charge of media streaming, which is handled by a mix of 1000+ nodes.
Discord learnt how to use the Erlang VM’s strength, its community, and when to recognize difficulties that need them to find their own solutions in order to function at this size.
Other times, the company’s and community’s activities are complementary. That was the case when Discord scaled to 11 million concurrent users using the Rustler project, which offers a secure bridge between Elixir and Rust. They utilized the Rustler to connect their Elixir services to a bespoke data structure written in Rust.
So, what are you waiting for? Pack up your bags and go ahead and grab onto the amazing offer on Elixir courses given by RE2 Programming. Learn from the best instructors and get all your queries resolved in the live classes.
Visit RE2 Programming today and enroll yourself to learn and get ahead of the world.

– Suparil K Bhatt