2026年3月21日

go net/http缺点和改进

摘要: go net/http在每次建立连接时,都会创建一个goroutine来处理,即一个连接绑定一个goroutine,在高并发情况消耗大量资源。 fasthttp在每次建立连接时,优先从工作池里面获取已有的处理对象,不够时再创建,即一个连接绑定一个goroutine。不同于go net/http库处理 阅读全文

posted @ 2026-03-21 17:18 王景迁 阅读(1) 评论(0) 推荐(0)

go http server优雅关闭Shutdown方法

摘要: go 1.24.0 用法 package main import ( "context" "log" "net/http" "os" "os/signal" "syscall" "time" ) func main() { mx := http.NewServeMux() mx.HandleFunc 阅读全文

posted @ 2026-03-21 15:49 王景迁 阅读(2) 评论(0) 推荐(0)

2026年3月20日

nginx配置总结

摘要: 开启debug日志 1. server里面增加error_log /var/log/nginx/debug.log debug;2. location里面增加不存在的测试后端proxy_pass http://172.17.0.3:8080;3. nginx -s reload 访问nginx ip 阅读全文

posted @ 2026-03-20 21:10 王景迁 阅读(1) 评论(0) 推荐(0)

k8s hostport

摘要: spec: containers: - image: nginx name: nginx ports: - containerPort: 80 hostPort: 8080 iptables增加dnat规则,完成主机端口8080到容器端口80的映射。 优点:固定转发到本节点pod。缺点:占用节点端口 阅读全文

posted @ 2026-03-20 20:30 王景迁 阅读(3) 评论(0) 推荐(0)

2026年3月7日

prometheus增加需要采集数据的pod

摘要: Prometheus serviceMonitorSelector ServiceMonitor(描述监控对象信息) matchLabels Service(k8s服务发现) Service+Deploy yaml定义 kind: Service apiVersion: v1 metadata: n 阅读全文

posted @ 2026-03-07 11:15 王景迁 阅读(1) 评论(0) 推荐(0)

2026年3月5日

go实现单机版限流

摘要: go get golang.org/x/time/rate package main import ( "log" "time" "golang.org/x/time/rate" ) func main() { // 创建一个每秒产生5个令牌,桶容量为10的限流器 log.Printf("调整前") 阅读全文

posted @ 2026-03-05 08:02 王景迁 阅读(4) 评论(0) 推荐(0)

平衡kube-apiserver流量

摘要: 问题现象 多个kube-apiserver,重启单个kube-apiserver,会导致请求集中到其他kube-apiserver上,重启的kube-apiserver几乎没有收到请求。 问题分析 重启kube-apiserver,client因连接断开而重连到其他kube-apiserver。cl 阅读全文

posted @ 2026-03-05 07:47 王景迁 阅读(5) 评论(0) 推荐(0)

2026年2月15日

adb命令总结

摘要: # 切root adb root # 通过ip+端口连接主机 adb connect ip:端口 # 进入主机 adb shell # 拷进文件 adb push xxx /root/ # 拷出文件 adb pull xxx ./ 阅读全文

posted @ 2026-02-15 11:01 王景迁 阅读(2) 评论(0) 推荐(0)

2025年12月25日

ping工具总结

摘要: # 指定网口,大写的i -I eth0 # 指定包长 -s 128 # 不分片 -M do 阅读全文

posted @ 2025-12-25 23:07 王景迁 阅读(4) 评论(0) 推荐(0)

2025年12月20日

docker拉取镜像支持http

摘要: docker默认使用https拉取镜像,无法通过http拉取镜像。创建或修改/etc/docker/daemon.json文件,增加insecure-registries字段。 { "insecure-registries" : ["镜像地址域名或者ip:port"] } 重启docker syst 阅读全文

posted @ 2025-12-20 07:03 王景迁 阅读(16) 评论(0) 推荐(0)

导航