当前位置:网站首页>Golang - gin - pprof - use and safety
Golang - gin - pprof - use and safety
2022-07-31 13:08:00 【SakuraKizuna】
pprof is a performance analysis tool provided by golang
You can call
project code excerpts by referencing github.com/gin-contrib/pprof
directly:
//Performance tuning monitoring TODO Gin hides itself, to be optimizedauthStr := fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(config.ProducerUsername+":"+config.ProducerPassword)))pprofGroup := r.Group("/producer", func(c *gin.Context) {auth := c.Request.Header.Get("Authorization")if auth != authStr {c.Header("www-Authenticate", "Basic")c.AbortWithStatus(http.StatusUnauthorized)return}c.Next()})pprof.RouteRegister(pprofGroup, "flowerxxxxx_pprof")
The pprof carried by the Gin framework can be called directly, but it will cause exposure problems in the production environment, resulting in the /debug/pprof interface being exposed to the public network.
We register the interface into a new routing group, and add the Basic ID to the base64 of the (account + colon + password) to trigger the protection mechanism of entering the account and password for access.
Project (small and medium-sized) pprof analysis overview, you can check whether there is a goroutine deadlock or abnormal CPU usage.
边栏推荐
- ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)解决办法
- PHP序列化:eval
- Optimization of five data submission methods
- 查看Mysql数据库版本
- PyQt5快速开发与实战 10.1 获取城市天气预报
- 2022年最新重庆建筑安全员模拟题库及答案
- Architecture Camp | Module 8
- [CPU Design Practice] Simple Pipeline CPU Design
- 纷享销客罗旭对话元气森林黄晓枫:零售数字化的终点不是创新,而是数据
- C#控件 ToolStripProgressBar 用法
猜你喜欢
随机推荐
Character Functions and String Functions
Exploring Plain Vision Transformer Backbones for Object Detection Paper Reading Notes
分布式锁有哪些,怎么实现(分布式锁的三种实现的对比)
基于去噪自编码器的故障隔离与识别方法
Use IN List Population in Your JDBC Application to Avoid Cursor Cache Contention Issues
生产力工具和插件
计算机复试面试问题(计算机面试常见问题)
ASM module in SAP Ecommerce Cloud Spartacus UI and Accelerator UI
SAP message TK 248 solved
滑窗法切分数据
Markdown编辑器语法
分布式监视 Zabbix 和 Prometheus 到底怎么选?千万别用错了!
Build a Valentine's Day confession website (super detailed process, package teaching package)
PyQt5 rapid development and actual combat 10.1 Get city weather forecast
NameNode (NN) 和SecondaryNameNode (2NN)工作机制
Error EPERM operation not permitted, mkdir ‘Dsoftwarenodejsnode_cache_cacach两种解决办法
列表页优化思路
C#获得网卡信息 NetworkInterface IPInterfaceProperties
Cognitive-exercise rehabilitation medical robot application design
0X7FFFFFFF,0X80000000「建议收藏」