How would I guarantee a multi-instance service receives an event exactly once?

8/24/2021

I am building an application which deals with a great deal of pub/sub use, commands from the client, status updates from the service X. This application I am building is running on kubernetes so it is obviously multi-instance. I want to create some sort of middleware service which will basically listen to all updates from all tasks in the service X and process them without interfering, just a silent observer, since that middleman will be multi-instance as well I want to guarantee that only one of these instances will process an update, so for example if service X sends an update for Task Y, then just one instance from the middleware will be busy with that status update. With my current implementation using redis I find that impossible as there is no way to reliably let the other subscribers know that you have read a message. What would you propose I use? Is there in fact a way to do it with redis? Would redis streams be a better candidate compared to pub/sub?

Please help!

-- Andrew Giannoulis
kubernetes
microservices
publish-subscribe
redis

0 Answers