iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
19.95k stars 3.81k forks source link

Profiling Docker Containers (nginx) #4138

Open joelcisnerosss opened 1 year ago

joelcisnerosss commented 1 year ago

Hello Everyone!

I was playing around with the profile.py tool just to see how does it perform on different scenarios. I've started a simple nginx server by executing docker run -d -p 80:80 nginx. When I run curl localhost:80 it does work so the nginx server has been setup correctly. I ran ps aux | grep nginx to get the PID of this nginx server. I then ran the profiling tool with the root PID, while I continuously curled localhost:80, however I got no output. I then saw that the nginx server had forked many processes inside so I tried profiling each PID individually, while still curling localhost:80. However, still no output. Is there a way to profile a server hosted within docker such as nginx?

Any help would be appreciated!

chenhengqi commented 1 year ago

Try increasing the profile frequency like -F 9999.

joelcisnerosss commented 1 year ago

This worked, thanks so much!

Could you possibly share an explication of why increasing the frequency solved this issue?

chenhengqi commented 1 year ago

The profile.py works by sampling all processes on all CPUs at 49Hz (pretty low )by default, so it's likely to miss events triggered by nginx.

You may also solve the problem by increasing the QPS to nginx.