Load Balancer

Load Balancer

Allows to distribute incoming requests to multiple nodes, either by using a reverse proxy or by redirecting the client.

var workers = LoadBalancer.Create()
    var cdn = LoadBalancer.Create()
    var app = Layout.Create()
                    .Add("api", workers)
                    .Add("content", cdn);

If needed, the incoming request can get analyzed to determine the nodes with the highest priority that should handle the request (e.g. to prefer nodes near to the requesting client).

LoadBalancer.Create().Proxy(..., (r) => Priority.High);

Additionally, the builder accepts any IHandler instance as a node, allowing to extend the functionality where needed. For example, the following snippet would distribute the load to two different, local drives.