r/SoftwareEngineering • u/Historical_Ad4384 • May 26 '25
Which communication protocol would be better in manager-worker pattern?
Hi,
We are trying to implement the manager-worker (similar to master-slave but no promotion) architecture pattern to distribute work from the manager into various workers where the master and workers are all on different machines.
While the solution fits our use case well, we have hit a political road block within the team when trying to decide the communication protocol that we wish to have between the manager and workers.
Some are advocating for HTTP polls to get notified when the worker is finished due to the relative simplicity of HTTP request-response model while doing away with extra infrastructure at the expense of wasted compute and network resources on the manager.
Others are advocating towards a message broker for seamless communication that does not waste compute and network resources of the manager at the expense of an additional infrastructure.
The only constraint for us is that the workers should complete their work within 23 hours or fail. The manager can end up distributing to 600 workers at the maximum.
What would be a better choice of communication ?
Any help or advice is appreciated
10
u/dacydergoth May 26 '25
Message broker. 100% especially for long running workers
3
u/cashewbiscuit May 26 '25
There seems to be reinventing of wheels going on here. Which platform are you running your code?
4
u/Momus_The_Engineer May 26 '25
I have implemented things like this over: raw sockets, dds, gRPC, Kafka, hazelcast and zeroMQ… just to name a few that I can think of.
What are the rest of your requirements? Latency? Bandwidth? Security? Client languages? Target architectures? Message size? Observably? Audit? Extensibility? Do all clients always exist? Or can they join ad-hoc?
I think you need to ask and answer some/more of the questions above then look into your options for a best fit.
2
u/cuboidofficial May 26 '25
Why use polls when SSEs are a thing?
2
u/ergnui34tj8934t0 May 26 '25
it sounds painful to build a multi team representation of the elixir/erlang BEAM VM.
16
u/Radiant_Equivalent81 May 26 '25
Trick question, the actual answer is fire the PM for only bringing this up with a day left
4
u/[deleted] Jun 02 '25
The only protocol you mentioned was HTTP, so Im going to assume that you’re leaning towards that one.
Message broker is a pattern more than a protocol. You can implement a message broker using HTTP or a shared database or Redis or RabbitMQ or or or or. I recommend checking out the MassTransit library and notice all the different transports it supports.
At the end of the day, don’t micromanage. Trusting the metaphor, a polling solution does just that.
The main downside of using a pure broker is introducing an additional layer or complexity to the applications. The benefits may offset the risks, but if you aren’t already proficient in the pattern or a specific technology (Redis, RabbitMQ, Masstransit, etc) then it may not be the best idea to introduce it into your architecture at this time.
Given that, opt for a webhook/postback architecture which can be implemented very easily over any protocol especially HTTP. Fundamentally workers to signal their status/completion rather than the manager demanding updates. You can even include an optional interface for the manager to ping a worker, get its status, or perform some other operation like cancelling it.
2
u/nandanavijayakumar Sep 03 '25
In a manager–worker pattern, message-based communication is generally better since it allows asynchronous, scalable, and reliable task distribution.
1
u/angriest_man_alive May 26 '25
Its a shame that this is far too funny and accurate for the humor sub