Skip to main content

Scaling an App Horizontally in Cloud Foundry

Hands-On Lab

 

Photo of Travis Thomsen

Travis Thomsen

Course Development Director in Content

Length

00:45:00

Difficulty

Beginner

In this live environment, you are a system administrator that maintains a website that tracks record albums. Your site has grown in popularity and you need to increase the number of instances to two to handle the traffic. Your application is hosted in Cloud Foundry.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Scaling an App Horizontally in Cloud Foundry

Introduction

In this live environment, you are a system administrator that maintains a website that tracks record albums. Your site has grown in popularity and you need to increase the number of instances to two to handle the traffic. Your application is hosted in Cloud Foundry.

Solution

Open a terminal session and log in to the provided instance:

ssh cloud_user@<PUBLIC IP>

Then, become root:

sudo su

You will also need to register for a free Pivotal Cloud Foundry account.

Log In to Pivotal Cloud Foundry

  1. Log in to your Pivotal Cloud Foundry account:

    cf login -a api.run.pivotal.io
  2. When prompted, enter the email address you used for the account as well as your password.

  3. Clean up any lingering resources:

    cf apps
  4. If there are any resources you need to delete, for each app you need to remove, enter:

    cf delete <APP NAME>

Scale App Horizontally

  1. Change to the spring-music directory:

    cd spring-music/
  2. Bootstrap the environment:

    cf push
  3. In a new browser tab, browse to the application by entering: spring-music-chatty-wombat.cfapps.io. It should load alright.

  4. Back in the terminal, scale the application up to two instances:

    cf scale spring-music -i 2
  5. Verify there are two instances:

    cf apps
  6. Change it back to one instance:

    cf scale spring-music -i 1
  1. Verify there is one instance:

    cf apps

Clean Up the Environment

  1. Delete the app:

    cf delete spring-music
  2. Verify it's deleted:

    cf apps

Conclusion

Congratulations on successfully completing this hands-on lab!