Azure的Web应用程序缓慢的服务器响应时间

问题描述:

我有基本的(小)层Azure的Web应用程序托管在西欧与在同一地区基本SQL数据库。总是在已打开。请注意,我的网站的目标受众是在欧洲。

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.

请注意,该网站是一个基于 codeIgniter ,并运行在 PHP 5.6

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

该页面加载缓慢真的,即使对当地环境的一切都是快。运行后 PageSpeed​​ Insights的在我的网站我得到了如下评价:

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:

减少服务器响应时间
  在我们的测试,您的服务器1.7秒内做出响应。有许多因素可以减缓你的服务器响应时间。请阅读我们的建议,以了解如何监测和衡量您的服务器花费时间最多的。

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:

正如你可以看到最初的反应是非常糟糕的。可能是什么问题?

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

UPDATE / SOLUTION

刘的建议 - 的MSFT 从注释,即让 pconnect database.php中页面加载时间下降到 0.23 秒,这是一个〜8倍的改善。

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.

在CI框架中,如果您运行的是督促的应用程序,我们可以设置 pconnect 真正的config / database.php中来使用数据库的持久连接。这可以降低初始连接延迟。

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.

顺便说一句,如果你正在运行一个测试或开发应用程序,我们需要使用此设置用心对待,因为它可能会带来一些意想不到的问题。你可以参考的Advantages /在codeIgniter pconnect选项的缺点,以获得更多信息。

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.