2022年12月17日

MySQL字符集

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

posted @ 2022-12-17 09:35 王景迁 阅读(81) 评论(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 王景迁 阅读(128) 评论(0) 推荐(0) 编辑

2022年11月26日

Nginx超时检测主流程

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

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

2022年11月25日

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

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

posted @ 2022-11-25 08:45 王景迁 阅读(172) 评论(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 王景迁 阅读(31) 评论(0) 推荐(0) 编辑

2022年10月30日

Nginx源码编译并运行

摘要: 安装Nginx git clone https://github.com/nginx/nginx.git cd nginx git checkout release-1.22.1 ./auto/configure 如果报错the HTTP rewrite module requires the PC 阅读全文

posted @ 2022-10-30 08:47 王景迁 阅读(102) 评论(0) 推荐(0) 编辑

2022年10月29日

Nginx代理后端Tomcat

摘要: 拉取镜像并运行 docker pull nginx:1.23 docker pull tomcat:8 docker run -d nginx:1.23 docker run -d tomcat:8 修改Nginx配置 安装vim命令并备份 安装vim命令 apt-get update apt-ge 阅读全文

posted @ 2022-10-29 19:32 王景迁 阅读(461) 评论(0) 推荐(0) 编辑

2022年8月17日

Spring循环依赖问题

摘要: Spring Boot版本 pom.xml <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.5.2</version 阅读全文

posted @ 2022-08-17 22:45 王景迁 阅读(151) 评论(0) 推荐(0) 编辑

2022年8月14日

Spring IoC常用注解手写实现

摘要: 执行流程 1. 初始化Spring容器时传入配置类,通过配置类的@ComponentScan注解告知Spring需要扫描的包路径,不在扫描包路径下的@Component等注解修饰的Bean不会被IoC容器创建;2. 从工程根目录/target/classes中获取全类名,使用类加载器加载全类名得到c 阅读全文

posted @ 2022-08-14 20:05 王景迁 阅读(53) 评论(0) 推荐(0) 编辑

2022年7月23日

go Mutex源码分析

摘要: 使用Mutex 互斥锁Mutex提供了两个函数Lock和Unlock。 func(m *Mutex) Lock() func(m *Mutex) Unlock() 源码分析 Mutex实现演变过程 初版 // 互斥锁的结构,包含两个字段 type Mutex struct { key int32 / 阅读全文

posted @ 2022-07-23 07:34 王景迁 阅读(67) 评论(0) 推荐(0) 编辑

导航