Skip to content

Latest commit

 

History

History
129 lines (101 loc) · 4.33 KB

File metadata and controls

129 lines (101 loc) · 4.33 KB

Lab 3 - Scaling and Operating Applications

Pivotal Cloudfoundry makes the work of performing operations actions, such as scaling, doing a zero-downtime deploy, and managing application health very easy. In the next two labs we’ll explore Pivotal Cloud Foundry operations.

Scale the Application Up

  1. Now let’s increase the number of running application instances to 3. :

    > cf scale env -i 3
    Scaling app env in org student-42 / space development as student-42...
    OK

    In reporting OK, the CLI is letting you know that the additional requested instances have been started, but they are not yet necessarily running.

  2. We can determine how many instances are actually running like this:

    > cf app env
    Showing health and status for app env in org student-42 / space development as student-42...
    OK
    
    requested state: started
    instances: 3/3
    usage: 512M x 3 instances
    urls: env-farraginous-thunderclap.apps.pcf4u.com
    last uploaded: Sun Feb 19 18:18:32 UTC 2017
    stack: windows2012R2
    buildpack: binary_buildpack
    
         state     since                    cpu    memory      disk      details
    #0   running   2017-02-19 01:23:28 PM   0.0%   0 of 512M   0 of 1G
    #1   running   2017-02-19 01:25:52 PM   0.0%   0 of 512M   0 of 1G
    #2   running   2017-02-19 01:25:53 PM   0.0%   0 of 512M   0 of 1G
    >
  3. Revisit the application route in the browser. Refresh several times. You should observe the instance index changing as you do so:

    lab scale up

    The aforementioned (Go)Router is applying a random routing algorithm to all of the application instances assigned to this route. As an instance reaches the running state, its Diego Cell registers that instance in the routing table assigned to its route by sending a message to Cloud Foundry’s message bus. All (Go)Router instances are subscribed to this channel and register the routes independently. This makes for very dynamic and rapid reconfiguration!

Scale the Application Down

  1. We can scale the application instances back down as easily as we scaled them up, using the same command structure:

    > cf scale env -i 1
    Scaling app env in org student-42 / space development as student-42...
    OK
  2. Check the application status again:

    > cf app env
    Showing health and status for app env in org student-42 / space development as student-42...
    OK
    
    requested state: started
    instances: 1/1
    usage: 512M x 1 instances
    urls: env-farraginous-thunderclap.apps.pcf4u.com
    last uploaded: Sun Feb 19 18:18:32 UTC 2017
    stack: windows2012R2
    buildpack: binary_buildpack
    
         state     since                    cpu    memory      disk      details
    #0   running   2017-02-19 01:23:28 PM   0.0%   0 of 512M   0 of 1G

    As you can see, we’re back down to only one instance running, and it is in fact the original index 0 that we started with.

  3. Confirm that by again revisiting the route in the browser and checking the instance index:

    lab scale down

HTTP Routing

There are two ways to discover what routes, or HTTP URLs, are ampped to an application The first is available via the CLI. Just type:

> cf app env

and you’ll see the list of routes in the section that says urls.

The second way is via the Apps Manager UI. Click on the env application to view application details. Select the Routes tab to view a list of mapped routes:

lab routes
  1. We can easily add an additional route by clicking on + Map a Route and supplying the new hostname:

    lab add route
  2. Navigate to the new URL in your browser window. You should see that same application displayed!

    lab new route
  3. We can just as easily remove a route by clicking on x icon on the route you wish to remove.

    lab unmap route

    If you navigate to that URL you’ll receive a HTTP 404 response

    lab no route
  4. This is how blue-green deployments are accomplished. Check the documentation for detailed instructions.

    blue green