0

we have an application which has at most 50K Users active at peak hours, for this we are using SQLServer as its backend DB, now we are planning to migrate it to MySQL.So as part of this, we need to check if MySQL can handle the traffic. so far I have tried mysql_pconnect() and when I check the active connections in MYSQL console it is not reflecting the expected number as this function reuses the connections.It would be very helpful if someone can tell me a way to open multiple connections to DB.

5
  • Apache handles automatically Connection pool Commented Jul 22, 2015 at 14:24
  • but how can I make sure that application can handle that much traffic. The problem is we are very much comfortable with Sqlserver but in order to migrate we need to look at all the disastrous situations right. Commented Jul 22, 2015 at 14:30
  • serverfault.com/questions/257391/… here :) Commented Jul 22, 2015 at 14:32
  • 1
    You really should use mysqli or PDO statment instead of mysql because in about 2 or 3 years mysql won't work anymore. It is really deprecated since PHP 5.5 Commented Jul 22, 2015 at 14:35
  • Try blitz.io for load testing. Commented Jul 22, 2015 at 15:06

2 Answers 2

1

Use this to create 2 different connections:

$first_db_conn = new mysqli('localhost', 'user_1', 'pw_1', 'db_1');
$second_db_conn = new mysqli('localhost', 'user_2', 'pw_2', 'db_2');

you can then:

$first_db_conn->query("SELECT * FROM `users` LIMIT 1");
$second_db_conn->query("SELECT * FROM `users` LIMIT 1");
Sign up to request clarification or add additional context in comments.

Comments

0

Try to make multiple calls to mysql_connect(),

Check this example:

$dbh1 = mysqli_connect($hostname, $username, $password); 
$dbh2 = mysqli_connect($hostname, $username, $password, true); 

mysqli_select_db('database1', $dbh1);
mysqli_select_db('database2', $dbh2);

Now query database 1 pass the first link identifier:

mysqli_query('select * from tablename', $dbh1);

and for database 2 pass the second:

mysqli_query('select * from tablename', $dbh2);

1 Comment

The mysql extension is deprecated as of PHP 5.5 in favor of mysqli.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.