So, I frequently need to have servers within a clu...
# http4k
a
So, I frequently need to have servers within a cluster talk to each other. For example, a cluster that holds websockets, and exposes a control API. Rather than have clients of the control API figure out which server is holding the websocket, I want them to use the load balancer. But to make that work, any server in the cluster that gets the request needs to be able to figure out which server holds the websocket, and then find a way to send the command to it. In the past, I've been able to take advantage of the fact that each server is running on an instance, with an accessible private IP: • Use the aws load balancing API to get the private IPs of each server in the target group • each server publishes their active websockets to a table, including their private IP • each server publishes their private IPs to a table, and you poll them for the websocket But I now have a similar service that's running in ECS/K8s, and there's no (easy) way to access each server individually. • I can't use AWS SQS, because there's no way for servers to subscribe to just the messages intended for them (and no way to send messages to all servers) • I don't really want to use AWS SNS, because each server would have to dynamically create/subscribe/unsubscribe an SQS queue for themselves • MQTT is annoying to set up, and I don't have an incredibly robust fake for it yet So, I thought about using redis as a message broker. But realized I not only wanted to send the commands, but ensure they're processed correctly. So I came up with the idea for Http4k over Redis! This will let you map commands and acknowledgements to the http4k workflow we're all accustomed to. It seems to work in my tests, but I have no idea if it will stand up to production use. Will try to integrate on Monday. Thoughts are welcome. https://github.com/oharaandrew314/http4k-over-redis
http4k 2