dnldd
dnldd

Reputation: 113

load balancing cowboy http servers

how do you load balance identical cowboy http servers in the same cluster considering they have the identical listeners listening to the same port for requests? I don't think the usual round-robin approach for load balancing will work in this scenario since the listeners for each server are always active when the server starts. What am I missing here?

Upvotes: 2

Views: 981

Answers (1)

lastcanal
lastcanal

Reputation: 2175

I think what your missing is that Cowboy doesn't register it's listeners globally across the cluster, it only registers them locally. Requests that are sent to node1 are processed with handlers running on node1. Cowboy does not automatically form a cluster of servers across each of your connected nodes. A Cowboy server will need to be started on each of your nodes and they will operate independently of each other.

The best way to manage load balancing is to use a reverse proxy, such as Nginx, and have it redirect requests across your cluster.

If you need 'sticky sessions' that route requests to globally registered processes, then you should do a lookup (using global:whereis_name/1) from within the Cowboy handler and route the message across your cluster from there.

Upvotes: 1

Related Questions