Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I be concerned about performance with connections to multiple databases?

Tags:

php

mysql

apache

I have a PHP app that is running on an Apache server with MySQL databases. Based on the subdomain that users access, I am connecting them to a database (sub1.domain.com connects to database_sub1 and sub2.domain.com connects to database_sub2). Right now there are 10 subdomain-database combos, but that number could potentially grow to well over 100.

So, is this a bad thing?

Considering my situation, is mysql_pconnect the way to go?

Thanks, and please let me know if more info would be helpful.

Josh

like image 758
Josh Ryan Avatar asked Nov 14 '22 10:11

Josh Ryan


1 Answers

Is this an app you have written?

If so, from a maintenance standpoint this may turn into a nightmare.

What happens when you alter the program and need to change the database?

Unless you have a sweet migration tool to help you make changes to all your databases to the new schema you may find yourself in a world of hurt.

I realize you may be too far into this project now, but if a little additional relation was added to the schema to differentiate between the domains (companies/users), you could run them all off one database with little additional overhead.

If performance really becomes a problem (Read this) you can implement Clustering or another elegant solution, but at least you won't have 100+ databases to maintain.

like image 180
TomWilsonFL Avatar answered Dec 06 '22 05:12

TomWilsonFL