[Seaside] How to develop and deploy
Ramon Leon
ramon.leon at allresnet.com
Wed Jun 25 17:40:47 UTC 2008
> At the time Ramon blogged about Seaside Deployment, he had
> used Apache 2 and probably it didn't have out of the box Load
> Balancing. That was the exact reason why he had used HAProxy.
Correct, I wrote that before mod_proxy_balancer existed, I really need to
update the article or write another one.
These days I use mod_proxy_balancer to do the load balancing with something
like this config...
<VirtualHost *:80>
ServerName www.yoursite.com
DocumentRoot /var/www/www.yoursite.com
RewriteEngine On
ProxyRequests Off
ProxyPreserveHost On
UseCanonicalName Off
ExpiresActive on
ExpiresByType text/css A864000
ExpiresByType text/javascript A864000
ExpiresByType application/x-javascript A864000
ExpiresByType image/gif A864000
FileETag none
# http compression
DeflateCompressionLevel 9
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml
application/xml application/xhtml+xml text/javascript text/css
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Let apache serve static files NOW
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} -f
RewriteRule (.*) $1 [L]
#proxy remaining requests to a seaside cluster
ProxyPass /yourApp balancer://seaside_cluster/seaside/yourApp
lbmethod=byrequests stickysession=server
ProxyPass / balancer://seaside_cluster/ lbmethod=byrequests
stickysession=server
ProxyPassReverse / balancer://seaside_cluster/
<Proxy balancer://seaside_cluster>
BalancerMember http://localhost:3001 route=yourApp3001
BalancerMember http://localhost:3002 route=yourApp3002
BalancerMember http://localhost:3003 route=yourApp3003
BalancerMember http://localhost:3004 route=yourApp3004
BalancerMember http://localhost:3005 route=yourApp3005
BalancerMember http://localhost:3006 route=yourApp3006
BalancerMember http://localhost:3007 route=yourApp3007
BalancerMember http://localhost:3008 route=yourApp3008
BalancerMember http://localhost:3009 route=yourApp3009
BalancerMember http://localhost:3010 route=yourApp3010
</Proxy>
</VirtualHost>
And then in my seaside app on the #initialRequest: I set the load balance
cookie using the following...
setServerCookie
| port |
self session currentRequest cookies
at: #server
ifAbsent:
[ port := (HttpService allInstances select: [ :each
| each isRunning ]) first portNumber.
self session redirectWithCookie: (WACookie
key: #server
value: 'seaside.yourApp' , port
asString) ]
I'm very happy with this setup and happily ditched HAProxy a while back.
Ramon Leon
http://onsmalltalk.com
More information about the seaside
mailing list