7 years after: Is OCaml suitable to write networking servers?

I’m pretty convinced that the belief that shared memory parallelism matters for servers is a huge fallacy. If you need to really scale, you will exceed the capacity of a single server at some point, and if you do so, you need a load balancer. You might as well start by using a load balancer and multiple processes. Sure, there are cases where it really matters (see Hack’s typechecker) but they are not nearly as common as people make them.

As for video games … either you have lot’s of small instances (individual matches) and you can keep your state on one thread, or you have ReallyBigInstances (MMOs) and you can’t assume one server is enough at all. Most MMOs actually use instances to avoid being in the second situation completely.

While we are on the amusing exercise of pulling examples out of our asses, I also have one: Did you know that Eve Online’s engine (the MMO that regularly make headlines for ridiculous large battles with thousands of players) is completely single threaded? Each solar system can only run in one process. All the magic is in the load balancing, to ensure that systems with high load have one process only for themselves. There are multiple devblogs on the topic.

Maybe other languages are better, maybe they aren’t. OCaml-multicore will be certainly be useful when we got it. But the argument that shared memory is essential for web and game servers still sounds like commonly-propagated nonsense.

10 Likes