March 04, 2016

Sorting Server IPs By a Property in the Hash

Problem described here is an inherited design and doesn’t reflect my engineering opinion. I just had to make it work in given ecosystem.

Problem:

Given a list of hardware servers we need to pull the least busy one from the pool.

Pool in our case is a sorted set of worker ips which is sorted by CPU load in descending order (least busy first). Thus queuer can just take first worker ip in the array and know that’s the least busiest worker.

Infrastructure:

We need a Redis DB running and be accessible by other servers to update information about themselves.

Will use a Redis Set to store our server ips. And Redis Hashes to store CPU utilization and some other info about the server.