Note: Please go to to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > Tutorials > Amazon Web Services (AWS) > Grid Edition > Write a User Application

Write a User Application

Table of Contents

Short Description

RightGrid supports two ways of invoking the user's application: one shot or persistent.

  1. one shot - a new application process is created for each new work unit received by the worker
  2. persistent -  invokes the user's application once and then uses that instance to repeatedly process workunits

One shot invocation is the simplest way to use RightGrid, but for applications that have a high start-up cost (like loading a large set of input data or doing significant initial setup) it's best to use the persistent model.  The invocation model is selected by the 'invocation_model' parameter of a queue section in the rightworker configuration file.

The following sample "hello world" Ruby code uses the 'one shot' invocation model where a new process is created for each new work unit that is received by a worker.



class RGHelloWorld

  def do_work(message_env, message)
    starttime =

    for j in 0...10000 do
      2 + 2

    finishtime =

    result = {
      :result => 0,
      :id => message_env[:id],
      :starttime => starttime,
      :finishtime => finishtime,
      :created_at => message_env[:created_at],
      :output => "Goodbye World!"


Where message_env is given by the following hash:

message_env = {
  'tmp_dir' => “Directory for temp files”,
  's3_in' => "Directory with the files downloaded from S3",
  'output_dir' => "Directory where the app or kicker should put output files to be
uploaded to S3",
  'log_dir' => "Directory where the app or kicker should put log files to be
uploaded to S3",
  'log_file' => "File for right_worker logs',
  'message_id' => "SQS message id",
  'controller' => "RightWorkersDaemon",
  'worker_name' => "name of user worker"
  'logger' => "handle to the RightGrid logger object",
  's3_downloaded_list' => {‘bucket/key1’=> ‘local_file1’, ..., ‘bucket/keyN’=>


You must to post a comment.
Last modified
21:18, 16 May 2013



This page has no classifications.



© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.