July 31, 2008

Scalability Benchmark of Monte Carlo Simulation on Amazon EC2 with GridGain Software

This blogpost presents the report on recently concluded scalability benchmark of Monte Carlo simulations running on Amazon EC2 using the GridGain framework. It consists of two parts: Part I is a technical report on the benchmark goals, method and results and Part II is an account of the development process and lessons learned.


Part I: Benchmark description & results

The goal of the benchmark was to study the scalability characteristics of massively parallel algorithms executed on Amazon ’s Elastic Computing Cloud (EC2) and managed by GridGain

A Monte Carlo simulation was chosen as an algorithm to represent its widespread use in financial applications. The same algorithm with different parameters was used on a wide range of grid sizes: 2, 4, 8, 16, ..., 256, 512. The parameters guaranteed that the amount of work performed by the whole grid was always linear with respect to the number of nodes. In other words, twice as many nodes always performed twice as much work. Perfect linear scalability would demonstrate the identical *completion time* of Job-1 running on 2 node and Job-2 running on 512 nodes, given that Job-2 had 256-times more work to do.

As Amazon permitted us to use the maximum of 550 nodes in a single run, the upper limit o fthe benchmark was chosen at 512.

The test utilized a full open source software stack, including GridGain, the Linux operating system, Sun Microsystem’s Open MQ JMS messaging and Sun’s Java 5 VM. Amazon’s preinstalled Fedora Core 8 with custom testing framework was used to conduct the benchmark.

The results justified our hopes: we could successfully run up to 512 nodes without significant performance degradation. The results graph is shown on figure 1.

Figure 1. Average task execution times on 2-512 nodes grids.

The performance degradation of 3 seconds (about 20%) should be considered minor given roughly 250-fold increase in scale. The curve rises two times: in the ranges 2-8 and 256-512, while 8-256 remains almost flat.

The range 2-8 growth can be explained by initial rapid growth of grid size, which causes the rise of maximum task execution time among nodes (the overall time is determined by the “weak link”). The range 256-512 growth could be explained by OpenMQ limitations as applied to our use case (the JMS load is quadratic against the grid size). In order to continue scaling the grid beyond 512 nodes, a clusterization of OpenMQ is likely to be required.

We can conclude that the obtained result showed near linear scalability and performance improvements from 2 to 512 nodes in all test runs.


Part II: How did we do it?

To start using EC2, just open Amazon EC2 Getting Started Guide, download EC2 API tools and follow the instructions. You can use one of the predefined public machine images or create a bundle with your own image.

The relatively big problem is the lack of persistence options in EC2. When an instance goes down, all the data is lost. However, there are third party solutions capable of mounting Amazon's S3 storage interface as a Linux filesystem.

Now, we needed to create a simple framework allowing us to manage the grid on Amazon’s EC2. The basic functionality would look like:

  • start the grid;
  • add/remove nodes to/from the grid;
  • display the grid health;
  • run single calculation task interactively;
  • run a benchmark (batch task execution on 1, 2, 4, …, 512,... nodes).

The first problem we encountered was that multicast is not supported in the EC2 infrastructure. By default GridGain is configured to make initial discovery by IP multicast. Unfortunately, as far as we know, the EC2 guys don’t plan to create fully functional multicast support anytime soon.

Luckily, GridGain is shipped with a set of various Service Provider Interfaces (SPIs). So, we could choose another DiscoverySPI that does not use IP multicast for discovery purposes, and we chose JMSDiscoverySPI. At first, we picked Apache ActiveMQ as a JMS implementation and soon ran into stability issues. Then we switched to OpenMQ and it proved to be sufficiently robust.

Our second problem turned to be the default maximum number of running instances per user – 20. Since we were going to run grids much larger than 20 nodes, we needed to override the default limit. It took several steps and a few more days to negociate with Amazon EC2, but eventually, we were granted the right to run up to 550 nodes. It seems that the business process of requesting a large amount of nodes is still not very well-defined by Amazon.

The image creation was not a very hard task: we got the public Fedora 8 i386 image, ran it, installed Java Runtime Environment 6, GridGain and ActiveMQ, then bundled this new image.

We still required some extra configuration since the grid node must start on system startup. The hardest thing was to write shell scripts for starting the grid. These scripts had to parse user data sent to the instance (different for the Head Node and Worker Nodes), determine the node type and start the necessary software in each given configuration. Later these scripts were replaced by more convenient Java-based tools and Head Node’s ActiveMQ was replaced by a standalone OpenMQ.

Figure 2. Initial GridGain on Amazon EC2 architecture.

So, how does the grid work? First, we start the Head Node (see figure 2). Head Node automatically starts ActiveMQ (only in early versions), GridGain in master mode (will be described later) and runs the requested number of Worker Nodes. Since Workers should connect to the JMS server, Head Node passes its IP address as user data for Worker Nodes. Worker Nodes just start GridGain.

We realized quickly that we needed some user-friendly interface to manage the grid. So, we rewrote the scripts in Java using the typica library. Thus we integrated Amazon and GridGain management. Now we can automatically start EC2 instances, wait for them to start, get their IP’s, track status, etc. Together with GridGain management it becomes a very powerful tool. Let’s imagine the grid running completely autonomously. The management module can automatically bring up more EC2 instances or shut them down depending on the current grid load.

When we had the simple web UI with capabilities of seeing the table of grid nodes and running our benchmark, we felt ready to run grids larger than 20 nodes. We asked Amazon to increase our running instances limit to 1050 nodes. Amazon agreed to let us run 550 instances. The know-how of our UI was the embedded scripting engine, allowing us to change a benchmarking schema without restarting the grid. To understand how simple it is to run a benchmark consisting of several task runs on different number of nodes, just look at this code:

var itersPerNode = 5000;
var cnode = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512];
for (var i in cnode) {
var n = cnode[i];
grid.growEC2Grid(n, true);
grid.waitForGridInstances(n);
runTask(itersPerNode * n, n, 3);
}

Listing 1. Sample benchmarking script.


The closing remarks:

The framework we built is a good place to start developing a GridGain appliance. But what if we want to create, for instance, an In-Memory Data Grid on this basis? Our next step is making the framework more generic to allow easy integration with virtually any grid framework (either computing or IMDG). There are also other ideas such as creating a generic image and storing specific grid software/configurations in S3, which should ease debugging and small alterations to the appliance.

We are currently evaluating if our framework will be something more than just a GridGain testing framework. We'd love to hear from the community if this line of work is interesting to others beside ourselves. If you'd like to know more about this benchmark, or get access to the full source code, please contact me at mgorbunov@griddynamics.com

Labels: , , , , , , ,

12 Comments:

Blogger amalter said...

This is really interesting stuff from a number of perspectives. I like seeing that GridGain scales with a known use-case. It's interesting to see what heights you can push EC2, and you gave all the underlying components a good stress test.

Can you detail a little more what issues you had with ActiveMQ. We explored the project in it's 4.x incarnation and found some stability issues also. However, I had heard 5.x was much better and we again were going to start looking into it. If anybody has some real world experience, I'd love to hear.

Anyway, thanks for the interesting technical story. I saw a bunch of people on DZone were getting on you guys and I don't think they give credit due when you guys give back like this. Yes it's a GridGain plug, but I happen to like your product, and you also pushed EC2 and OpenMQ to it's limits. Additionally, this benchmark provides a pretty damn good tutorial for anybody creating a highly coordinated distributed application of any kind on EC2.

Bravo!

-Adam Malter

August 6, 2008 8:40 AM  
Anonymous Anonymous said...

I thought that AWS announced a new solution to help with the EC2/S3 roughness. Some sort of high-speed persistent storage that can be mounted in the filesystem.

No, I don't mean a vendor-supplied solution either.

Also did you make use of their new EC2 geographic locality feature whereby you can specify that you prefer instances to be in the same datacenter?

August 6, 2008 2:47 PM  
Blogger AnjanBacchuDev said...

Hi there,

I'd like to repeat what you did for the learning experience.

I will be sending you an email asking for the source code and whatever else that you can share so that I can repeat the experiment and, more important, the findings.

it will be useful to your readers to know what type of EC2 instances you used(there are 4 varieties of instances, AFAIK).

thank you,

BR,
~A

August 6, 2008 9:49 PM  
Blogger The Simplist said...

Some thoughts here
Great work Max. Keep up the insights!

August 6, 2008 10:45 PM  
Blogger Manik Surtani said...

Interesting stuff. Do you have any idea when EC2 plans to support IP multicast? It would be interesting to see how things scale if you were to use JBoss Cache as your "persistence" library (in-memory storage, distributed across the grid) but you would need IP multicast for an optimal JBC configuration.

August 7, 2008 7:14 AM  
Blogger Max Gorbunov said...

2 amalter:
We got "java.lang.OutOfMemoryError: unable to create new native thread" and other issues with ActiveMQ on 50+ nodes. The best results (~100 nodes) were reached by tuning ActiveMQ 4.1.2. Anyway OpenMQ works much better with GridGain.

2 Anonymous:
Amazon promises to release their persistent storage on next week. Currently it is not publicly available.
We did not use availability zones in our tests. Putting all nodes into the same zone would insignificantly reduce our expenses (as well as network latencies), but real-world applications are likely to use different availability zones for reliability purposes.

2 AnjanBacchuDev:
Actually, there are 5 options. We used Small Instances for Worker Nodes and Large Instances for OpenMQ and Head Node.

2 Manik Surtani:
Amazon doesn't plan to support IP multicast. That's why we used JMS.

August 7, 2008 9:26 AM  
Blogger pelegri said...

Hi Max. I've done a spotlight on this entry at TheAquarium [1]. We are always interested in adoption stories for our OpenSource software [2], please contact me at "stories at sun dot com" if you are interested.

- eduard/o


[1] http://blogs.sun.com/theaquarium/entry/openmq_in_512_node_setup
[2] http://blogs.sun.com/stories

August 10, 2008 12:27 PM  
Blogger James Strachan said...

BTW details of the ActiveMQ instability are here - basically using the latest 5.x releases fix this

August 14, 2008 2:02 AM  
Blogger Max Gorbunov said...

2 James Strachan:
We decided to use OpenMQ for a number of reasons with both 4.x and 5.x versions of ActiveMQ.
See, for example, this forum: http://www.gridgainsystems.com/jiveforums/thread.jspa?threadID=343&tstart=0

August 14, 2008 4:12 AM  
Anonymous Anonymous said...

Can the same test be performed in an all Windows environment using something like GoGrid instead of EC2?

http://www.gogrid.com/

I need to gridify an exhaustive optimization search whose fitness function is the result of an OLE automation call upon an object available only on Windows.

August 21, 2008 6:07 PM  
Blogger Max Martynov said...

We think, this is possible. GoGrid should have all the required features to provision and start nodes. GridGain can also be used on Windows 2003, at least as a limited testing edition right now. Some of MQ solutions should run on Windows too. At least it will be ActiveMQ.

So, the only thing that is needed is to refactor our test harness to use GoGrid API. We can share the source codes if you want.

However, if you use OLE automation, it may not be very comfortable to run them from Java environment. So, you may consider using Microsoft HPC solutions.

We can also arrange a conf call to discuss the details if you find it useful.

August 27, 2008 1:29 AM  
Blogger Mike said...

Hi Max,
Very interesting and cool. Is there any chance that the team plans to release the code or a howto (or have they already?).

thanks...

March 31, 2009 8:22 AM  

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home