Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have no strace skill and knowlegde, but im trying to work through a problem where my clients application is awfully slow. And im trying to find out where the bottleneck / problem may lie.

So I ran

/etc/init.d/apache2 stop && strace -Tf -o /tmp/trace.txt /etc/init.d/apache2 start

And going through /tmp/trace.txt, im seeing quite a lot of the following.

2540  poll([{fd=21, events=POLLIN|POLLPRI}], 1, 0) = 0 (Timeout) <0.000052>

Would anyone please what im seeing and, and how would I go about tying it to where the problem is. The site does use MySQL, does this mean the connection to MySQL could not be established? Is the poll even DB related.

share|improve this question
    
Have you ruled out all the basics ? You mention MySQL - you've confirmed it's not long running queries locking on your MySQL host? Jumping in with strace is for when you're getting down to brass-tacks. Can you outline some of the steps you've ruled out? –  Andrew Taylor Jan 18 '11 at 14:32
add comment

1 Answer

Take a step back first -- you are getting very low level before finding out where the problem generally is. A simple way to do this is to see if static HTTP pages are slow from Apache -- if they are not then maybe the DB is slow. The next step I would take is to see how long DB queries are taking.

Also if this is all on the same system you can look at system resources will tools such as top, iotop, and iostat.


Regarding the poll system call:

I would try adding the -c switch to the strace of Apache to see what your timings are on each syscall if you narrow it down to apache before focusing on a system call. For example the top of my output from a healthy HAProxy is:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 38.79    0.001152           0      6089           epoll_wait

The poll system call is used to wait for for an available an event on a file descriptor. My first guess since the timeout is so low that this is the normal functioning of Apache. It might be that Apache is running out of file descriptors since a file descriptor is needed for each network socket if this actually a problem. You could look at Apache manual section on File Descriptors if you get to this point. But according to DerkK "it'd be failing at open() or socket()" which makes a lot more sense.

So really this is just some detail on what very likely isn't your actual problem -- again take several steps back.

share|improve this answer
2  
Not quite, poll() waits for an event on an existing file descriptor (specifically, data to be read or priority data to be read according to the events flag above). If you want to see what apache is waiting for, you'd need to back up and see which system call returned fd 21 (likely open() or socket()). If it was out of descriptors, it'd be failing at open() or socket() long before it got here. I think the rest of your ideas are sound. It's really unlikely that the problem is apache and can easily be tested by loading some jpegs or static html from the server. –  DerfK Jan 18 '11 at 14:44
    
If you do a man poll you can find out what poll() does, which is as described in the comment above. But i thought I'd share with you how to find out what the various system calls do. You can do a man <syscall> to get more info on each of them from strace. –  slm Jan 12 at 16:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.