Skip to content

Instantly share code, notes, and snippets.

@zhouchangxun
zhouchangxun / loadbalancer.py
Created July 5, 2018 08:06
a simple loadbalancer implemention with python.
import sys
import socket
import select
import random
from itertools import cycle
# dumb netcat server, short tcp connection
# $ ~ while true ; do nc -l 8888 < server1.html; done
# $ ~ while true ; do nc -l 9999 < server2.html; done
SERVER_POOL = [('10.157.0.238', 8888)]