oshirowanen
oshirowanen

Reputation: 15965

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: enter image description here

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?

Upvotes: 5

Views: 1328

Answers (5)

lll
lll

Reputation: 12889

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.

Upvotes: 1

Roman Newaza
Roman Newaza

Reputation: 11700

Xdebug: Profiling PHP Scripts - pay attention to KCacheGrind tool or, alternatively, you can use Advanced PHP debugger apd_set_pprof_trace() function and pprofp to process generated data file.

Upvotes: 3

bcmcfc
bcmcfc

Reputation: 26825

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.

Upvotes: 1

William Greenly
William Greenly

Reputation: 3989

Page Speed for Chrome is also an option:

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

Upvotes: 0

Rob C
Rob C

Reputation: 920

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

Upvotes: 0

Related Questions