Scaling an App Using cf scale

Page last updated:

This topic describes how to scale an app using the Cloud Foundry Command Line Interface (cf CLI).

Overview

Several factors, such as user load or the number and nature of tasks, can change the disk space, memory, and log rate limit that an app uses. For many apps, increasing the available disk space or memory can improve overall performance. Similarly, running additional instances of an app can allow the app to handle increases in user load and concurrent requests. Making these adjustments is called scaling an app.

You can use the cf scale command to scale an app up or down to meet changes in traffic or demand. For more information, see the Cloud Foundry CLI Reference Guide

Scaling Horizontally

Horizontally scaling an app creates or destroys instances of the app.

Incoming requests to an app are automatically load-balanced across all instances of the app, and each instance handles tasks in parallel with every other instance. Adding more instances allows the app to handle increased traffic and demand.

Horizontally Scale an App

To horizontally scale an app:

  1. In a terminal window, run:

    cf scale APP-NAME -i NUMBER-OF-INSTANCES
    

    Where:

    • APP-NAME is the name of the app you want to scale.
    • NUMBER-OF-INSTANCES is the number of instances you want the app to have.

      For example:
    cf scale example-app -i 5
    

    Note: If you are using cf CLI v7, you can include the --process flag to scale specific processes of an app.

Scaling Vertically

Vertically scaling an app changes the disk space limit, memory limit, or log rate limit that your Cloud Foundry deployment applies to all instances of the app.

Scale the Disk Space Limit of an App

To scale the disk space limit applied to all instances of an app:

  1. In a terminal window, run:

    cf scale APP-NAME -k DISK-LIMIT
    

    Where:

    • APP-NAME is the name of the app you want to scale.
    • DISK-LIMIT is the maximum amount of disk space in megabytes or gigabytes that you want each app instance to use. This value must be an integer followed by either M or G.

      For example:
    cf scale example-app -k 512M
    

Scale the Memory Limit of an App

To scale the memory limit applied to all instances of an app:

  1. In a terminal window, run:

    cf scale APP-NAME -m MEMORY-LIMIT
    

    Where:

    • APP-NAME is the name of the app you want to scale.
    • MEMORY-LIMIT is the maximum amount of memory in megabytes or gigabytes that you want each app instance to use. This value must be an integer followed by either M or G.

      For example:
    cf scale example-app -m 1G
    

Scale the Log Rate Limit of an App

To scale the log rate limit applied to all instances of an app:

  1. In a terminal window, run:

    cf scale APP-NAME -l LOG-RATE-LIMIT
    

    Where:

    • APP-NAME is the name of the app you want to scale.
    • LOG-RATE-LIMIT is the maximum number of logs in bytes, kilobytes, megabytes, or gigabytes that you want each app instance to send to Loggregator. This value must be an integer followed by either B, K, M, or G. To configure each app instance to send an unlimited number of logs to Loggregator, specify -1.

      For example:
    cf scale example-app -l 12K
    
Create a pull request or raise an issue on the source for this page in GitHub