pelegk2 wrote:when should i use mysql_pconnect and when to use mysql_connect
?
Use persistent database connections when:
- You have extensively tested them on a test server under simulated load, and found no problems
- You have a dedicated server and are running only one major application (If you're running other minor apps, run them without persistent connections)
- You are only connecting to a single database
- You have a LOT of traffic
- You are sure that your database can handle the number of connections you're going to have, which may reach the maximum number of threads your web server uses (e.g. set with MaxClients in Apache)
what the execlly diffrence and how does it influence performance?
thnaks in advance
peleg
Persistent connections may remain after the execution of a page for use by a later request which uses the same database.
You must only use persistent connections if your entire app just connects to a single database, otherwise you could create too many connections. Also it is necessary to always use the same login details etc, into your database.
The performance advantage is relatively small if the database is local, similar in size to just one or two simple queries (after all, that's all MySQL really does upon connect). But it might be greater when the database is on a separate machine, as it avoids a tcp handshake etc, which takes a small amount of time even on a fast LAN.
IN order to determine the difference, I suggest YOU benchmark YOUR application on your test network and measure it quantitively. Be sure to post your results here!
Mark