<p>There are applications and services in enterprises that do not need to run all the time and that have a limited user base (say a handful of people). </p>

<p>These applications can be shut down and started either based on scheduling or even better user activity. So, we are talking about on-demand service (say wrapped by a container) and node start-up and shut down. </p>

<p>Now, first to mention that the reason why I mention authenticated user activity is because is makes sense to startup and shutdown on that basis (i.e. not based on lower level network traffic). One can imagine corporate SSO (say OAuth 2 based) being involved.</p>

<p>So, my question is whether anyone has attempted to implement what I have described using Consul or Kubernetes?   </p>

<p>In the case of Consul, it could be that the key-value store could be used to give "Micro" (i.e. small user base) class applications a TTL, each time an authenticated user requests access to a given "Micro" class application it's TTL is updated. During the TTL window we want to check the health of the node(s), containers and services - outside of the window we don't (since we want to save on op ex).</p>

<p>This question is similar to <a href="https://stackoverflow.com/questions/33556707/dynamic-scalable-and-adaptive-architecture">this autoscaling question</a>, however different in the sense that this use case is about scaling from 0 nodes and then down to 0 based on an authenticated user base (most likely using SSO).</p>

<p>In the case of <a href="http://kubernetes.io" rel="nofollow">Kubernetes</a>, the <a href="http://kubernetes.io/v1.1/docs/design/horizontal-pod-autoscaler.html#autoscaling-algorithm" rel="nofollow">Horizontal Pod Autoscaling documentation</a> lists the exact use case described under <strong><em>Next steps</em></strong> (i.e. the feature is on the backlog and may be implemented after v1.1. of Kubernetes). The cited feature description (<a href="https://github.com/kubernetes/kubernetes/pull/3247" rel="nofollow">Unidling proposal</a>) is as follows:</p>

<p><em>Scale the number of pods starting from 0. All pods can be turned-off, and then turned-on when there is a demand for them. When a request to service with no pods arrives, kube-proxy will generate an event for autoscaler to create a new pod.</em></p>

<p>So basically, it may be possible to do what I've described in future using Kubernetes, but it is not possible right now. This in itself does not address the requirement to only scale from 0 based on authenticated user activity.</p>

<p>It's worth noting, as a cluster-agnostic aside, <a href="https://developer.atlassian.com/blog/2015/03/docker-systemd-socket-activation/" rel="nofollow">on-demand container activation based on systemd</a>. This solution will of course not scale back down to 0 without a controlling process, but it's still worth noting.</p>
