Typesafe Activator

Reactive Scales

Reactive Scales

typesafehub
Source
March 18, 2014
demo reactive

A demonstration of how Reactive scales with the Typesafe Reactive Platform.

How to get "Reactive Scales" on your computer

There are several ways to get this template.

Option 1: Choose reactive-scales in the Typesafe Activator UI.

Already have Typesafe Activator (get it here)? Launch the UI then search for reactive-scales in the list of templates.

Option 2: Download the reactive-scales project as a zip archive

If you haven't installed Activator, you can get the code by downloading the template bundle for reactive-scales.

  1. Download the Template Bundle for "Reactive Scales"
  2. Extract the downloaded zip file to your system
  3. The bundle includes a small bootstrap script that can start Activator. To start Typesafe Activator's UI:

    In your File Explorer, navigate into the directory that the template was extracted to, right-click on the file named "activator.bat", then select "Open", and if prompted with a warning, click to continue:

    Or from a command line:

     C:\Users\typesafe\reactive-scales> activator ui 
    This will start Typesafe Activator and open this template in your browser.

Option 3: Create a reactive-scales project from the command line

If you have Typesafe Activator, use its command line mode to create a new project from this template. Type activator new PROJECTNAME reactive-scales on the command line.

Option 4: View the template source

The creator of this template maintains it at https://github.com/typesafehub/reactive-scales#master.

Option 5: Preview the tutorial below

We've included the text of this template's tutorial below, but it may work better if you view it inside Activator on your computer. Activator tutorials are often designed to be interactive.

Preview the tutorial

Reactive Scales

The Reactive Scales application has been created! This application illustrates the great performance of Reactive applications built with the Typesafe Reactive Platform.

Right now the server is running in development mode which provides a productive environment where you just hit refresh in your browser to see your code changes. Check the server status by going to Run. In development mode every request checks the file system for changes to see if something needs to be recompiled. To run a performance test we need to disable this by running in production mode. To do that first stop the app in Run. From a command line in this project's root directory run this application in production mode:

  • On Linux and Mac:
    ./activator -Dpidfile.path=MY_PID start
  • On Windows:
    activator -Dpidfile.path=MY_PID start

The application should be started and you can open it in your browser: http://localhost:9000

There you should see three charts, one that tracks the number of requests per second, a chart that indicates how much memory this application is using, and one that shows how much CPU the application is using. These values are pushed from the server to the client every 100 milliseconds using a Comet channel.

To test the performance of this application lets send one million requests to it (100 concurrent).

  • On Linux:
    ./loadtest-linux-64.sh
  • On Mac:
    ./loadtest-mac-64.sh
  • On Windows:
    loadtest-windows-64

You should see the charts begin to dial up. It will take 100,000 or so requests before the JVM is warmed up. Then you should get around 40k requests per second. (These results can vary based on number of CPUs, JVM version, and operating system.) You will see the memory bounce around as the JVM garbage collector does it's job. (Note: The JVM will usually try to use as much memory as it can but you can but you can hit the "Garbage Collect" button and it should always come back down to a pretty small base footprint.) During the performance test the CPU usage should be around 75% which is not full utilization because the actual load tester is also consuming some CPU.

It is great that you can slam the application and get around 40k requests per second but what is really cool is that while totally saturating the app with requests the charts are still being updated every 100 milliseconds with values being pushed from the same saturated server!

comments powered by Disqus