Round robin a list from Phoenix app

How high is your throughput and how exact does your round robin need to be?

If you just want more or less the same traffic to each IP, the easiest way would be to randomly select one each time. This would, on average, give the same amount of traffic to each IP and not require any coordination between processes.

If you really need true round robin, a GenServer that simply returns the next IP would be able to handle a pretty huge number of requests. It’s true they’d be serialized, but you wouldn’t run into issues until you had some pretty serious traffic on it.

What are you doing once you get an IP? If you’d benefit from having a persistent connection to each IP that you re-use, poolboy could handle giving you the next available connection.

1 Like