Advertisement:

Author Topic: mysql connect and hostgator  (Read 2073 times)

kingofpain

  • Jr. Member
  • **
  • Posts: 95
mysql connect and hostgator
« on: July 21, 2011, 06:46:49 pm »
Hostgator implies a 30 concurrent connections per mysql user limit on script to prevent heavy mysql load on the server and to hunt down scripts that use unnecessary mysql connections due to bad coding practices.

These errors can be prevented by making some coding tweaks into your code.

1. Use of mysql_connect() for connections to mysql dbs in your code. The advantage is :

"The link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling mysql_close()."

2. Use of mysql_close() explicitly. Although mysql_connect() closes the connections, use of mysql_close() in conjunction with it would make sure that the connection is totally closed.

3. Prevent use of mysql_pconnect(). The disadvantage is :

"The connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect)"



My question: what do you use: mysql_pconnect().
                                                             or
                                                   mysql_connect()   ?

Juan Ramón

  • Osclass Developer
  • Hero Member
  • *****
  • Posts: 2382
Re: mysql connect and hostgator
« Reply #1 on: July 21, 2011, 06:58:52 pm »

keny

  • Full Member
  • ***
  • Posts: 137
Re: mysql connect and hostgator
« Reply #2 on: July 21, 2011, 09:06:45 pm »
If you reach 30 connection in same time it will be the time to change your hosting. OSClass is well coded don't worry about that


_CONEJO

  • Administrator
  • Hero Member
  • *****
  • Posts: 4689
Re: mysql connect and hostgator
« Reply #3 on: July 22, 2011, 12:08:28 pm »
Hi kingofpain,

As JR said, we use mysqli instead of mysql, recently, there were a message on PHP's maillist to move from mysql to mysqli (newer, better). This isn't new, from some time ago, but a bit long to tell it here.
We have some good practices (we close manually the connection), but for 2.3 release we want to work on optimization and almost rewrite from scratch the database connection models.


30 users limit is a low limit (usually on shared hosting) it could handle around 50-80 users at the same time, which is a serious amount.