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

边栏推荐
猜你喜欢

IDEA的database使用教程(使用mysql数据库)

【CPU设计实战】简单流水线CPU设计

ECCV2022:在Transformer上进行递归,不增参数,计算量还少!

centos7安装mysql5.7步骤(图解版)

一文吃透哈希表

How does the SAP ABAP OData service support the $filter (filter) operation trial version

Edge Cloud Explained in Simple Depth | 4. Lifecycle Management

365天挑战LeetCode1000题——Day 044 最大层内元素和 层次遍历

log4j2的使用

基于verilog的CRC校验(汇总)
随机推荐
亲测可用!!!WPF中遍历整个窗口的所有TextBox组件,对每个输入框做非空判断。
Exploring Plain Vision Transformer Backbones for Object Detection Paper Reading Notes
聊聊 SAP 产品 UI 上的消息显示机制
纷享销客罗旭对话元气森林黄晓枫:零售数字化的终点不是创新,而是数据
C# List用法 List介绍
手撕Verilog PWM呼吸灯
docker部署完mysql无法连接
SAP 电商云 Spartacus UI 和 Accelerator UI 里的 ASM 模块
PyQt5快速开发与实战 9.7 UI层的自动化测试
ASM module in SAP Ecommerce Cloud Spartacus UI and Accelerator UI
系统集成项目管理工程师(软考中级)知识点总结【挣值分析】【关键路径】
CentOS7 installation MySQL graphic detailed tutorial
ADS与C#通信
SAP 电商云 Spartacus SSR Optimization Engine 几处 timeout 的执行顺序
全局平均池化层替代全连接层(最大池化和平均池化的区别)
Introduction to using NPM
ASM外部冗余是否可以替换磁盘
查看Mysql数据库版本
关于MySQL主从复制的数据同步延迟问题
Verilog——基于FPGA的贪吃蛇游戏(VGA显示)