简体   繁体   中英

Finding a bottleneck when loading a webpage?

UPDATE 1:

After doing an strace on the server, I have discovered that the mmap's process is taking 90% of this processing time. 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

It possibly shows the same problem. However, I don't understand what the anwer means by correctly disabling the php error handlers?

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?

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:

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 . 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.

Derick Rethans (author of Xdebug) released quite a nice article today called What is PHP doing?

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.

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.

mmap is for creating a memory mapped view of a file .

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. This should make any issues apparent.

http://fiddler2.com/fiddler2/

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

Hope this helps

Page Speed for Chrome is also an option:

https://developers.google.com/speed/docs/insights/using_chrome

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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