基于互联网/连接延迟PHP执行时间的变化? [英] PHP's execution time changes based upon internet/connection latency?

查看:138
本文介绍了基于互联网/连接延迟PHP执行时间的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人能帮助我明白了什么。如果我访问一个网站,该网站在这个星球上的PHP报告〜300ms的页面执行时间的另一面(通过做简单的数学与 microtime中(真))。如果我访问同一网站本地服务器上,PHP报告〜20ms的页面执行时间。这似乎是网络延迟是在PHP的执行时间,因为我觉得整个页面是由PHP渲染并返回到Apache将被立即发送到客户端(因此,脚本的执行时间将是相同的这是令人惊讶的对我的一个因素,不论出身)。

I'm hoping someone can help me understand something. If I'm accessing a website which is on the other side of the planet PHP reports ~300ms page execution time (via doing simple math with microtime(true)). If I access that same website locally on the server, PHP reports ~20ms page execution time. It seems like network latency is a factor in PHP's execution time, which is surprising to me because I thought the entire page was rendered by PHP and returned to apache to be immediately sent to client (thus, the script execution time would be the same, regardless of origin).

的Apache,PHP5(mod_php的),CentOS 5的。

Apache, PHP5 (mod_php), CentOS 5.

我是假设PHP是在某种方式等待输出继续执行之前,被发送到浏览器?我有一种感觉,有可能是参与了一些这方面的输出缓冲因素的影响,但我真的不是很确定。我有输出缓冲通过php.ini中打开。

Am I to assume that PHP is in some way waiting for output to be sent to the browser before continuing to execute? I have a feeling there might be some output buffering factors involved with this, but I really am not sure. I have output buffering turned on via php.ini.

我的问题是:怎么回事,怎么是我影响PHP的执行网络延迟

My question is: what is going on, and how is my network latency affecting PHP's execution?

我希望这是适当的地方要问这样的问题。我尝试了与功放搜索;谷歌,但与结果一无所获,甚至没有相关的运气。

I hope this was the appropriate place to ask this kind of question. I tried searching SO & google, but had no luck with finding anything even relevant.

修改我说的不是测量它的网页从服务器传送到客户端的时间。我是直线上升谈论PHP如何计算它,当我从本地机器上下载网页的HTML源代码执行速度更快。同一台服务器,同一个页面,一致的结果。我使用卷曲http://example.com | grep的毫秒在这两个位置,看看服务器作为PHP执行时间报告。

Edit I am not talking about measuring the time it takes for the webpage to transfer from server to client. I am straight up talking about how PHP calculates that it executes faster when I download the HTML source of the page from a local machine. Same server, same page, consistent results. I am using curl http://example.com | grep milliseconds in both locations to see what the server is reporting as PHP execution time.

推荐答案

两台不同的机器,甚至两个不同的服务器软件或不同的配置可以对你的执行时间,巨大的影响究竟最相同的机器。任何地方都可能发生。一个堵塞可能出现(它以前发生在我身上),突然网页需要10秒来加载。在此之后,重新启动浏览器,清空缓存,再试一次,并再次将其几乎是瞬间完成的。

Two different machines, or even two exactly-the-same machines with different server software or different configurations can have drastic effects on your execution time. Anything may happen. A clog may occur (it has happened to me before), and suddenly the page takes 10 seconds to load. After that, you restart your browser, empty the cache, try again, and it is almost instantaneous again.

因此​​,所有的华夫饼干后,所有我想提的是,它没有任何关系的连接速度,或者至少是接近罢了。

So after all that waffle, all I want to mention is, it has nothing to do with connection speed, or at least near nothing.

这篇关于基于互联网/连接延迟PHP执行时间的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆