Managing Two Million Web Servers - Joe Armstrong
So this is about web-servers written in Erlang and Elixir. Time and again I’ve heard this said:
We have a (Erlang or Elixir) web server managing 2 million user sessions.
But this statement is incorrect and stems from a fundamental misconception.
We do not have ONE web-server handling 2 millions sessions. We have 2 million webservers handling one session each.
The reason people think we have one webserver handling a couple of million users is because this is the way it works in a sequential web server. A server like Apache is actually a single webserver that handles a few million connections.
In Erlang we create very lightweight processes, one per connection and within that process spin up a web server. So we might end up with a few million web-servers with one user each.
If we can accept say 20K requests/second - this is equivalent to saying we can create 20K webservers/second.
On the surface things look very similar. But there is a fundamental difference between having one webserver handling two million connections, and two million web servers handling one connection each.
If there is a software error and the server software crashes we lose either two million connections or one depending upon the model.
In Erlang if the web server software itself is incorrect we’ll lose a single connection, which is OK. Since the software is incorrect and crashes we don’t know what to do so crashing is a good alternative. What is important is that one session crashing does not effect all the other sessions.
This requirement, goes way back to when we designed Erlang in the mid 1980’s. In Telecoms systems, losing one connection due to a software error was acceptable, losing them all due to a bug was big time bad news.