Using Subversion to Update Content with Scalr Scripts

I wanted to touch again on the use of Subversion (SVN) to populate the /var/www of app servers on Scalr.  Basically the issue is how to add your web content to a new instance once it has automagically launched a new instance due to high load.  So Scalr will launch another app role once the server reaches a load threshold you have previously set. So the issue is I can have the instance started, but once it has launched the /var/www needs to be populated for that server to be able to serve content via load balancer.

Scalr Scaling Settings

Scalr Scaling Settings

This is where SVN and Scalr Scripting come into play.  I keep all my site content in a SVN repo.  So I link to whatever production tag I want to be live at that time.  In order to get the directory populated I make a simple script to do an svn checkout of that tag to /var/www.  A simple bash script is added to do the checkout and is added to the “OnHostUp” option.  This way once the server sends its SNMP trap saying it is up the script will be executed.  This is also a helpful means of updating your servers to a newer build.  I DO NOT checkout the tag directly into /var/www instead I make a symlink to /var/svn where the tags are checked out.  So when it is time to roll out a new production tag I simply checkout the new tag to /var/svn and redo the symlink to point at new tag.  This way if there is an issue that was not forseen in the QA process I can roll back to known good tag by redoing symlink.  This is an easy but very effective way of using Scalr scripts and SVN to manage content loading on servers.

2 comments

  1. Hello!
    Very Interesting post! Thank you for such interesting resource!
    PS: Sorry for my bad english, I’v just started to learn this language ;)
    See you!
    Your, Raiul Baztepo

  2. Can’t you create and use a machine image (AMI) that already has the bare bones and simply NFS mount to S3 mounted /var/www/. That seems easier.

    But in either case, its yet another reason to avoid using a damn database for largely flat content. And, that is the complete ease of porting content from one server to another.

    I still don’t understand the need for SQL for content that is already structured by way of xml or pretty much flat. Urgh. Databases are like the automobiles of the computer world. Made necessary by poor system planning. And that one should be tm.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>