Speed up connection to MySQL – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.
But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about apache-2.2, windows, mysql, performance, .
So here’s one for you. Any idea on a way to shorten the time it takes to connect to a MySQL database?
The reason I’m wondering is because I find that just connecting to the DB adds just over a second to the rendering of the page and that seems a bit long considering Apache and MySQL is running on the same machine and the mysqli_connect is connecting to localhost. It’s just such a shame when the connection takes a second while any query I end up doing won’t add any significant amount of time to the render/load time.
Any ways to shorten the time it takes to open a connection?
With so little information to go on it’s hard to offer much but I will tell you that you will be better off setting your configuration to connect to MySQL by IP (127.0.0.1) address than by name. If nothing else, you will remove one complete layer from the connection.
Since everything is local, you can skip networking (TCP/IP, DNS, etc) and use a socket or network-pipe connection to MySQL.
You should use persistent connexion from your application to the mysql server, this way you won’t have to initiate a new TCP connexion each time a request is done.
Have a look at this documentation:
Update: Care to explain why I got that downvote ?