Skip to content
This repository has been archived by the owner on Nov 18, 2019. It is now read-only.

Need a concept for leader election to allow multiple instances of controller components to run in parallel #38

Open
wrichter opened this issue Apr 30, 2019 · 1 comment

Comments

@wrichter
Copy link
Contributor

This is usually done via some data store, i.e. there's concepts to perform leader election using MongoDB, Zookeeper or etcd. Each choice introduces new technical dependencies, maybe there's a concept for leader election using messaging?

@DanielFroehlich
Copy link
Collaborator

Generally, I would try to avoid to implement that low level stuff our self, but delegate to something like mongo, Kafka or so.
Also, I would like to avoid the need for that as much as possible.
If we have an async event style communication with idempotency of event processing (which is must have for event driven architectures), most of the writing events should be handled correctly.

For example, we wouldnt need a "playlist-controler" at all if the spotify-backend creates a "music stopped" event, where the playlist-component subscribes to.

Heads Up - leaving now the "general event driven architecture disussion field" and hoping into OPenDJ Details:

the tricky part is the spotify-backend with multiple instances, executing calls to spotify. maybe we could delegate the whole problem to spotify . multiple "start playing" calls to spotify in parallel are a "last save wins" strategy which might be fine. Or bad because of interruptions of the music, or API rate limits.

If really really not avoidable, I would think about events like "I am the leader" firing in 100ms intervals. if an instance receives these events, it remains passive. If it is missing these events for more then 250ms sec, it starts firing events and considers itself to be a leader.
We dont need 100% consistency here, if in case of a container loss exactly during the transition to a next song there is a small hickup (e.g. the song starting twice), that is acceptable.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants