Arc Forumnew | comments | leaders | submitlogin
Arc Cluster Implications
6 points by lojic 6115 days ago | 5 comments
Has anyone tried running multiple Arc processes to serve a web app? I'm not very familiar with a continuation based approach, but it would seem that it would necessitate using session affinity to route an HTTP request to the proper Arc process containing the continuation.

I use Apache with mod_proxy_balancer currently, and it does support "sticky sessions", so I think that would allow Apache to sit in front of multiple Arc processes and ensure that all requests from the same browser are routed to a single Arc process.

Any thoughts or experiences?



6 points by lojic 6115 days ago | link

Here's an Apache virtual host config that allows Apache to sit in front of an Arc web server via mod_proxy_balancer. I just took my typical Rails config and tweaked it slightly. You need to have the mod_proxy_balancer module loaded.

I've setup a pseudo IP of 10.0.0.71 and put www.lojic.com in my /etc/hosts file with that IP for testing. I'll try 2 Arc processes with sticky sessions later, but for one server the following works fine. If you don't have a bunch of other virtual hosts active, you could probably just use 127.0.0.1 w/o setting up the pseudo IP.

Having Apache sit in front of the Arc server allows using SSL easily, serving up static files directly for extra speed, etc.

  <VirtualHost 10.0.0.71:80>
    ServerName www.lojic.com
    ServerAlias lojic.com
    DocumentRoot /home/brian/software/arc/arc2

    <Directory /home/brian/software/arc/arc2 >
      Options FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>

    # Configure cluster
    <Proxy balancer://lojic_cluster>
      BalancerMember http://127.0.0.1:8080
    </Proxy>

    RewriteEngine On

    # Prevent access to .svn directories
    RewriteRule ^(.*/)?\.svn/ - [F,L]
    ErrorDocument 403 "Access Forbidden"

    # Redirect all non-static requests to cluster
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
    RewriteRule ^/(.*)$ balancer://lojic_cluster%{REQUEST_URI} [P,QSA,L]

    # Deflate
    AddOutputFilterByType DEFLATE text/html text/plain text/xml
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    ErrorLog logs/www.lojic.com-error_log
    CustomLog logs/www.lojic.com-access_log combined
  </VirtualHost>

-----

1 point by utx00 6114 days ago | link

Could one cluster news.arc as is? It persists everything in files. Could that be a problem whilst saving an item that's modified by two users at the same time? (If the users happen to be in different runtime instances that is). I guess I should just try it, but any feedback will be appreciated.

Thanks.

-ut

-----

2 points by lojic 6114 days ago | link

You've asked a good question. pg could probably answer off the top of his head; otherwise, it may take some digging into the source. If I had to guess, I'd say that you'd have problems clustering it as is, but that's an easy guess, because clustering usually has problems :)

Ruby on Rails (and many others) use a shared nothing approach, so each node in the cluster has to read everything it needs from the database (or other store) for each request. It's very easy to scale until you overload your database, but not very efficient.

Another approach is to have the nodes in the cluster communicate information amongst themselves.

I would think using something like memcached would be pretty effective in helping to cluster news.yc

-----

1 point by utx00 6114 days ago | link

Thanks for the reply. I played with it a little bit, and I think there could be some contention. If two users created kids for the same item, the kids entry in the 'item template has to be updated to reflect the two new articles (ie, the item has to be serialized again). If the users are on different instances I believe you could lose information ... I think :)

Also, it doesn't seem save-table is safe in the sense that it just overwrites the file that's already there (as opposed to writing it with a different name, and just 'mv' over which is supposedly atomic).

Anyhoo ....

-----

2 points by utx00 6114 days ago | link

Also, take a look at couchdb if you're interested in such things.

-ut

-----