You have dug around lots and uncovered many prospective parameters at play -
This here Performance issue with v10 pos notes MySQL analysis tools documented here:
https://dev.mysql.com/doc/refman/8.0/en/show-processlist.html
https://dev.mysql.com/doc/refman/8.0/en/sys-processlist.html
https://dev.mysql.com/doc/refman/8.0/en/thread-information.html
https://dev.mysql.com/doc/refman/8.0/en/threads-table.html
They may help learn precisely what query or queries are spending their time that may point you to the holdup?
frappe@ubuntu:~/frappe-bench$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 348420
Server version: 10.2.13-MariaDB-10.2.13+maria~xenial-log mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SELECT * FROM performance_schema.threads\G
Empty set (0.08 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| 1bd3e0294da19198 |
| d56cb677eaab3383 |
| information_schema |
| mysql |
| performance_schema |
+--------------------+
5 rows in set (0.03 sec)
MariaDB [mysql]> use 1bd3e0294da19198;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [1bd3e0294da19198]> SELECT * FROM performance_schema.threads\G
Empty set (0.00 sec)
MariaDB [1bd3e0294da19198]> show processlist;
+--------+-------------+-----------+------------------+---------+------+--------------------------+------------------+----------+
| Id | User | Host | db | Command | Time | State | Info | Progress |
+--------+-------------+-----------+------------------+---------+------+--------------------------+------------------+----------+
| 1 | system user | | NULL | Daemon | NULL | InnoDB purge coordinator | NULL | 0.000 |
| 3 | system user | | NULL | Daemon | NULL | InnoDB purge worker | NULL | 0.000 |
| 2 | system user | | NULL | Daemon | NULL | InnoDB purge worker | NULL | 0.000 |
| 4 | system user | | NULL | Daemon | NULL | InnoDB purge worker | NULL | 0.000 |
| 5 | system user | | NULL | Daemon | NULL | InnoDB shutdown handler | NULL | 0.000 |
| 348420 | root | localhost | 1bd3e0294da19198 | Query | 0 | init | show processlist | 0.000 |
+--------+-------------+-----------+------------------+---------+------+--------------------------+------------------+----------+
6 rows in set (0.04 sec)
MariaDB [1bd3e0294da19198]> SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+--------+-------------+-----------+------------------+---------+------+--------------------------+----------------------------------------------+---------+-------+-----------+----------+-------------+---------------+----------+----------------------------------------------+------+
| ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO | TIME_MS | STAGE | MAX_STAGE | PROGRESS | MEMORY_USED | EXAMINED_ROWS | QUERY_ID | INFO_BINARY | TID |
+--------+-------------+-----------+------------------+---------+------+--------------------------+----------------------------------------------+---------+-------+-----------+----------+-------------+---------------+----------+----------------------------------------------+------+
| 348420 | root | localhost | 1bd3e0294da19198 | Query | 0 | Filling schema table | SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST | 9.992 | 0 | 0 | 0.000 | 85296 | 0 | 3039715 | SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST | 2725 |
| 5 | system user | | NULL | Daemon | 0 | InnoDB shutdown handler | NULL | 0.000 | 0 | 0 | 0.000 | 24360 | 0 | 0 | NULL | 2543 |
| 4 | system user | | NULL | Daemon | 0 | InnoDB purge worker | NULL | 0.000 | 0 | 0 | 0.000 | 24360 | 0 | 0 | NULL | 2539 |
| 2 | system user | | NULL | Daemon | 0 | InnoDB purge worker | NULL | 0.000 | 0 | 0 | 0.000 | 24360 | 0 | 0 | NULL | 2537 |
| 3 | system user | | NULL | Daemon | 0 | InnoDB purge worker | NULL | 0.000 | 0 | 0 | 0.000 | 24360 | 0 | 0 | NULL | 2538 |
| 1 | system user | | NULL | Daemon | 0 | InnoDB purge coordinator | NULL | 0.000 | 0 | 0 | 0.000 | 24360 | 0 | 0 | NULL | 2536 |
+--------+-------------+-----------+------------------+---------+------+--------------------------+----------------------------------------------+---------+-------+-----------+----------+-------------+---------------+----------+----------------------------------------------+------+
6 rows in set (0.02 sec)
This Slow Query Log utility may shed light on the problem https://mariadb.com/kb/en/library/slow-query-log-overview/
Just one of your 8x gunicorn workers does the work, presumably that is all that is required to respond to the front end HTTP requests and other housekeeping tasks.