How does the gateway decide to which broker it should forward a client request?

Stefan Wiese: Hi, I’m just learning about CamundaCloud. I do understand the concept of brokers and replication of partitions, but how does the gateway decide to which broker it should forward a client request? From my understanding the gateway should know about the elected/configured leaders and forward to them only. Does that happen in a round robin fashion? Or is there another concept/algorithm behind?

menski: Hey Stefan, the leader topology is propagated through the cluster, therefore the gateway can assume which broker is currently leader for a partition. Depending on the client request the gateway either does a round robin distribution, i.e. for create instance requests, activate jobs, or forwards the requests to a specific broker, i.e. complete/fail job, cancel instance, publish message

Stefan Wiese: Ok, but how is this specific broker evaluated then? Does the gatewqy know about job- instance- or message ids?

menski: for jobs and process instances the technical identifier, e.g. process instance key, contains the partition id, therefore the gateway can decode the partition id and reach the correct broker.

For publish message commands the gateway calculate a hash of the correlation key to identify the correct partition to send the message to and in the same way the workflow engine does calculate the hash of the correlation key of messages it awaits find the right partition to correlate the message on.

Stefan Wiese: Thank you very much for this nice explanation. I think it’d be worth to be added to the official docs. The gateway section is quite small, just two lines…

menski: that is probably a good idea, feel free to open an github issue for this request https://github.com/camunda-cloud/camunda-cloud-documentation/issues

Stefan Wiese: https://github.com/camunda-cloud/camunda-cloud-documentation/issues/560

Note: This post was generated by Slack Archivist from a conversation in the Zeebe Slack, a source of valuable discussions on Zeebe (get an invite). Someone in the Slack thought this was worth sharing!

If this post answered a question for you, hit the Like button - we use that to assess which posts to put into docs.