Hi Tony, Hmm.. my benchmarking with 'ab' didn't show any significant slowdown. YMMV! It's easy enough to try, why not find out? The rewrite module keeps the the program running and just sends to stdin and reads from stdout. You could write it in "C" if it turns out to be a bottleneck. I think however that if you have poor python performance, then Zope is going to be a much bigger problem than my little script. :-( -steve On Monday, September 3, 2001, at 03:27 PM, Tony McDonald wrote:
On 2/9/01 9:41 pm, "Steve Spicklemire" <steve@spvi.com> wrote:
Hi Tony,
I've achieved reasonable (though somewhat naive) ZEO load distribution (I won't call it balancing) this way:
In Apache:
01 <VirtualHost 192.xxx.yyy.zzz:80> 02 ServerAdmin steve@spvi.com 03 ServerName test_balance.spvi.net 04 ErrorLog /var/log/spvi.net-error_log 05 CustomLog /var/log/spvi.net-access_log common 06 07 08 RewriteEngine on 09 #RewriteLog /var/log/rewrite.log 10 #RewriteLogLevel 10 11 RewriteMap balance_load_ext prg:/usr/local/share/apache/conf/balance_load_ext.py 12 RewriteRule ^/(.*)$ ${balance_load_ext:$1} [P,L] 13 14 </VirtualHost>
where balance_load_ext.py is:
01 #!/usr/bin/env python 02 03 count = 0 04 05 import sys 06 import string 07 08 def translate(data): 09 global count 10 count = (count + 1) % 3 11 return "http://www%i.spvi.net:14080/VirtualHostBase/http/test_balance.spvi.net: 80/ %s" % (count, data) 12 13 14 if __name__=='__main__': 15 while 1: 16 data = string.strip(sys.stdin.readline()) 17 if not data: 18 break 19 print translate(data) 20 sys.stdout.flush()
This distributes load between three machines, using Apache only. You could make the python script smarter to achieve something closer to real load balancing with a little effort.
-steve
That's an interesting method Steve (at least it's in Python and I can understand it). Thing is that the poor python performance on our solaris hardware is the driving force behind me trying to use ZEO!.
Wouldn't having a python script sitting in front of every request slow things down a fair bit?
Cheers for the info though, Tone. -- Dr Tony McDonald, Assistant Director, FMCC, http://www.fmcc.org.uk/ The Medical School, Newcastle University Tel: +44 191 243 6140 A Zope list for UK HE/FE http://www.fmcc.org.uk/mailman/listinfo/zope