Optimizing a sample application running on AWS

In this example, you will go through the optimization of a Spark based PageRank algorithm on AWS instances. We’ll be using a PageRank implementation included in Renaissance, an industry-standard Java benchmarking suite developed by Oracle Labs, tweaking both Java and AWS parameters to improve the performance of our application.

Environment setup

For this example, you’re expected to use two dedicated machines:

  • an Akamas instance

  • a Linux-based AWS EC2 instance

The Akamas instance requires provisioning and manipulating instances, therefore it requires to be enabled to do so by setting AWS Policies, integrating with orchestration tools (such as Ansible) and an inventory linked to your AWS EC2 environment.

The Linux-based instance will run the application benchmark, so it requires the latest open-jdk11 release

sudo apt install openjdk-11-jre

Telemetry Infrastructure setup

For this study you’re going to require the following telemetry providers:

Application and Test tool

The renaissance suite provides the benchmark we’re going to optimize.

Since the application consists of a jar file only, the setup is rather straightforward; just download the binary in the ~/renaissance/ folder:

In the same folder upload the template file launch.benchmark.sh.temp, containing the script that executes the benchmark using the provided parameters and parses the results:

You may find further info about the suite and its benchmarks in the official doc.

Optimization setup

In this section, we will guide you through the steps required to set up the optimization on Akamas.

Optimization packs

This example requires the installation of the following optimization packs:

System

Our system could be named renaissance after its application, so you’ll have a system.yaml file like this:

Then create the new system resource:

The renaissance system will then have three components:

  • A benchmark component

  • A Java component

  • An EC2 component, i.e. the underlying instance

Java component

Create a component-jvm.yaml file like the following:

Then type:

Benchmark component

Since there is no optimization pack associated with this component, you have to create some extra resources.

  • A metrics.yaml file for a new metric tracking execution time:

  • A component-type benchmark.yaml:

  • The component pagerank.yaml:

Create your new resources, by typing in your terminal the following commands:

EC2 component

Create a component-ec2.yaml file like the following:

Then create its resource by typing in your terminal:

Workflow

The workflow in this example is composed of three main steps:

  1. Update the instance type

  2. Run the application benchmark

  3. Stop the instance

To manage the instance we are going to integrate a very simple Ansible in our workflow: the FileConfigurator operator will replace the parameters in the template file in order to generate the code run by the Executor operator, as explained in the Ansible page.

In detail:

  1. Update the instance size

    1. Generate the playbook file from the template

    2. Update the instance using the playbook

    3. Wait for the instance to be available

  2. Run the application benchmark

    1. Configure the benchmark Java launch script

    2. Execute the launch script

    3. Parse PageRank output to make it consumable by the CSV telemetry instance

  3. Stop the instance

    1. Configure the playbook to stop an instance with a specific instance id

    2. Run the playbook to stop the instance

The following is the template of the Ansible playbook:

The following is the workflow configuration file:

Telemetry

If you have not installed the Prometheus telemetry provider or the CSV telemetry provider yet, take a look at the telemetry provider pages Prometheus provider and CSV Provider to proceed with the installation.

Prometheus

Prometheus allows us to gather jvm execution metrics through the jmx exporter: download the java agent required to gather metrics from here, then update the two following files:

  • The prometheus.yml file, located in your Prometheus folder:

The config.yml file you have to create in the ~/renaissance folder:

Now you can create a prometheus-instance.yaml file:

Then you can install the telemetry instance:

You may find further info on exporting Java metrics to Prometheus here.

CSV - Telemetry instance

Create a telemetry-csv.yaml file to read the benchmark output:

Then create the resource by typing in your terminal:

Study

Here we provide a reference study for AWS. As we’ve anticipated, the goal of this study is to optimize a sample Java application, the PageRank benchmark you may find in the renaissance benchmark suite by Oracle.

Our goal is rather simple: minimizing the product between the benchmark execution time and the instance price, that is, finding the most cost-effective instance for our application.

Create a study.yaml file with the following content:

Then create the corresponding Akamas resource and start the study:

Last updated

Was this helpful?