If you are just about to start on soft realtime project in elixir you might have a lot of questions on how exactly to go about meeting some soft realtime requirement. Elixir is made for this and if one works on “HTTP layer” there are various things to consider that impact latency.

You should always try to think in terms of where request goes and don’t focus on erlang vm much(except tweeking things a bit but that can be done when you really need it).

First thing one would think is how does your request come in? There are many picks for load balancing. Fastest one is that you use kernel itself to loadbalance with some iptables rules. That actually is super fast. Next options are proxies like haproxy thats good and cheap even for userland but still userland. Tiny pinch of performance will suffer but in general we are talking about setting iptables rules for kernel load balancing vs configuring haproxy.

Second elixir servers like cowboy last time I checked were good enough for this type of heavy lifting.

You think there in terms of how much stuff will I have in connection pool? The more the marry but you need to measure not to chocke shedulers otherwise you’ll saturate your servers firepower.

Do I use persistent connections wich are faster than establishing one each time?

Do I spawn something and where does that go or my connection pool invokes handler that is module method directly? If you have handler method your connection pool is what is doing stuff otherwise you have some chain of stuff that takes time.

Then you think if I have to fetch something from database how will that add latency? We all know how this will end up. Mnesia is second to none. In memory you get microsecond latency. On disk on order of few miliseconds(you can have hundreds of gigabytes and more on ssd) If you use redis or aerospike you worry about multithreading vs not multithreading and connection pool to these which needs to be measured and tuned but in general is much slower. Its like ssd perfomance of mnesia. You might also look how to saturate your resources too.

Just to mention that with mnesia saturating resource you use is quite nice, utilisation is quite good.

Anyway you can try to hope now to be as cool as this guy.