Perf is a performance analysis tool for Linux, capable of function-level and instruction-level hotspot search.

1. Start docker

docker run -dt –privileged=true -p 3333:22 -p 80:80 -v /Users/wenba/Desktop/project:/data -v /Users/wenba/Desktop/docker/nginx:/usr/server/openresty/nginx/conf/vhost –name mydocker 933bdb63c863 /usr/local/sbin/run.sh

When starting docker tests, remember to use — Privileged = True to allow super privilege mode

2. Install the perf

yum install perf
Copy the code

3. Perf Several common commands

# Count global performance
perf record -g
Copy the code

After a while

# check record
perf report
Copy the code

View abnormal problems of a process

Check the process ID
ps aux|grep index.php
# check record
perf record -p 276
Copy the code

After a while

# check record
perf report
Copy the code

To see where more CPU is being used, we see pow_function, which we can enter to see the specific execution instructions

Real-time observation

We can also use an instruction usage like top

# Global performance observation
perf top

# Monitor a process
perf top -p 327
Copy the code

We can also

# limit scope according to commS
perf top --comms nginx,php
Copy the code

There may not be a single process providing services, which can be separated if all analysis is required

Perf top - 23015324, 76, pCopy the code

Finally, according to view consumption instructions, comprehensive analysis, troubleshooting system bottlenecks.

More highlights: