lots of DB connections



Hi, I have a site where 7 databases are opened for every user, using mysql_connect. each database is on the same server, and each connection uses a different user.

what i am worried about is the overhead this might cause should the site get a lot of traffic. what should i be worried about?

thanks !

why do you need to open all 7 different database connections at the same time?

Mysql can only open so many connections till your system runs out of resources. You should only have to open one connection per page load per user. Connections are closed after the page is finished loading or mysql_close() is called.

we open the connections in an included file, and then our website accesses whatever of the 7 databases are required, when they are required, by referencing the database object.

these are not persistent connections ... is it really going to be that much of a problem? just wondering how much load opening connections like this is goign to cause...

it hasnt been a problem for many sites we have done, but they have had fewer DBs and not that much traffic. :shock:

You still haven't answered the question: Why do you need seven databases? I could see maybe having seven tables, but unless you're Amazon.com I can't imagine any scenario in which having seven databases would be useful.
it is a very big site, although not amazon, and i prefer to have different databases for different kinds of content. we have a members database, a prices database, a content database, a transactions database, etc. each database has between 7-14 tables. putting all these together would result in a massive database that is very hard to deal with.
If you have 7-14 tables for users and 7-14 tables for prices, it seems fairly likely to me that you have serious architecture problems.