博文
在中小型公司做 SRE 是怎样一种体验
· ☕ 6 分钟
1. 两年前选了一条不一样的路 现在回顾,2021 年应该是近些年武汉互联网打工人跳槽的黄金年份。疫情过去,我们对未来充满期待;货币政策宽松,公司对市场前景满怀信心。 在这个背景下,当时一批做 Kubernetes 开源产品的同事纷纷跳槽,去云厂商继续做云基础设施。凭借过

我的 Restful API 规范
· ☕ 2 分钟
主要用来规范自己写的 API,也是为了让 LLM 更好理解我的 API。 1. Domain 尽量单独使用一个域名,例如 api.example.com 。 2. Path 统一使用小写字母。 不用包含 /api 前缀。 不要包含扩展名。 / 不要出现在末尾。 对于 Restful API,/ 用来划分资源层级,末尾的 / 会导致混淆。 使用带版本的路径 /v1 。

OpenAI Vs Azure OpenAI API
· ☕ 2 分钟
由于定价和限制会随时间变化,本文仅供撰写当前时间参考。 1. 术语 RPM (requests per minute) 每分钟请求次数 RPD (requests per day) 每天请求次数 TPM (tokens per minute) 每分钟 Token 数 TPD (tokens per day), 每天 Token 数 在 https://platform.openai.com/tokenizer 可以根据文本查询对应的 token 数。在 https://github.com/openai/tiktoken/blob/main/tiktoken/model.py 可以发现 text-embedding-ada-002 与 gpt-3.5、gpt-4 的词表都是 cl100k_bas

Istio 中的 EnvoyFilter 配置
· ☕ 3 分钟
1. EnvoyFilter 是什么 EnvoyFilter 是 Istio 的 CRD 资源,它允许用户修改 Envoy 的配置,以满足用户针对不同场景的定制需求。 1 2 3 4 5 6 7 8 9 kubectl get envoyfilter -A NAMESPACE NAME AGE istio-system add-request-id-into-ingressgateway 54d istio-system compression-gzip 18d istio-system custom-access-log 3d istio-system ingressgateway-settings 52d istio-system preserve-request-header-us-test-ingress-gateway 95d istio-system preserve-x-request-id 54d 通常在使用 istio 时,或多或少都会用到一些 EnvoyFilter。 EnvoyFilter 提供的功能是基于 Envoy 已有的内

容器下的 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 进行