What factors determine the maximum possible number of threads mysqld will create?
I only care about consideration for mysql and not limitations that may be imposed by the operating system. Further, I only care about Linux, though if you want to include information specific to Windows, feel free.
As far as I can tell, threads can be created for replication, aspects of innodb, one per client connection up to max_connections, with an additional +1 to handle super connections. What else is there, or is that it?
threads_max = max_connections
+ 1 for super
+ 2 for replication slave threads
+ ? for InnoDB ?
Best Answer
On Linux for example, whichever is smaller among:
and:
UPDATE: As you correctly pointed out, we should add at least the background threads to the list. More information below.
As far as your last update is concerned, for InnoDB we have innodb_read_io_threads and innodb_write_io_threads.
I've just checked and a MySQL 5.5.34 on debian with default values we have:
And the OS sees:
After connecting as root, the thread count remained the same (the thread count increased when I made another one tough):
So, as I said, this could be version specific, but we seem to have:
So, if you need to do some kind of capacity planning, I would suggest to check the number of background threads after the startup without user/app connection and add to that: