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?
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:
Pod
s can go down and still handle the requests or intended operation?Pod
s backing other Service
s?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.
If you are using kubernetes anyway then use the :
horizontal pod autoscaler for stateless components such as webservers
horizontal pod autoscaler for app servers
a stateful set or operator for DB compoenets ( estimate the initial size of cluster and manually grow later )
And its all done.
Things will auto grow and shrink according to the load.
Note: use the answer by @Trin as guideline how to configure the autoscalers and autoscaling criteria. There is a list of metrics exposed by kubernetes metrics system that you can use for auto scaling.