Getting started with Rapture ---------------------------- Today, Propensive are announcing a limited alpha release of Rapture, a Scala-based cloud platform we first announced at the London Scala eXchange in June. Rapture should run on most Linux distributions straight out-of-the-box, and requires only a 5KB download, Perl and Curl to run. Support for other operating systems will follow later. You will also require an access key to use Rapture. As this is only a limited alpha release, I will be emailing out access codes to those users we've promised early access to. If we've forgotten to include you in the initial release, please tweet me (@propensive) and I'll get back to you. First of all, download the Rapture client, rap, and change its permissions to make it executable: wget http://www.propensive.com/downloads/rap chmod +x rap You will probably want to add it to your path. You can check it's working by running rap help which should show a selection of commands. If at any point you need help on a particular Rapture command, rap -h should provide an explanation. You should receive an access key which looks like a random string of characters, for example aMpRB09GSIqaRAuQpcAm4G The Rapture client looks for the environment variable RAPTURE_USER to identify users, so export the access key as this environment variable, or use your operating system's preferred system for managing these. export RAPTURE_USER='aMpRB09GSIqaRAuQpcAm4G' You are now ready to start using Rapture. Brief walkthrough of features ----------------------------- Let's start by creating a new project, called 'helloworld'. I'll tell you now it's not going to be complicated. mkdir helloworld cd helloworld rap project --init helloworld This will initialize a new project in the 'helloworld' directory. We are going to build a cloudlet to deploy to Rapture which displays a simple "Hello World!" message in a web browser, so let's write some code to do this. Create a src folder, and edit the file hello.scala using your favourite editor: mkdir src vi src/hello.scala The contents of hello.scala will be as follows: - - - - - - - - - - - - - - package com.example.helloworld import rapture.http._ import rapture.io._ class Main extends Cloudlet { handle { case Path(^ / "hello") & r => "Hello World!" } } - - - - - - - - - - - - - - Save this file, and from the project directory, compile it using: rap compile This will first analyse your program's dependencies and then run the Scala compiler on your code. If everything was successful, you should receive a message confirming this. If not, then you will see the output from the compiler. We imported two packages, rapture.http and rapture.io, and Rapture will resolve these to a build configuration which provides the classpath necessary to perform the compilation and run the application. To see the build configuration, run rap config This shows the fully-resolved dependencies of your cloudlet. Rapture doesn't currently know about many third-party dependencies. The intention is to add these over the course of the next few weeks so that the wealth of Java libraries is available to Rapture users. If the compilation was successful, then you can also view a list of successful builds of your software using rap build But let's stop messing around and get the show on the road! To deploy your cloudlet, run rap deploy This will deploy your cloudlet to the first-available cloud node in a couple of seconds. We haven't arranged for it to use a particular domain name, so it will be available by default at http://helloworld..accounts.propensive.com/ Check this by pointing your browser at http://helloworld..accounts.propensive.com/hello Your browser should say "Hello World!", if everything went to plan. To see where your cloudlet is running, run rap node and you should see a list with a single entry for the name of the node it's running on, along with its IP address and details such as its load average. So, you've got your first application running! Although it's not a complicated application, let's pretend that it's going to be under heavy load, so we want to make sure that there will always be two cloud nodes running it. We're going to define an autoscaling function for the cloudlet. Normally we would want to write a scale method which takes into account the load averages of each of the nodes, but here we're just going to fix it at two nodes. Change the source code to: - - - - - - - - - - - - - - package com.example.helloworld import rapture.http._ import rapture.io._ class Main extends Cloudlet { override def scale(xs : List[(Double, Double, Double)]) = 2 handle { case Path(^ / "hello") & r => "Hello World! from "+nodeName } } - - - - - - - - - - - - - - then recompile and redeploy: rap compile rap deploy -R This will spin down the node running the old version of the cloudlet, and create a new deployment. When it's ready, it will then scale up to two nodes. If you return to http://helloworld..accounts.propensive.com/hello and refresh a few times, you should find that, using round-robin DNS, responses will be served by different nodes on the cloud. One thing to be wary of is overzealous caching of DNS records: Unfortunately, DNS wasn't designed for quite such frequent updates as you might need during development, so you might have to be patient to appreciate the two tests above. You can always check individual nodes using the names listed by the 'rap node' command by going to: http://.node.propensive.com/ Next Steps ---------- So, that's it! Hopefully that was quite easy. I would say "go wild", but this is an alpha release, and it comes with no guarantees except that it is definitely not production-ready yet. Over the next week, I'll be redeveloping the Propensive website with more information on Rapture, and making available an issue tracker to support it. If you find any bugs in the meantime, please just email me with details and I promise to reply. Just to reiterate: This software is undertested and liable to break without warning! I'll be doing everything I can to improve it over the weeks leading up to launch. Jon Pretty Propensive 12 August 2011