1
votes

I have Basic (Small) tier Azure Web App hosted in West Europe with a Basic SQL Database in the same region. Always On is turned on. Note that my website's target audience is in Europe.

Note that the website is CodeIgniter based and runs on php 5.6.

The page loads really slowly, even though on local environment everything is fast. After running PageSpeed Insights on my site I get the following assessment:

Reduce server response time In our test, your server responded in 1.7 seconds. There are many factors that can slow down your server response time. Please read our recommendations to learn how you can monitor and measure where your server is spending the most time.

When inspecting the site from developer toolsI get a similar picture: enter image description here

As you can see the initial response is really bad. What could be the problem?

UPDATE/SOLUTION

Taking the advice of Gary Liu - MSFT's from the comments, namely enabling pconnect in the database.php the load time of the page went down to 0.23 seconds, that is an ~8x improvement.

2
It's because of your SQL Database. A basic SQL database it's quite slow. You can either scale your SQL Database to standard, or use Redis Cache if your app is relatively static.Jack Zeng
I think its not correct to derive conclusions with out factsTheGameiswar
After upgrading the DB to Standard the delay went down to 1.4. This is a very slim change considering that my latency to West Europe data centers is ~100 ms. How could I measure the latency between the web app and the db?Pio
I think that the best way is to add at method enter/ exit System.Diagnostic.Trace.WriteLine(DateTime.Now + " Enter method xxx) So you can see the timing in the Azure Application Log. Are you using EF?aljj
have you set the pconnect to true in config/database.php?Gary Liu

2 Answers

2
votes

I have found the Entity Framework to be the culprit for long initial(cold start) responses. Disabling IIS from timing out has not helped, I think there must be some kind of EF pooling\memory timeout that is not advertised.

You can turn off some of the EF checks for DB versioning and try to use precompiled view that help a bit. I am still quite displeased with EF startup times when running in Azure connecting to on prem DB. Startup times on prem are about 1 second but nothing I have done can get my cloud on prem startup times under about 10-12 seconds. I have concluded that there is a lot of networking overhead for on prem and I would suspect using Azure SQL also presents a lot of networking overhead as well since it is public facing.

0
votes

In CI framework, if you are running a prod application, we can set pconnect to true in config/database.php to use a persistent connection to database. Which can reduce latency on initial connection.

By the way, if you are running a test or dev application, we need to treat carefully with this setting, because it may cause several unexpected issues. You can refer to the answer of Advantages / Disadvantages of pconnect option in CodeIgniter to get more info.