On a page where I use mysql_pconnect, am I supposed to close it again in some way. Or is it done automaticaly?
Printable View
On a page where I use mysql_pconnect, am I supposed to close it again in some way. Or is it done automaticaly?
Not persistant connections. They stay open all the time, and may be shared by other scripts. Once all scripts which used persistant connections are finished, I think it will then be closed.
You think or you know...:D...well the thing is that I have a lot of pages that uses it on a server. And one of the guys that uses that page got an error today. But it dissapeared by it self.
It said something about too many users online....and I was wondering if it had something to do with the connection and closing to do.
ØØ
A persistant connection doesn't increase the number of users who can log on to the mysql server. It simply allows request for an identical connection from a child process to reuse the same connection. This just reduces the overhead of establishing the link.
If you want to increase the number of users who can logon, which defaults to 100, then you will need to configure this on the mysql server.
http://dev.mysql.com/doc/mysql/en/To...nnections.html
Persistent connections are closed when they time out (18 hours of non-usage by default, I think) or when the owning process (the web server, or at least one of the handler childs in Apache's case) shuts down. No earlier. Calling mysql_close on them has no effect.
So that means that if we have 100 diffrent users in less then 18 hours then our web pages can't be used anymore before one of the connections gets closed??? Did I understand that right. So that might be the problem with our page?
If so, then I feel I have to write a mail to those who we are renting the server from. THen the number is too low for our use.
ØØ
No, because if all your users who visit the site use the same script, which will connect to the database with the same host name, user name and pass word, the connection will be reused. When you use mysql_pconnect() it only actually makes a new connection if one of the same type does not exist.
The error which you got has nothing to do with this however, its due to the sql server's configuration and occurs when more the number of sinmultanous connections, exceeds the maximum.
OK...so my code is working then....well then we have to slap the server guys so we can have more visitors on at the same time. We don't have more then 50-100k visitors a month, and they should be able to handle that....if not PIIIIP them...
The relevant stat is only how many requests you need to serve at the same time.
It may be that the same SQL server is being shared with many other sites which have 50-100k hits per month. So it is quite plausable that at anyone time there could be 100 concurrent connectoins.