Created
October 14, 2012 01:50
-
-
Save oubiwann/3886959 to your computer and use it in GitHub Desktop.
Native LoadBalancing for Twisted Apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.web import static, server | |
from twisted.application import service, internet | |
application = service.Application("Demo Web Server") | |
web = server.Site('/home/oubiwann/public_html') | |
service = internet.TCPServer(7001, web) | |
service.setServiceParent(application) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.application import service | |
from txlb import manager | |
from txlb.model import HostMapper | |
from txlb.schedulers import leastc | |
from txlb.application.service import LoadBalancedService | |
proxyServices = [ | |
HostMapper(proxy='127.0.0.1:8080', lbType=leastc, host='host1', | |
address='127.0.0.1:7001'), | |
HostMapper(proxy='127.0.0.1:8080', lbType=leastc, host='host2', | |
address='127.0.0.1:7002'), | |
HostMapper(proxy='127.0.0.1:8080', lbType=leastc, host='host3', | |
address='127.0.0.1:7003'), | |
] | |
application = service.Application('Demo LB Service') | |
pm = manager.proxyManagerFactory(proxyServices) | |
lbs = LoadBalancedService(pm) | |
lbs.setServiceParent(application) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment