Limit maximum of replication
Hello,
is it possible to make an implemetation have a maximum number of replications?
I'm thinking of the use case of an element of my application that uses resources that are themselves limited
Use case:
- a database with a maximum number of connections
- a cache with a writer and several readers
Hi @kedric! Right now, we have no official support for specifying the maximum number of replicas of a component. If you use the weaver kube deployer, however, you can edit the generated Kubernetes YAML files to specify a maximum number of replicas. This is definitely something we might add in the future, so I'll leave the issue open.
I think guaranteeing a maximum number of replicas might be tricky. For example, if you currently have $n$ replicas, where $n$ is the max, and you lose contact to one of the replicas, do you start a new replica? I don't think you can without possible having $n+1$ replicas. But we might be able to enforce a maximum replica limit on a best effort basis.
Hi @mwhittaker,
If I lose contact with a replica, I think it should be considered obsolete. if the replica was in demand, I'll have to start a new one. After that, it's up to me to decide whether to keep a resource margin for myself, so that I can have a period of time when I'm likely to use more resources.
But this means that for a writer/reader case, it's a tricky situation.
Is there any way of making a leader election system for the second case with what exists?
If I lose contact with a replica, I think it should be considered obsolete. if the replica was in demand, I'll have to start a new one. After that, it's up to me to decide whether to keep a resource margin for myself, so that I can have a period of time when I'm likely to use more resources.
Makes sense! If we implement a limit on the number of replicas on a best effort basis, it should be fine to use for performance reasons.
But this means that for a writer/reader case, it's a tricky situation.
Yup, I don't think you should rely on a maximum number of replicas for correctness.
Is there any way of making a leader election system for the second case with what exists?
Because this would be very complicated, I don't think we have any short term plans to implement it in Service Weaver. If you need something like this, I recommend using an existing system like ZooKeeper in conjunction with Service Weaver.
Hi @mwhittaker,
Thank you for this information, I'll see how I can do.
@kedric, this is somewhat orthogonal, but you can specify the max number of replicas if you use the GKE deployer.