sql server - Why is PHP -> MSSQL very slow when the DB is not on the same machine as the PHP code -


in course of trying move our website azure, we've found problem our php code talking mssql.

on current dedicated host (hosting both php , db), going page typically takes less 2 seconds. i've run queries necessary through ssms , take less 1 second. amount of data being returned queries small - 10-20 records, less 100kb in total.

with website hosted on azure (connecting azure sql database) same page takes around 40 seconds load. further investigation showed might caused database not being on same machine php - when original website pointed @ remote database (either dedicated machine or azure sql instance) page load time goes 40 second range.

in azure case, both website , db located in same region (n europe). when testing using our machines, both located in uk.

the current webhosting machine running php 5.4 , microsoft sql server express edition. azure website running on php 5.4.

in both cases we're using 3.0.1 microsoft sqlsrv drivers

how can improve performance when connecting remote sql db?

this question has been cross-posted server fault @ https://serverfault.com/questions/496505/why-is-php-mssql-very-slow-when-the-db-is-not-on-the-same-machine-as-the-php

no clue why response time jumps 2 40 seconds, but... few things consider:

  • if sql database instance in data center, you'll see both latency , bandwidth charges. if data centers separated continent (e.g. 1 in west, 1 in hong kong), you'll see more latency than, say, west <--> east).
  • if you're transferring significant amount of data result of query, bound network pipe size. 100mbps per core, small (xs) instances have 5mbps bandwidth.

you mentioned testing query in sql server management studio (at least i'm assuming sms ssms). query performance when testing against sql database? if it's close 40-second mark, quite possibly there's missing index when data ported local database sql database instance.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -