当前位置:网站首页>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)

基于verilog的CRC校验(汇总)

攻防演练丨赛宁红方管控平台走进广东三地 助力数字政府网络安全建设

C# 中的Async 和 Await 的用法详解

The 2nd activity of the TOGAF10 Standard Reading Club continues wonderfully, and the highlights will be reviewed!

C#控件StatusStrip使用

架构实战营|模块8

Anaconda安装labelImg图像标注软件

ERROR 1819 (HY000) Your password does not satisfy the current policy requirements

【OpenCV】-边缘检测汇总示例
随机推荐
alert(1) (haozi.me)靶场练习
五种数据提交方式的优化
使用openssl命令生成证书和对应的私钥,私钥签名,公钥验签
硬盘分区,拓展C盘,不重装系统,不重装D盘软件的全教程。
攻防演练丨赛宁红方管控平台走进广东三地 助力数字政府网络安全建设
Talk about the message display mechanism on the SAP product UI
Encapsulation of conversion between Json and objects (Gson)
AMBA APB学习记录(AMBA 2.0)
365-day challenge LeetCode1000 questions - Day 044 Maximum element in the layer and level traversal
golang-gin-优雅重启
Adding data nodes and decommissioning data nodes in the cluster
Build a Valentine's Day confession website (super detailed process, package teaching package)
亲测可用!!!WPF中遍历整个窗口的所有TextBox组件,对每个输入框做非空判断。
docker部署完mysql无法连接
EXCEL如何快速拆分合并单元格数据
C# 中的Async 和 Await 的用法详解
Banyan Tree Loan GPU Hardware Architecture
深圳某游戏研发公司每个工位都装监控,网友:堪比“坐牢”!
求一份常见Oracle故障模拟场景
golang-gin-pprof-使用以及安全问题