In my solution I used a simple round robin implementation to choose between the two servers. I separated the balancer module from the frequency to make the implementation cleaner. I've also moved allocated/0
and deallocated/1
to this module since they are the interfaces.
Suppose that the frequency server needs to serve more frequencies. It would be possible to do this just by having a longer list of frequencies available, but it is likely that this scaling is required not only because more frequencies are needed but also because there are more requests to allocate and de-allocate them.
Sharding the handling of frequencies