Singleton Service Pattern

Running one – and only one – instance is a requirement for applications, since multiple instances could create instability. Although it seems to be against the scalable microservice architecture, there are some applications that are required to follow the singleton pattern:

  • Database instances and connectors
  • Configuration managers
  • Applications that do not scale yet

Kubernetes StatefulSet with a replica count of 1 ensures that only instances of the pod are running in the cluster. With this small configuration, singleton services can be created and used in a cloud-native environment. However, having only one instance of an application in the cluster comes with its drawbacks. For instance, handling the downtime of singleton applications should be handled with care. The primary concern for this issue is how to handle downtime due to the automatic
update of Statefulset. There are two possible solutions in Kubernetes:

  • Tolerate occasional downtime during updates
  • Set PodDistruptionBudget with minAvailable=1:
    • Eliminate the automatic update since PodDistruptionBudget is set
    • Prepare for disruption by operational steps
    • Delete the PodDistruptionBudget resource and let the update continue
    • Recreate PodDistruptionBudget for the next disruption
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.61.170