lila is a tiny (1kb) load balancer, fully end-to-end tested.
Node.js (>= 0.9.7) is the only prerequisite.
npm install -g lila-lb
yarn global add lila-lb
brew install simonewebdesign/tap/lila
Manual installation (Windows, Linux, macOS)
Run this command on a Bash shell to download the latest lila on the current directory and make it executable:
curl https://raw.githubusercontent.com/simonewebdesign/lila/master/lila > lila && chmod +x lila
Optional: if you want to use lila without knowing its location, make sure to add the folder where you've downloaded it on the
$PATH environment variable.
lila <mode> server1 server2 ... serverX
lila round-robin localhost:1337 example.com:80 127.0.0.1:7777
- Round Robin – Requests are distributed across the group of servers sequentially.
- Least Connections – A new request is sent to the server with the fewest current connections to clients.
- The mode needs to be passed as a shell argument, e.g.
- The servers have to be provided in the format
example.com:80. The protocol shouldn't be specified.
- On a HTTP server, lila will respect the Keep-Alive timeout by reusing the same socket, unless the client ends the connection.
lila is fast. Whilst there are several factors to consider when measuring the performance of a load balancer, such as network latency, workload, and what platform it's running on, quick benchmarking showed promising results.
My setup is a MacBook Pro 2.3 GHz Intel Core i7, 16 GB DDR3.
ApacheBench didn't provide consistent results: sometimes it would fail to complete due to an
apr_pollset_poll error, or cause a few
EPIPE socket errors. Also note it doesn't use HTTP's KeepAlive feature by default. However, it still yielded a satisfying result of 1582 requests/sec:
$ ab -c 7 -t 5 -k -s 2 http://localhost:4444/ Concurrency Level: 7 Time taken for tests: 5.000 seconds Complete requests: 7913 Failed requests: 0 Keep-Alive requests: 0 Total transferred: 633200 bytes HTML transferred: 39575 bytes Requests per second: 1582.48 [#/sec] (mean) Time per request: 4.423 [ms] (mean) Time per request: 0.632 [ms] (mean, across all concurrent requests) Transfer rate: 123.66 [Kbytes/sec] received
'Hey' provided much better results, yielding 22877 requests/sec (by reusing TCP connections between different HTTP requests):
$ hey -c 7 -z 5s http://localhost:4444/ Summary: Total: 5.0003 secs Slowest: 0.0067 secs Fastest: 0.0001 secs Average: 0.0003 secs Requests/sec: 22877.0034 Total data: 571965 bytes Size/request: 5 bytes Status code distribution:  114393 responses