<p>So basically I am starting with Kubernetes and wanted to try some things out. At this point I want to deploy a Webserver, a Database, a NodeJs Server and so on... And now, how do I decide how many instances of each of these services I need across my servers?</p>

<p>This is a question with a complex answer depending on your particular application behavior and resource utilization.  Put simply, the "short answer" is going to be: "It depends".  It depends on these main factors:</p>

<ul>
<li>Application Resource Utilization

<ul>
<li>How much RAM, CPU, Disk, sockets,
etc... does your application generally use on: Average?  Max?  Min?</li>
<li>What bottlenecks or resource limits does the application bump into first?</li>
<li>What routines in the application might cause higher than normal utilization?  (This is where a lot of complexity comes in... applications are all different and perform many functions in response to inputs such as client requests.  Not every function has the same behavior w.r.t. resource utilization.)</li>
</ul></li>
<li>High Availability / Failover

<ul>
<li>One of the reasons you chose Kubernetes was probably for the ease of scaling an application and making it highly available with no single point of failure.</li>
<li>This comes down to: How available do you need your application to be?</li>
<li>On the Cluster / Server level: How many nodes can go down or be unhealthy and still maintain enough working nodes to handle requests?</li>
<li>On the Application / Container level: How many <code>Pod</code>s can go down and still handle the requests or intended operation?</li>
<li>What level of service degradation is acceptable?</li>
</ul></li>
<li>How do the separate applications interact &amp; behave together?

<ul>
<li>Another really complicated issue that is hard to determine without observing their behavior together</li>
<li>You can try to do some analysis on metrics like "Requests Per Second" vs. resource utilization &amp; spikes.  However, this can be hard to simplify down to a single number or constant / linear cause / effect relationship.</li>
<li>Do some requests or input cause a "fan out" or amplification of load on sub-components?</li>
<li>For example:

<ul>
<li>Are there some SQL queries that result in higher DB load than others?</li>
<li>Are there some operations that can cause higher resource utilization in <code>Pod</code>s backing other <code>Service</code>s?</li>
<li>How do the systems behave together in a "max load" situation?</li>
</ul></li>
</ul></li>
</ul>

<p>This kind of thing is very hard to answer without doing load testing.  Not many companies I've seen even do this at all!  Sadly enough, any problems like this usually end up happening in production and having to be dealt with after the fact.  It ends up being DevOps, Ops, or the on-call engineers having to deal with it, which isn't the greatest scenario because usually that person does not have full knowledge of the application's code in order to diagnose and introspect it fully.</p>
