After the website is online, increased traffic or short-term functional failures will cause a very bad user experience. How to quickly find the performance bottleneck at this time? Usually when the CPU reaches 100%, it is sometimes difficult to replicate and find the key problem points.
In this article, we will introduce a set of tools called Pyroscope, which allows developers to quickly find the code with performance bottlenecks. Pyroscope can currently support Python, Ruby or Go environments. The author of this article will introduce the Go environment.
What is Pyroscope?
Pyroscope is a set of open source real-time performance monitoring platform. The simple server and agent architecture allows developers to easily monitor code performance. Whether you are looking for performance data within 10 seconds or minutes, it can be displayed quickly and instantly. Don't worry about installing this monitor will cause any performance burden. The storage behind Pyroscope uses Badger's Key-Value database, which is very good in performance. Currently only 3 languages (Python, Ruby and Go) are supported. NodeJS is expected to be supported in the future. Assuming you have not introduced any performance analysis tools or platforms, Pyroscope will be your best choice.
Pyroscope architecture
If you are planning to find a performance analysis tool platform, Pyroscope provides three advantages, so that developers can use it with confidence
- Low CPU usage, will not affect existing platforms
- Data can be stored for several years, and the data can be viewed in 10 seconds with fine granularity
- Compress storage data to reduce wasted hard disk space
- The architecture has only Server and Agent. In addition to the Go language, Python and Ruby App both use the pyroscope command to start related apps to monitor system performance.
Start the Pyroscope service
There are two ways to start. The first is to start directly with the docker command.
$ docker run -it -p 4040:4040 pyroscope/pyroscope:latest server
The other can be started with docker-compose.
---
services:
pyroscope:
image: "pyroscope/pyroscope:latest"
ports:
- "4040:4040"
command:
- "server"
Install Agent
Use in Go language
This article uses Go language as an example, first import package
import "github.com/pyroscope-io/pyroscope/pkg/agent/profiler"
Then write the following code in main.go:
profiler.Start(profiler.Config{
ApplicationName: "simple.golang.app",
ServerAddress: "http://pyroscope:4040",
})
Among them, http://pyroscope can be replaced with a custom hostname, and then open the above URL to see the performance monitoring screen.
Used in Python and Ruby languages
# If using Python
$ pyroscope exec python manage.py runserver
# If using Ruby
$ pyroscope exec rails server
Experience
This set of tools is very convenient. Although you can use pprof to quickly find problems in the Go language, it is inevitable that you still need to manually find some performance bottlenecks. With this platform, all apps can be monitored. If you have any problems, you can quickly use Pyroscope to check which codes are wrong.
Author: Little Devil Original: http://t.cn/A6c0G3dm
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。