How to reduce JSF application CPU consumption

2

From time to time, my application started to have a very large CPU consumption. I installed JProfiler, and from what I understand of it, there is a problem with hibernate's c3p0. I'm using hibernate 4.3, jsf2.2.10 + primefaces 5.2, use ehcache as well.

Below are some of the results I've written.

    
asked by anonymous 29.08.2018 / 00:24

1 answer

1

Looking at the graphs that appear, I believe you misinterpreted the problem.

I did not see CPU consumption as the problem, even because this information is not shown. The amount of% you are seeing is not CPU, but it is time spent running that method. The cause can be multiple things (including CPU).

In your specific case, C3P0 seems to be taking a long time to get a connection with the database. The connection pool serves to speed this up, because the C3P0 keeps some connections always open and, when the application requests a connection, it already has one ready to use.

However, if this step is slow, it is possible that the current pool is too small (in its current configuration, it is like 5) and it needs to open new connections to the database. Opening a new connection to the database is something heavier, which would explain your problem.

Another explanation is that you have reached the maximum number of connections , which you currently set to 20. When this occurs, the system needs to wait to use an open connection, which would also explain the delay.

The above two cases can be monitored on the server or directly in the database, following the number of open connections.

To improve, you can increase the minimum or maximum pool of connections, depending on your problem. Try a number greater than 5 for the minimum, for example. The exact number I can not say what it can be, because it depends a lot on your application and the server.

If you notice that this problem is more severe at specific times (such as at dawn) Also check if there is no heavy routine being run in the database during the time. This may affect the opening time of a new connection.

    
11.09.2018 / 22:39