Awesome Open Source
Awesome Open Source


Nucleon is a dynamic TCP load balancer written in Rust. It has the ability to insert and remove backend servers on the fly. To do that it leverages Redis Pub/Sub mechanism. Adding or removing a server to a cluster is as easy as publishing a message to Redis.

How to build it

All you need to build it is Rust 1.3.

Just go in the repository and issue:

$ cargo build --release


Nucleon can be used with or without a Redis database. When ran without Redis it is not possible to add or remove load balanced servers without restarting the process.

    nucleon [OPTIONS] [SERVER ...]

Dynamic TCP load balancer

positional arguments:
  server                Servers to load balance

optional arguments:
  -h,--help             show this help message and exit
  -b,--bind BIND        Bind the load balancer to address:port (
  -r,--redis REDIS      URL of Redis database (redis://localhost)
  --no-redis            Disable updates of backend through Redis
  -l,--log LOG          Log level [debug, info, warn, error] (info)

Imagine you have two web servers to load balance, and a local Redis. Run the load balancer with:

nucleon --bind 

Now imagine that you want to scale up your infrastructure by spawning a new web server at Just send a message to the Redis channel backend_add:

redis:6379> PUBLISH backend_add
(integer) 1

Your will see in logs:

INFO - Load balancing server V4(
INFO - Load balancing server V4(
INFO - Now listening on
INFO - Subscribed to Redis channels 'backend_add' and 'backend_remove'
INFO - Added new server

If you decide that you do not need server 2 any longer:

redis:6379> PUBLISH backend_remove
(integer) 1

How does it perform?

Surprisingly well. A quick comparison with HA Proxy in TCP mode with a single backend containing a single server using iperf results in:

Connections HA Proxy Nucleon
1 15.1 Gbits/s 15.7 Gbits/s
10 13.5 Gbits/s 11.3 Gbits/s
100 8.9 Gbits/s 10.5 Gbits/s

Keep in mind that this is a really simple test, far from what real life traffic looks like. A real benchmark should compare short lived connections with long running one, etc.



Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Rust (68,727
Server (65,690
Redis (24,275
Tcp (9,482
Load Balancer (1,576