Troubleshoot Database Performance
The following provides information for troubleshooting database performance issues. To view general troubleshooting tips and search for troubleshooting topics, see EJBCA Troubleshooting.
Before starting any database performance troubleshooting, ensure that you have (at least) the recommended database indexes applied. See doc/sql-scripts for recommended indexes.
Enable Performance Statistics in WildFly
To troubleshoot database performance in WildFly, follow the steps below.
The following instructions have been tested with WildFly 14.
- Run the following command to list available data sources.CODE
ejbcads
, but it can be different on your system. - Run the following commands to enable performance and SQL logging in Hibernate.
Replace the datasource
ejbcads
with the name of the datasource you noted down in the previous step.CODE Run the following commands to enable debugging of EJBCA and CeSeCore.
CODERestart WildFly.
CODELoad EJBCA in the browser and tail the log file.
CODE- It may be good to know the load times reported by the browser for reference. Assuming Chromium is used, you can see how much time it takes to load different resources by pressing Ctrl+Shift+I and opening the Network tab as shown in the screenshot below.
Perform some operation known to be slow and capture the output from the log. For example, loading the audit log page would give an output similar to the following:
TEXTYou can also use the ping utility in Linux to measure the RTT between the EJBCA machine and the DBMS machine.
CODEThis is useful if your database resides on another machine, and you want to determine if the network between the EJBCA machine and the DBMS machine is a bottleneck.
The investigation above shows quite normal values. It took about 350 ms to load the audit log page in Chromium. Of these 350 ms, around 6 ms seconds were spent on doing three queries against the database. Of these 6 ms, about 0.1 ms was incurred by network delays.
Log Database Queries Using MariaDB
If you are using MariaDB, you can enable logging of slow queries, as well as queries not using an index, by running the following commands:
The following displays an example of what the log file /tmp/mariadb-slow.log
can look like if slow queries are detected:
For more information, refer to the MariaDB Knowledge Base article Slow Query Log Overview.