none
multiple connections to mssql using php

    Question

  • Hi everyone,

    I have written a script to do multiple connections with mssql server. To accomplish this I use a php function mssql_connect(servername, username, pass, 1) in a loop which runs 50 times. But always after 25 iterations, my script fails to make a connection. I am doing this from APTANA IDE using the php5.3.3(CGI) plugin on my desktop.

    I checked the maximum connection limit by SELECT @@MAX_CONNECTIONS and it is more than 30000 . Moreover when I see the properties of the server by right clicking on it in management studio and going to connection page, i can see maximum number of connections is set to 0 which means unlimited.

    I am using SQL server standard edition 2008 and the server is Windows Server 2003.

    Can someone please let me know what I am missing here?

    Thanks,
    Manish

    • Moved by Tom Phillips Tuesday, December 14, 2010 1:58 PM PHP question (From:SQL Server Database Engine)
    Monday, December 13, 2010 10:34 PM

Answers

  • Hi Manish,

    We understand the need for simplicity. We will be happy to work with the APTANA IDE folks to provide them the required guidance to integrate the SQLSRV driver into their product. As their customer, feel free to direct them to us.

    As you are aware, SQL Server does support many connections so it could be a limitation of the MSSQL implementation. We don't have enough knowledge/experience with MSSQL to provide any assistance.


    Ashay Chaudhary
    SQL Server Driver for PHP (http://blogs.msdn.com/sqlphp)
    All information provided "as-is" and without warranty.
    Tuesday, December 14, 2010 8:03 PM

All replies

  • I think you must also check your query on MySQL or PHP forum.
    ~Manu
    http://sqlwithmanoj.wordpress.com
    Tuesday, December 14, 2010 7:16 AM
  • Hi Manish,

    This forum is to provide support for the SQLSRV and PDO_SQLSRV drivers, not the deprecated MSSQL drivers. If possible, use the SQLSRV driver and see if you have any problems doing so, and let us know.

    That said, it will be good to know why you need so many connections active. With the SQLSRV driver supporting Multiple Active Result Sets (MARS), one can use one connection for many queries and then use sqlsrv_next_result() to move to the next resultset. Possibly this is a better solution. Possibly a hybrid solution where you have a handful of connections and then judiciously "group" the queries to the appropriate connection.

    Alternatively, you can post on the PHP forum and see if there are any MSSQL experts who can help you.

    Manu - why do you think Manish will get help on the MySQL forum?


    Ashay Chaudhary
    SQL Server Driver for PHP (http://blogs.msdn.com/sqlphp)
    All information provided "as-is" and without warranty.
    Tuesday, December 14, 2010 3:30 PM
  • Hi Ashay,

    Thanks for the reply. As I mentioned I am doing this from APTANA IDE using the PHP plugin , I have to work with the drivers which are provided unless I go about installing and configuring  PHP on a server, but I was in a hurry to get it done and to start with it seemed quite trivial.

    Yes I can do one connection at a time but the whole purpose of script was to see how much load it can handle. In a real world scenario also we can have more than 25 open connections at a time easily and I was hoping since there is no constraint on the DB and server side for the open connections per user, it would be able to handle much more.

    Thanks very much for the suggestion and I did post it on PHP forums but nothing useful has come out of it till now. Although I did make sure that my script is configured to handle multiple connections by checking mssql.max_links and  mssql.max_procs and both are set to 'unlimited'.

    If you think there is no other option then I'll have to experiment with changing the driver only but have you seen this kind of problem with MSSQL driver before?

    Manu- If you are curious about the behavior with Mysql, I did test it and I was able to do 100 connections easily using the same environment which is the default for Mysql. This limit can also be increased but I didn't try it further. 

    Thanks

    Tuesday, December 14, 2010 4:24 PM
  • @Ashay, I really apologizes for this. I thought it was mysql & php, hence the response.

    @Manish, please disregard my response.


    ~Manu
    http://sqlwithmanoj.wordpress.com
    Tuesday, December 14, 2010 4:25 PM
  • Hi Manu,

    No harm done. It is quite common for folks to associate PHP with MySQL or the other way around, and it's just one character difference between mysql and mssql.


    Ashay Chaudhary
    SQL Server Driver for PHP (http://blogs.msdn.com/sqlphp)
    All information provided "as-is" and without warranty.
    Tuesday, December 14, 2010 7:57 PM
  • Hi Manish,

    We understand the need for simplicity. We will be happy to work with the APTANA IDE folks to provide them the required guidance to integrate the SQLSRV driver into their product. As their customer, feel free to direct them to us.

    As you are aware, SQL Server does support many connections so it could be a limitation of the MSSQL implementation. We don't have enough knowledge/experience with MSSQL to provide any assistance.


    Ashay Chaudhary
    SQL Server Driver for PHP (http://blogs.msdn.com/sqlphp)
    All information provided "as-is" and without warranty.
    Tuesday, December 14, 2010 8:03 PM
  • Hi,

    you can try :

    ini_set("mssql.max_procs", 50);
    Thursday, January 05, 2012 7:41 AM