How to reduce JSF application CPU consumption

Asked

Viewed 193 times

2

From a while ago, my application started to have a very large CPU consumption. I installed Jprofiler, and from what I understand from him, there’s a problem with the c3p0 from Ibernate. I am using Hibernate 4.3, jsf2.2.10 + primefaces 5.2, use ehcache also.

Below are some results I printed.

imagem consumo mchange

Threads .data

thread tree

hibernate config

  • Marlucio, what’s the app’s database? See if there are any Ocks in the database. Other than that, what has changed in the life of the application (use or update) that coincides with the increase in CPU consumption?

  • Mysql Bank 5.6. It hasn’t changed much. What’s strange to me is that even without anyone using it, like hours at dawn. Or without session are generating such consumption.

1 answer

1

Looking at the graphics presented, I believe you misinterpreted the problem.

I have not seen CPU consumption as the problem, 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 several things (including CPU).

In your specific case, C3P0 seems to be taking a while to get a connection with the database. The connection pool serves to speed this up, as C3P0 keeps some connections open at all times, and when the application asks for a connection, it already has one ready to use.

However, if this stage is taking long, it is possible that the current pool is very small (in its current configuration, it is as 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 you have reached the maximum number of connections, which you currently set as 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 amount 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’t tell which can be, as it depends a lot on your application and the server.

Note that this problem is more serious at specific times (such as at dawn) also check if there is no heavy routine being run in the database during hours. Maybe this can affect the opening time of a new connection.

  • So, I had not received notification of your reply. It’s because I didn’t show you the task manager. It’s always 99% in use. Thank you, I’ll test it here buddy.

  • Cara didn’t solve it. I changed the numbers and it’s still the same.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.