<p>I have been looking into Docker containerization for a while now but few things are still confusing to me. I understand that all the containers are grouped into a cluster and cluster management tools like Docker Swarm, DC/OS, Kubernetes or Rancher can be used to manage docker containers. I have been testing out Container cluster management with DC/OS and Kubernetes, but still a few questions remain unanswered to me.</p>

<p><strong>How does auto scaling in container level help us in production servers?</strong> How does the application serve traffic from multiple containers? </p>

<p>Suppose we have deployed a web application using containers and they have auto scaled. How does the traffic flow to the containers? How are the sessions managed?</p>

<p>What metrics are calculated for autoscaling containers?</p>

<p>Kubernetes has concept called <code>service</code>. A Kubernetes Service is an abstraction which defines a logical set of Pods and a policy by which to access them. Kubernetes uses services to serve traffic from multiple containers. You can read more about services <a href="http://kubernetes.io/docs/user-guide/services/#virtual-ips-and-service-proxies" rel="nofollow">here</a>.</p>

<p>AFAIK, Sessions are managed outside kubernetes, but Client-IP based session affinity can be selected by setting service.spec.sessionAffinity to "ClientIP". You can read more about Service and session affinity <a href="http://nishadikirielle.blogspot.in/2016/03/load-balancing-kubernetes-services-and.html" rel="nofollow">here</a></p>

<p>Multiple metrics like cpu and memory can be used for autoscaling containers. There is a good <a href="http://blog.kubernetes.io/2016/07/autoscaling-in-kubernetes.html" rel="nofollow">blog</a> you can read about autoscaling, when and how.</p>
