客户端 address 不足

net.ipv4.ip_local_port_range = 1024 65000

net.ipv4.ip_local_reserved_ports=8080,8081

net.core.somaxconn = 65535

net.ipv4.tcp_max_syn_backlog = 65535

复制代码
func initTransport() {
	// 创建自定义 Transport
	transport = &http.Transport{
		MaxIdleConns:        config.conns * 2, // 创建 Transport 时设置最大空闲连接数
		MaxIdleConnsPerHost: config.conns,     // 创建 Transport 时设置每个主机最大空闲连接数
		IdleConnTimeout:     90 * time.Second, // 创建 Transport 时设置空闲连接超时
	}
	customDialer := &net.Dialer{
		Timeout:   30 * time.Second,
		KeepAlive: 30 * time.Second,
		Control: func(network, address string, c syscall.RawConn) error {
			var operr error
			err := c.Control(func(fd uintptr) {
				// 设置 SO_LINGER 为0,实现优雅关闭
				linger := &unix.Linger{
					Onoff:  1,
					Linger: 0,
				}
				operr = unix.SetsockoptLinger(int(fd), unix.SOL_SOCKET, unix.SO_LINGER, linger)
				if operr != nil {
					return
				}

				// 设置 IP_BIND_ADDRESS_NO_PORT (Linux 4.2+)
				// 这个选项允许绑定地址时不预留端口
				operr = unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_BIND_ADDRESS_NO_PORT, 1)
			})

			if err != nil {
				return err
			}
			return operr
		},
	}

	// 更新 transport 使用自定义 dialer
	transport.DialContext = customDialer.DialContext
}

backlog

rlimits

queues

232 echo ff > /sys/class/net/ens3/queues/rx-0/rps_cpus

233 echo ff > /sys/class/net/ens3/queues/rx-0/rps_flow_cnt

234 ls /sys/class/net/ens3/queues/

235 echo 4096 > /sys/class/net/ens3/queues/rx-0/rps_flow_cnt

238 echo 32768 > /sys/class/net/ens3/queues/rx-0/rps_flow_cnt

相关推荐
徐小黑ACG3 小时前
nginx配置文件
linux·服务器·nginx
新时代牛马3 小时前
Linux VFS 完整篇:从path_openat、dentry/inode 到page cache 与挂载排障
linux·运维·服务器
java_logo3 小时前
Docker 部署 Rocky Linux:轻松搭建 RHEL 兼容企业级基础镜像平台
linux·docker·容器·rocky linux·基础镜像·轩辕镜像·rhel 兼容
拂拉氏4 小时前
【知识讲解】 Linux虚拟地址空间认识
linux·虚拟地址空间
新时代牛马5 小时前
Linux 驱动中断与定时完整篇:从 request_threaded_irq 到hrtimer 选型与排障
linux·运维·服务器
分支预测失败8 小时前
RISC-V 核间中断 IPI 实战:从 MSIP 寄存器到 IMSIC 消息投递
linux·后端
GeW8 小时前
RHCE考试避坑指南"90%考生容易忽略的细节
linux
键盘会跳舞9 小时前
【C++多线程】死锁诊断工具实战:从 Windows 到 Linux 的全链路排查
linux·c++·windows·死锁
拂拉氏10 小时前
【知识讲解】 Linux环境变量的认识与使用
linux·环境变量
zhangrelay10 小时前
答疑-是否软件源问题都必须更换为国内呢-
linux·笔记·学习·ubuntu·ros2