SQL Server Native Client 2012 + PHP + IIS – Performance issues with Large Queries
I am currently having 2 websites which are being hosted on a single server with Different Virtual Machines. Each website is hosted on its own Virtual Machine with IIS 7.5, PHP Fast CGI 5.3 which connects to an MS SQL Server 2012 DBMS with SQL Server Native Client 2012. The SQL Server 2012 resides on a Single Dedicated VM which hosts database pertaining to both the websites, since some of the data is being shared between the websites.
The Setup is based on Windows because we have few .NET services which need to run on the VMs and we are using separates VMs for the websites mainly for Isolation and Security.
The Server has Intel Xeon 2.4Ghz 6 Core processors X 2 with 32 GB RAM and 10K RPM SAS as the primary storage that hosts the databases and the Virtual Machines are hosted on another 7.2K RPM SAS. Performance wise the websites are really fast with average load.
We have a backend login for our websites where we often perform large queries to check the logs and other stuff pertaining to the website and its operation. An average query takes about a minute to complete because it is executed against a very big recordset. Whenever a query is being executed, the website on that host becomes painfully slow.
We have done some tests to narrow down if the issue is with the SQL Server, or the webserver. First of all, we have performed few batch queries on the Database server directly and upon checking the website, we were not able to find any performance issues which clearly suggests that there is no bottleneck with the SQL Server. Next, we wanted to see if this issue was caused by the Webserver or PHP or the SQL Server Native Client. We hosted a HTML test file on the server and we tried to access that file when we were performing a batch query and it turned out to be just as fast. A plain php file with a small sorting algorithm worked just fine when a batch query was being performed from the website backend. However, when we actually tested a database connection with a small query, it was taking time to load up when the query was running. This clearly states that there is a bottleneck somewhere in the PHP SQL Server Driver.
I know that PHP isn’t so good with MSSQL server, but due to development limitations, I need to stick with MSSQL for now. I have no idea what is slowing down the SQL Server Native Client when a big query is in progress. I have done some reading and I have tried playing with the ConnectionPooling and also the MultipleActiveResultSets but nothing have showed improvement in the current scenario. The website becomes really slow that it would take 20 seconds for each page that connects to the database, whereas without any query running on the backend, it would load in a mere second or two.
This seems to be limited to a particular host only. When I run a heavy query on Website 1, the other pages on Website 1 are painfully slow, whereas Website 2 doesn’t show any performance issues at all. Tried checking the CPU usage on both the webhost and the database server. They are just a mere 5-10% more which I don’t think might be responsible for such drastic issues with performance.
I am thinking that maybe there might be a bug with the SQL Server Native Client 2012 that is responsible for this or is there any setting or case that I missed?
Thank you in advance.
One Solution collect form web for “SQL Server Native Client 2012 + PHP + IIS – Performance issues with Large Queries”
First and foremost stop changing random settings (like enabling MARS) in hope it improves. Apply a methodology: measure, identify bottlenecks, fix those bottlenecks. I recommend you read the Waits and Queues paper, it was proven again and again an excellent performance troubleshooting methodology. Follow the Performance Troubleshooting Chart. You will then be able to correctly identify the root cause (/cough contention) and address it appropriately.