Skip to content
This repository was archived by the owner on Jul 22, 2022. It is now read-only.
This repository was archived by the owner on Jul 22, 2022. It is now read-only.

[feature request] multiple metacontroller with object sharding strategy  #190

Description

@hypergig

moving the slack discussion over to here to continue in a more formal manner

Obligatory

Metacontroller is freaking great, thank you for enabling us to build custom controllers in a matter of days.

The Problem

As our cluster grows in scale, we are noticing metacontroller isn't able to keep up during large volume and/or volatile events such as a major deployment, or new cluster provision. Metacontroller is responsible for about 2500 objects at this point, and the time it takes for all the "update loop"s to resolve could be about 20-30 mins. This is especially problematic for parents whose children may be conditional on the state of other children and/or objects. As these would require at least two "update loops". Metacontoller and the webhooks are in no way resource constrained, never going above 200m, and memory usage is negligible.

The A Solution

Clearly we don't want to break metacontroller's simple interactions with the cluster and users. Cluster scoped controller objects, and backwards compatible are really important. In essence, there is a cluster scoped pool of work, and the idea is to safely parallelize the processing of that pool across an arbitrary number of workers. Keeping that in mind, I propose the following:

  • Allow for multiple replicas of metacontoller, each with their own shard of the worker pool
  • All metacontroller's register watches on all controller parents/children, as they do now
  • ...but only process objects in their designated shard
  • Sharding algorithm would be just a simple math function:

update object if metaconroller statefulset host number == object uid % number of metacontroller replicas

  • This would still work as metacontroller scales up and down, and would be compatible with an hpa (I believe, though I never created an hpa for a statefulset before)
  • Metacontroller can look up the number replicas by watching it's parent statefulset status

Challenges

  • Need to be careful that two metacontrollers don't attempt to update the same object, this should be mathematically impossible however, latency on the api could cause moments when the exact replica count may be inaccurate
  • Metacontoller needs health and ready probes and should never start processing its object shard unless it is reported as ready
  • Though the processing of objects would scale, it is impossible to shard watches and thus, every metacontroller would still watch for everything. This should have no material effect on the k8s api, but it is worth mentioning.

Other nice side effects

  • Multiple replicas means we can improve our HA posture by spreading out our metacontrollers with anti-affinity rules
  • Auto scaling is now possible, tuning would be just like any other service in the cluster
  • It would be possible to preemptively scale up metaconroller before high volume / volatility events

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions