I have a Linux C application that makes use of the services of a MariaDB 10.0.34 server, also running under Linux. The application launches individual threads to do operations against the MariaDB server. My setup is the following:
1. Using the MariaDB C API, each thread opens a separate connection to the server, carries out its operations, and then closes the connection when done.
2. Each thread operates on the same database and on the same table.
3. There are no thread locks in the code run by the threads - the MariaDB server is assumed to manage the simultaneous connections.
4. The probability for each thread to be operating on the same element in table at the same time is negligible.
5. The application and the MariaDB server run in the same system.
6. The system where this is all running is a multicore one.
The problem that I am facing is that the performance of this setup is very poor. The application (which is driven by external events the nature of which is not relevant to this discussion) launches its threads to interact with the MariaDB server. These threads seem to be running sequentially, rather than taking advantage of the many cores available in the system. In essence, the threads keep accumulating, because they seem to be created faster than they can complete. While each thread, while running on its own, should terminate in a matter of a few seconds, once they start accumulating each may make take many minutes to complete - they seem to be competing with each other for the MariaDB server's resources: there doesn't seem to be any parallelism involved, despite the fact that the system has plenty of resources for the job.
I would like to make sure that my MariaDB server is configured adequately for the scenario I described above - which it is probably not, for I am a newbie to MariaDB. my /etc/my.cnf file includes all the files under /etc/my.cnf.d. One of them is named server.cnf, and it includes the following lines:
[mariadb]
thread_handling=pool-of-threads
That's pretty much it, as far as my MariaDB server configuration is concerned.
What I am asking for is feedback concerning how to configure my MariaDB server to address my scenario. The system is by no means stressed - when running, with tens of threads executing simultaneously, the system load never reaches 2.0, and most of the 16 cores available are idle most of the time.