简体   繁体   English

加载网页时发现瓶颈?

[英]Finding a bottleneck when loading a webpage?

UPDATE 1: 更新1:

After doing an strace on the server, I have discovered that the mmap's process is taking 90% of this processing time. 在服务器上执行strace后,我发现mmap的进程占用了90%的处理时间。 I've discoverd that 1 of the pages is taking a minute to load. 我发现其中的一页需要花费一分钟的时间来加载。

So I found this link: PHP script keeps doing mmap/munmap 所以我找到了这个链接: PHP脚本一直在执行mmap / munmap

It possibly shows the same problem. 它可能显示了相同的问题。 However, I don't understand what the anwer means by correctly disabling the php error handlers? 但是,我不明白正确禁用php错误处理程序意味着什么。

ORIGINAL QUESTION: 原始问题:

How do I check for bottle necks on my web server when loading a specific web page which is being served by my server? 加载服务器正在服务的特定网页时,如何检查Web服务器上的瓶颈?

For some reason, a couple of pages on my site have become very slow, and I am not sure where the slowness is happening. 由于某些原因,我网站上的几个页面变得非常慢,我不确定这种情况正在何处发生。

Screenshot from Chrome Dev Tools: Chrome开发工具的屏幕截图:

Click here to enlarge : 点击这里放大 在此处输入图片说明

So basically, I need to find out what is taking this section to long to load? 因此,基本上,我需要找出使此部分花很长时间加载的内容? Client Side web tools can't seem to break this down? 客户端网络工具似乎无法将其分解?

Xdebug:分析PHP脚本 -注意KCacheGrind工具,或者,可以使用高级PHP调试器 apd_set_pprof_trace()函数和pprofp处理生成的数据文件。

I would suggest looking into Xdebug profiling . 我建议研究Xdebug分析 The other two answers deal with client side loading issues but if your bottleneck is server side it won't become apparent from the use of those tools. 其他两个答案处理客户端加载问题,但是如果您的瓶颈是服务器端,那么使用这些工具就不会变得明显。

You may also want to look into the database queries that are being run to serve the pages in question. 您可能还需要调查正在运行的数据库查询,以便为有问题的页面提供服务。 You could be missing an index somewhere which would explain a recent slowness with specific pages as your database tables grow in size. 您可能在某处缺少索引,这可能解释了随着数据库表的增大,特定页面的近期运行缓慢。

I would extract those queries and run them using MySQL EXPLAIN (assuming you are using MySQL) to see if there is slowness there. 我将提取这些查询并使用MySQL EXPLAIN (假设您正在使用MySQL)运行它们,以查看那里是否运行缓慢。

Derick Rethans (author of Xdebug) released quite a nice article today called What is PHP doing? Derick Rethans(Xdebug的作者)今天发表了一篇不错的文章,名为PHP在做什么?

It covers the strace that you've already done, but also shows you how you can use a custom .gdbinit to get the actual php function name that is causing the problem. 它涵盖了您已经完成的strace,还向您展示了如何使用自定义.gdbinit获取导致问题的实际php函数名称。

Of course you have to run your script from the command line with gdb, so I hope that your problem is reproducible in this way. 当然,您必须使用gdb从命令行运行脚本,因此我希望您的问题可以通过这种方式重现。

mmap is for creating a memory mapped view of a file . mmap用于创建文件的内存映射视图。

If it really is the error handler causing it, I'd guess that your script is generating a lot of errors (which you are trying to log), maybe a NOTICE for an undefined index in a loop or something). 如果确实是导致错误的错误处理程序,我猜您的脚本正在生成许多错误(您正在尝试记录),可能是循环中未定义索引的通知或其他内容。

Check the log file (is anything being logged at all?), check permissions on the log file if nothing is logged, also double check what your error reporting level is set to. 检查日志文件(是否记录了所有内容?),如果未记录任何内容,请检查日志文件的权限,还请再次检查错误报告级别设置为什么。

var_dump(ini_get('error_reporting') & E_NOTICE); - Non-zero if you are reporting notices. -如果您要报告通知,则为非零值。

error_reporting(E_ALL & ~E_NOTICE); - Turn off reporting notices. -关闭报告通知。

Using an application such as Fiddler or YSlow Firefox addin will help identify slow loading elements in your website. 使用Fiddler或YSlow Firefox插件等应用程序将有助于识别网站中加载缓慢的元素。 This should make any issues apparent. 这应该使任何问题显而易见。

http://fiddler2.com/fiddler2/ http://fiddler2.com/fiddler2/

https://addons.mozilla.org/en-US/firefox/addon/yslow/ https://addons.mozilla.org/zh-CN/firefox/addon/yslow/

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM