摘要: 针对多进程负载均衡无法保持会话的问题,提出一个基于epoll机制的内核级高效解决方法。对于每个新建立的连接,在epoll的通知机制中使用源地址哈希算法,由epoll通知哈希选出的进程接收此连接,期望通过为同一个IP地址的请求选择同一个负载均衡服务进程,保证该进程依据自身记录的会话信息将同一个客户的请求转发给同一个后端服务器。此外,通过分析多队列网卡的特性,给出维持收包发包中断、软中断、协议栈处理、用户态处理都在同一个核上的优化方法,以提高cache性能。实验结果表明,该方法能解决基于epoll的多进程负载均衡服务器的会话保持问题,并且在多核处理器多队列网卡环境下通过优化使cps提高12%,数据吞吐量提高4.6%。
关键词:
多队列网卡,
多核,
epoll机制,
源地址哈希,
会话保持
Abstract: This paper proposes an efficient method at the kernel level to solve the problem how to maintain the session in multi-process load balancing. In the wakeup-callback mechanism of epoll, this method wakes up a certain service process selectively to process the packet and accept this connection according to the source address hash algorithm. It hopes that the requests sharing the same IP address are responded by the same service process. So the requests from the same client are forwarding to the same backend server according to the session information kept in this load balancing process. This paper also devotes to optimize the performance of the procedure of receiving and sending packets. It is an intended way to keep this whole process on the same CPU core to reduce the refresh rate of the CPU cache. Experimental results reflect that the method in this paper achieves the objective to keep the session and also increases cps by 12% and throughput by 4.6% which is based on multi-queue NIC and multi-core processor.
Key words:
multi-queue network card,
multi-core,
epoll mechanism,
source address hash,
session-persistence
中图分类号: