osm icon indicating copy to clipboard operation
osm copied to clipboard

Fix head of line blocking in pubsub

Open steeling opened this issue 3 years ago • 3 comments

With the pubsub used in the message broker, we allow for many publishers and many subscribers. In the current implementation, if a subscriber fails to read from its subscribed channel (or is slow to do so), it blocks publishers from being able to publish. In the worst case, a backed up subscriber can prevent certificates from being rotated, or block updates to proxies.

This can essentially take down a single osm-controller. We can degrade (more) gracefully by instead leveraging an unbounded queue when publishing, prior to reading publishing onto the

While we're at it, we should hide the internals of the pubsub mechanism from the broker's API calls, and simplify using channels. An API may look like:


func (b* Broker) PublishCertEvent(e Event, topics ...string) {
   ...
} 

// Named return params just to show what the unsub func is used for.
func (b* Broker SubscribeCertEvents(topics ...string) (stream ch <- Event, unsub func()) {
   ...
}

This still prevents updates from being published, but at least frees up routines that are doing the publishing. We should look into other mechanisms to further degrade gracefully. Some may include:

  1. Removing/reducing usage of pubsub
  2. Having a policy of no blocking calls on any routine that subscribes to a pubsub topic.
  3. Use an unbounded queue on the subscriber end. If we do this, we may want to further investigate message coalescing.

steeling avatar Jun 23 '22 19:06 steeling

This issue will be closed due to a long period of inactivity. If you would like this issue to remain open then please comment or update.

github-actions[bot] avatar Sep 17 '22 00:09 github-actions[bot]

Issue closed due to inactivity.

github-actions[bot] avatar Sep 24 '22 00:09 github-actions[bot]

Still valid

keithmattix avatar Sep 24 '22 17:09 keithmattix

This issue will be closed due to a long period of inactivity. If you would like this issue to remain open then please comment or update.

github-actions[bot] avatar Nov 25 '22 00:11 github-actions[bot]

Issue closed due to inactivity.

github-actions[bot] avatar Dec 02 '22 00:12 github-actions[bot]