How to reduce MySQL connection time

I have a JSP page. It worked well, but it gets very slow (15 seconds to boot) after the Systems team has updated OS Solaris 10.

I checked all the requests on this page and each request works fine. In fact, they are all very simple queries. And there are only about 300 entries in each related table.

The only feature: there were about 60 connections on this page. I managed to reduce the connections by 30 after I discovered that it was very slow. After this optimization, the boot time was reduced to 6 seconds. But, still very slow! And even worse, I can no longer reduce the connection if I do not want to rebuild half of the application.

Another JSP page (not in the same application) worked well, but now it is slowing down too. It has only 1 link, but this page is very time sensitive. Thus, I see that it is becoming slower.

Can someone tell me how to configure mysql or / and tomcat to reduce mysql connection time?

+4
source share
3 answers

Do you say โ€œconnectionโ€ when you mean โ€œrequestโ€? Or are you creating a new database connection for each query? You must not do this. On a Tomcat application server, you should use pooling , which will significantly reduce connection costs.

Another common problem is that MySQL Server is trying to resolve your client hostname from its IP address. This is called DNS host name resolution, and when creating a new connection, this can be a source of great overhead. You can configure your MySQL server to skip DNS name resolution without significant reduction.

+3
source

Why are you making more than one database connection per page? This should not be a general case. Make one connection and use it to display the entire page.

0
source

How do you refer to the server in your connection string? Are you using "localhost" or something else? Try replacing this with โ€œ127.0.0.1,โ€ for example, which will skip name resolution.

0
source

Source: https://habr.com/ru/post/1316372/


All Articles