Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 932
oshirowanen Avatar asked Jul 10 '12 11:07

oshirowanen


People also ask

How do I find the bottleneck on a website?

If you want a generic way to find bottlenecks, try using a HTTP monitoring tool. This allows you to see what types of requests are taking longer, or if they are returning error messages. You can then use a platform specific profiling tool to zero in on specific areas of your application based on the data from the tool.

What is bottleneck in website?

A bottleneck can occur in the user network or storage fabric or within servers when there is excessive contention for internal server resources, such as central processing unit (CPU) power, memory or input/output. As a result, data flow slows down to the speed of the slowest point in the data path.

What element S on this website could lead to a performance bottleneck?

Large Image Sizes. An example of a performance bottleneck would be a website that contains a huge number of images, trying to render all of the images in the web browser at the same time. This would put a huge strain on the webserver to deliver all of the data, leading to a longer load time.


2 Answers

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.

like image 91
Roman Newaza Avatar answered Sep 20 '22 18:09

Roman Newaza


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.

like image 34
Leigh Avatar answered Sep 23 '22 18:09

Leigh