性能优化
如何将 Kubernetes 中的 Events 分离到独立的 Etcd
· ☕ 1 分钟
对原 etcd 所在磁盘压力减少 5% 以下,风险系数很低,集群没有异常 1. 部署 Events Etcd 集群 Events 对一致性要求低于主 Etcd,建议部署 3 节点 集群。磁盘建议使用 SSD,数据目录与主 Etcd 分开。 采用静态 Pod 方式部署,kubelet 会自动管理 Etcd 进程,与 kube-apiserver 的部署方式一致。 1.1 集群部

容器下的 Go 应用程序优化
· ☕ 2 分钟
1. 内存对齐 结构体内字段,从大到小排列 减少内存占用 安装 fieldalignment 工具 1 go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest 分析并修复内存对齐 1 2 3 4 5 6 7 8 9 fieldalignment -fix ./... /Users/shaowenchen/Code/app/config/config.go:136:14: struct with 32 pointer bytes could be 24 /Users/shaowenchen/Code/app/config/config.go:150:11: struct of size 96 could be 88 /Users/shaowenchen/Code/app/config/config.go:166:14: struct of size 152 could be 144 /Users/shaowenchen/Code/app/config/config.go:194:12: struct with 80 pointer bytes could be 72 /Users/shaowenchen/Code/app/config/config.go:209:12: struct with 56 pointer bytes could be 40 /Users/shaowenchen/Code/app/dao/gormx/gorm.go:12:13: struct with 16 pointer bytes could be 8 /Users/shaowenchen/Code/app/dao/gormx/entity/cluster.go:5:14: struct with 128 pointer bytes could be 104 查看 fieldalignment 进行

优化 Tekton 执行克隆任务慢问题,节省约 30 秒
· ☕ 8 分钟
1. 现象 - Tekton 克隆代码任务慢 在执行克隆任务时,Tekton 很费时间,多仓库下一般都需要 2 分 30 秒左右。如下图: 仅克隆的流水线就需要执行 2 分钟 16 秒,而克隆脚本实际上仅执行 1-3 秒。其中大部分时间花在了哪里?能不能减少?这是本篇主要想讨论的问题。 2. 分析克