One of the benefits of deploying applications in the cloud is the ease of scaling, or adjusting the capacity of a resource. Instead of manually adding new hardware, deploying new servers, or worrying about load balancing and network configuration, a cloud platform enables scaling an application via a simple user interface. AppFog is a Platform-as-a-Service (PaaS) system implementing the popular cloud computing platform Cloud Foundry. Among its many features are powerful scaling utilities that control many aspects of an application's footprint.

Nevertheless, properly scaling an application so it uses the right amount of system resources takes a little planning and experimentation. With cloud services it's important that you don't over allocate. At the same time, you don't want to hurt application performance through specifying less than you may need. In other words, you want your applications to scale on demand so that you pay only for the resources you actually use. This article explores the application scaling features of AppFog.

Tools Used

AppFog is our PaaS offering based on Cloud Foundry. It allows you to easily host cloud-native applications without worrying about provisioning and maintaining servers and separate services. AppFog applications deploy quickly and scale automatically while having access to the full range of CenturyLink Cloud products.

Getting Started with AppFog

Before you can deploy to AppFog, you need to sign up for a CenturyLink Cloud account and enable AppFog. If you don't have a CenturyLink Cloud account, migrate to the CenturyLink Platform with free onboarding assistance and receive a matching spend credit. The credit is based on your initial commitment period of platform use.

Enable AppFog

First, enable AppFog in the CenturyLink Cloud Control Panel.

  1. Go to the Control Panel and log in.
  2. Select AppFog from the pull-down menu. Control Portal
  3. Select a region to host your application. Region

Log into AppFog Using the Cloud Foundry Tools

Once AppFog is set up in your CenturyLink Cloud account, you need to log in to AppFog using the Cloud Foundry CLI. The Control Panel gives you an exact command from the Overview tab.

  1. Find the cf login command on your AppFog control panel. It will look similar to this:

       cf login -a -o C007 -u your.username

    Control Portal

  2. Run the command in your project directory.

  3. Enter your CenturyLink Cloud password when prompted. Password
  4. Press "1" to select the Dev application space. Dev App

Note: To learn more about logging into AppFog using the Cloud Foundry command-line tools, we recommend reading this Knowledge Base article.

Planning For Scalability

Application scaling in AppFog can be either vertical or horizontal.

  • Vertical Scaling - Adding more compute resources in the form of CPU and memory to the existing machines in the pool (or removing that), along with specifying thresholds for determining when to scale.
  • Horizontal Scaling - Adding additional machines to the pool or resources (or removing them), along with specifying thresholds for determining when to scale.

The proper approach to scaling depends on a number of factors; one of the biggest is your application architecture. Some applications just aren't built for a distributed computing model, which means that vertical scaling is the only option. Additionally, vertical scaling begins to see diminishing returns after a certain point, where adding more resources to a single instance won't help application performance as much as you might want.

In the past, horizontal scaling posed a problem with increased management complexity. AppFog removes that complexity by managing the hardware running your application instances. This removes one of the biggest issues related to horizontal application scaling. In addition, as we will see later, horizontal scaling doesn't require an AppFog application to be restarted, meaning that it is the fastest, easiest way to scale on-the-fly. AppFog handles most of the stack for you.

Stack Handling

Evaluating Application Needs

Sometimes it's easy to tell when your application needs to scale. Users may complain about speed. Resources may appear strapped. To evaluate how resources are being consumed by your application, you can use the cf app command. For example:

    $ cf app MYAPP

Replace MYAPP with the name of your application. You will receive output similar to the following:

Output Command

In this example, each AppFog instance is running at over 200% CPU usage, but memory and disk space are both well within the allocated range. If your application instances are seeing their CPU usage this high, it's a good time for horizontal scaling. However, if memory or disk space are nearly consumed, then vertical scaling is needed.

Application Need Approach
Disk space Vertical Scaling
Memory Horizontal or vertical scaling
CPU Horizontal scaling

View Current Scaling Options

To see the current settings for your app, use the cf scale command:

    $ cf scale MYAPP

Replace MYAPP with the name of your application. You will receive output showing currently allocated memory, disk space, and the number of instances running for your app. Scaling Options

Configuring for Vertical Scale

Adding more memory and disk space to an application can be done with just one command. To add memory, use the cf scale command like this:

    $ cf scale -m 512M MYAPP

Replace MYAPP with your application name. The argument after -m is the total amount of memory you'd like to make available for the application. It should be a number followed by M for megabytes or G for gigabytes.

To add disk space, use the cf scale command like this:

    $ cf scale -k 2G MYAPP

Replace MYAPP with the application name. The argument after -k is the total amount of disk space you would like to allocate for your application. Likewise, that should be a number followed by M for megabytes or G for gigabytes.

Vertical scaling requires you to restart your application for the new resource limits to take effect. Use the cf restart command for that.

Note: If you would like to restart your application without additional prompting, you can use this command: cf restart -f

Configuring for Horizontal Scale

Horizontal scaling also uses the cf scale command, which provides a quick way to scale your application up or down when needed. Before scaling horizontally, remember to consider the following:

  • Not all applications are built to scale horizontally.
  • If an application is reaching its disk or memory allocation limit, horizontal scaling may not help.

To scale an application horizontally, use this command:

    $ cf scale -i 5 MYAPP

Replace MYAPP with the name of your application. The number after the -i argument is the number of instances you would like to allocate for your application. If the number is greater than the number of running instances, more instances will be provisioned and deployed. Now, if the new number of instances is lower than the current running number, then any extra instances will be stopped and their resources released.

Automated Scaling

Sometimes it's possible to plan ahead for scaling requirements. For example, an e-commerce website will plan to scale up dramatically for major online shopping days such as Black Friday. News websites might know when big stories will hit or might plan scaling around major news cycles. Sometimes scaling is needed during unexpected usage spikes, and that's when automated scaling becomes important.

AppFog doesn't provide built-in automatic scaling. However, there are third-party tools available that can automatically scale applications based on CPU or memory usage. Two applications that you might want to evaluate for this purpose are:


The AppFog PaaS takes the effort out of scaling. You no longer have to worry about the long and arduous process of adding new physical servers and hardware. Just because scaling is easy to implement doesn't mean that it's simple to address. With the tools you learned about in this article, you should be ready to evaluate your application needs and prepare a suitable approach to scaling.

What's Next?

This tutorial provides an overview of scaling an application with AppFog. Expanding on the tutorial, you can add CenturyLink Object Storage, lightning-quick Hyperscale Servers, and other robust cloud services to give your application the performance edge it needs.

Sign-up for our Developer-focused newsletter CODE. Designed hands-on by developers, for developers. Keep up to date on topics of interest: tutorials, tips and tricks, and community building events.

We’re a different kind of cloud provider – let us show you why.