In the end all of these values have to be set according to what you are going to run on your Nginx and MySQL servers, so there is no silver bullet formula to answer your question and be correct in every possible use case. Still I tried to pull some data together that can lead you to the answer for your questions:
Nginx
Regarding Nginx worker_processes
the documentation says this:
If Nginx is doing CPU-intensive work such as SSL or gzipping and you have 2 or
more CPUs/cores, then you may set worker_processes to be equal to the number
of CPUs or cores.
If you are serving a lot of static files and the total size of the files is
bigger than the available memory, then you may increase worker_processes to
fully utilize disk bandwidth.
Regarding worker_connections
, consider this formula that I got from here:
max_clients = worker_processes * worker_connections
So after you know your worker_processes
value, you can calculate the worker_connections
based on the maximum number of concurrent clients that you might need to serve.
MySQL
Regarding the max_connections
value on MySQL you should try to figure out how many connections you will need on your MySQL concurrently at peak time. For example if your application runs on PHP and you have 32 PHP worker processes, and PHP is the only application accessing MySQL, it's probably safe to assume that you won't need more than 32 connections on MySQL. You also don't want to set this value too high, because a whole bunch of buffers has to be allocated for each connection, so if the max_connections
value is too high you are taking the risk that something kills your MySQL by creating connections to it until it runs out of memory.
max_user_connections
is basically the same thing, just on a per MySQL user base, instead of a global value for the whole MySQL server.
In case you haven't looked at it already, here are the relevant docs:
max_connections / max_user_connections