一个简单、快速、纯粹的python负载平衡器
PumpkinLB的Python项目详细描述
pumpkinlb是一个快速的多进程tcp负载均衡器/端口转发器,与linux、cygwin和windows环境兼容。
正在处理
pumpkinlb在运行它的机器的本地端口上侦听请求,并将它们分发给任意数量的工人。
您可以使用它在不同的服务器上非常快速地设置一个负载平衡器,例如从1个入口点到5个不同的apache工作器。
每个传入端口都由一个不同的进程等待,而每个连接又是另一个进程,因此即使在重载情况下,它的性能也非常好。
请求通常在不同的工作人员之间进行循环处理。 如果请求在后端工作进程上失败,将在另一个随机工作进程上重试,直到成功为止,并将记录一条消息。
用法
通过运行pumpkinlb.py[cfgfile]执行
其中[cfgfile]是配置文件的路径。包括一个示例“example.cfg”。
config节
配置文件被分为几个部分,可由[$sectionname]定义,后面是格式为key=value的变量。
[选项]
预处理工人=0/1-默认值1
Any workers defined with a hostname will be evaluated at the time the config is read.
This is preferable as it saves a DNS trip for every request, and should be enabled
unless your DNS is likely to change and you want the workers to match the change.
缓冲区大小=n-默认4096
Default read/write buffer size (in bytes) used on socket operations. 4096 is a good default for most, but you may be able to tune better depending on your application.
[映射]
localaddr:inport=worker1:端口,worker2:端口…
Listen on interface defined by “localaddr” on port “inport”. Farm out to worker addresses and ports.
Ex: 192.168.1.100:80=10.10.0.1:5900,10.10.0.2:5900
inport=worker1:端口,worker2:端口…
Listen on all interfaces on port “inport”, and farm out to worker addresses with given ports.
Ex: 80=10.10.0.1:5900,10.10.0.2:5900
因此,在端口80本地主机上侦听并将其分配到本地子网上的3个apache服务器的示例:
80=192.168.1.100:80,192.168.1.101:80,192.168.1.102:80
正常关机
发送sigterm、sigint或按control+c将正常关闭(它将等待6秒以完成任何活动请求,然后终止)。