Hey all, I recently migrated a bunch of production HTTP traffic to a new server 
written in Nim using [Mummy](https://github.com/guzba/mummy), 
[Ready](https://github.com/guzba/ready), 
[JSONy](https://github.com/treeform/jsony) and 
[Curly](https://github.com/guzba/curly/).

The results have been great so I want to share some concrete details about the 
real-world performance that can be achieved today using nothing but open source 
Nim code to build the server.

The context: The new server is currently handling around 350 requests per 
second constantly. Peaks are about double that. The hardware this server is 
running on is a 2 vCPU + 2GB RAM virtual machine. And it's only using ~10% of 
the CPU and less than 10% of the RAM in `top`. This is not a big VM, and even 
still it is barely noticing the traffic.

The VM is in Google Cloud. I have the VM behind a load balancer which handles 
HTTPS termination. This is a "load balancer" in-name-only since just one VM is 
able to easily handle all the traffic.

This is an API server so it is JSON-in-JSON-out with some Redis and database / 
HTTP RPC calls in the endpoint handlers.

I have had the process running for 48+ hours between deploying updates and the 
memory use has been perfectly stable. This provides evidence I am not 
struggling with memory leaks.

My goal with this post is to share that 1) Nim is being used in production with 
hundreds of thousands of users, and 2) Nim 1.6.10 with `--threads:on --mm:orc` 
\+ Mummy are performing great. For me, Mummy, Ready etc have been proved to be 
reliable for building real services.

So why is this of interest? Well it's pretty rare to hear about the performance 
of real production services. Usually its just benchmarks of artificial 
scenarios which are of murky value.

Because every service is different it is hard to make comparisons, however, 
this post does give you evidence that Nim is capable of thousands of requests 
per second per vCPU. I have every reason to believe a 4, 8, 12, 16+ vCPU VM 
would scale throughput linearly too, all else equal. One machine running a Nim 
server handling 10s of thousands of real-world HTTP requests per second is 
totally possible. Likely much more than that.

Some HTTP performance links as food for thought:

[GitHub processes 2.8 billion API requests per day, peaking at 55k requests per 
second](https://twitter.com/natfriedman/status/1404835709278580739)

[Production Twitter on One Machine? 100Gbps NICs and NVMe are 
fast](https://thume.ca/2023/01/02/one-machine-twitter/)

[How much can you really get out of a 4$ 
VPS?](https://alicegg.tech//2023/02/06/4dollar-vps.html)

Reply via email to