PHP 执行时间:确定执行速度时要考虑的因素

发布于 2024-10-20 04:17:06 字数 268 浏览 2 评论 0原文

由于我的所有请求都通过索引脚本,因此我尝试计算所有请求的响应时间。

它只是开始时间(脚本的开始)和结束时间(脚本的结束)之间的差异。

当我将数据缓存在 memcached 上时,所有用户都使用 memcached 提供服务。

我的响应时间大多不到一秒,但有时会出现超过一秒的奇怪峰值。最坏的情况可能会长达 200 秒以上。

我想知道移动用户的连接速度是否缓慢,这是否会影响我的响应时间?

我正在为主要移动用户提供服务。

谢谢!

As all my requests goes through an index script, I tried to time the respond time of all my requests.

Its simply the difference between the start time (start of the script) and end time (end of the script).

As I cache my data on memcached and user are all served using memcached.

I mostly get less than a second respond time but at times there's wierd spike of more than a seconds. the worse case can go up to 200+ seconds.

I was wondering if mobile users had a slow connection, does that reflect on my respond time?

I am serving primary mobile users.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

孤芳又自赏 2024-10-27 04:17:06

不,这是脚本的运行时。它不计算用户的延迟,这是底层 Web 服务器所担心的。你的脚本中的某些内容需要很长时间。我建议您分析您的脚本以查找它是什么。 Xdebug 是一个很好的方法。

No, it's the runtime of your script. It does not count the latency to the user, that's something the underlying web server is worrying about. Something in your script just takes very long. I recommend you profile your script to find what that is. Xdebug is a good way to do so.

醉生梦死 2024-10-27 04:17:06

如果您使用 PHP 进行测量(听起来像您),那就是在服务器端生成页面所需的时间,而不是下载所需的时间。

将计时器放在整个页面中,并尝试将其分解为导致 200 秒以上巨大延迟的部分。

您甚至可以添加一个小脚本,如果加载频率不够高,您自己无法看到,该脚本会通过电子邮件向您发送有关加载每个部分所需时间的详细信息。

If you're measuring in PHP (which it sounds like you are), thats the time it takes for the page to be generated on the server side, not the time it takes to be downloaded.

Drop timers in throughout the page, and try and break it down to a section that is causing the huge delay of 200+ seconds.

You could even add a small script that will email you details of how long each section took to load if it doesn't happen often enough to see it yourself.

遇到 2024-10-27 04:17:06

脚本可能无法完成,因为客户端下载结果非常非常慢。如果你没有使用像nginx这样的前端服务器,那么首先要做的就是尝试一下。

It could be that the script cannot finish because a client downloads the results very-very slowly. If you don't use a front-end server like nginx, the first thing to do is to try it.

云醉月微眠 2024-10-27 04:17:06

有人已经提到了 xdebug,但通常您不想在生产中运行 xdebug。我建议使用 xhprof 来配置有关开发/登台/生产的页面。您可以有条件地打开 xhprof,这使得在生产环境中运行变得非常容易。

Someone already mentioned xdebug, but normally you would not want to run xdebug in production. I would suggest using xhprof to profile pages on development/staging/production. You can turn on xhprof conditionally, which makes it really easy to run on production.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文