2023年1月21日

go Channel源码分析

摘要: 理论基础 不要通过共享内存来通信,要通过通信来共享内存。 特点 通道分为非缓冲通道和缓冲通道。单向通道由双向通道转换而来,但是单向通道不能转换回双向通道。 通过make来初始化一个chan,未初始化的chan的零值是nil。 接收数据时,返回两个值。第一个值是返回的chan中的元素,第二个值是boo 阅读全文

posted @ 2023-01-21 09:59 王景迁 阅读(111) 评论(0) 推荐(0)

2023年1月14日

获取kubelet管理的容器

摘要: k8s 1.15 pkg/kubelet/kuberuntime/kuberuntime_container.gogetKubeletContainers方法获取kubelet管理的所有业务容器(true表示包括退出的和死亡的容器,用于GC)补充代码 kubelet日志 容器情况 启动一个基于Ngi 阅读全文

posted @ 2023-01-14 14:40 王景迁 阅读(151) 评论(0) 推荐(0)

2023年1月8日

curl命令总结

摘要: 打印curl总耗时 curl -w " %{time_total}s" https://www.baidu.com 输出出口公网ip curl -s myip.ipip.net 输出服务端证书过期时间 curl -v https://www.baidu.com 2>&1 | grep "expire 阅读全文

posted @ 2023-01-08 19:34 王景迁 阅读(127) 评论(0) 推荐(0)

2023年1月1日

arthas输出方法的请求参数和返回值

摘要: 运行jar包 java -jar demo-0.0.1-SNAPSHOT.jar 下载Arthas并启动 curl -O https://alibaba.github.io/arthas/arthas-boot.jar && java -Dfile.encoding=UTF-8 -jar artha 阅读全文

posted @ 2023-01-01 15:54 王景迁 阅读(542) 评论(0) 推荐(0)

2022年12月17日

GC测试

摘要: 基于SpringBoot来开发接口并编译运行 代码 UserController类 package com.wjq.demo; import org.springframework.web.bind.annotation.RequestMapping; import org.springframew 阅读全文

posted @ 2022-12-17 14:37 王景迁 阅读(164) 评论(0) 推荐(0)

MySQL字符集

摘要: 查看字符集 show charset like 'utf8%'; 每种字符集有多种比较规则,有默认的比较规则。utf8:一个字符最多占用3个字节,默认比较规则是utf8_general_ci。utf8mb4:一个字符最多占用4个字节,默认比较规则是utf8mb4_general_ci。比较规则中,c 阅读全文

posted @ 2022-12-17 09:35 王景迁 阅读(127) 评论(0) 推荐(0)

2022年12月7日

Nginx加权轮询负载均衡

摘要: Nginx 1.22.1 默认负载均衡策略 Nginx默认采用加权轮询策略。 src/http/ngx_http_upstream.c中ngx_http_upstream_init_main_conf函数 省略 for (i = 0; i < umcf->upstreams.nelts; i++) 阅读全文

posted @ 2022-12-07 22:11 王景迁 阅读(225) 评论(0) 推荐(0)

2022年11月26日

Nginx超时检测主流程

摘要: 请求不能在指定时间内完成时触发Nginx的超时机制。定时器由红黑树实现,红黑树中最左边的节点代表最有可能的超时事件。 timer_resolution Nginx提供2种超时检测方案:1. 设置定时器,每过固定间隔时间进行超时检测扫描,缺点是超时事件可能得不到及时处理。2. 等待当前时间与最有可能的 阅读全文

posted @ 2022-11-26 23:00 王景迁 阅读(521) 评论(0) 推荐(0)

2022年11月25日

Nginx在日志中输出代码文件名和行号

摘要: Nginx源码版本是1.22.1 error.log函数:ngx_log_error_core 对应日志前半部分 对应日志后半部分 输出日志时打印文件名和行号 效果 阅读全文

posted @ 2022-11-25 08:45 王景迁 阅读(259) 评论(0) 推荐(0)

2022年11月20日

基于close channel广播机制来实现TimingWheel

摘要: 基于1个Ticker+1个环形数组+多个channel,实现了多个任务在指定最大超时时间范围内的一次性超时通知机制。 代码 package main import ( "fmt" "sync" "time" ) type TimingWheel struct { sync.Mutex interva 阅读全文

posted @ 2022-11-20 20:33 王景迁 阅读(68) 评论(0) 推荐(0)

导航