cluster-broccoli icon indicating copy to clipboard operation
cluster-broccoli copied to clipboard

Websocket Publish Subscribe

Open FRosner opened this issue 7 years ago • 0 comments

Problem

Updates in Broccoli (coming from Nomad and Consul, the template or instance) are propagated to all clients with a fixed delay, independent of whether there are actual changes. This leads to a lot of communication overhead.

Solution

Architecture

img_20171122_113546

Instance Service

On every update write change to the instances (e.g. changing parameters, etc.), we notify the websocket service that there is an update of the instances. The websocket service still has a scheduled thread but it will only send new instances in a new batch if it got notified. Notifications can be booleans and the websocket service can just take the current state when updating all clients.

On every update we receive from Nomad or Consul before overwriting the job and service map inside the InstanceService we calculate a collision free hash of the two data structures, seeing if there is a difference. If there is no difference, we don't update them. On each update we notify all subscribers about the update.

Template Service

On every SIGUSR2 being send to the template storage we can notify the websocket service. If it received a notification it will send the new templates on the next sync timeslot.

FRosner avatar Nov 22 '17 10:11 FRosner