9. Scaling an App on the Cloud Foundry - pnguye35/pal-tracker GitHub Wiki
Purpose Gain an understanding of how to manually and automatically scale an application on Cloud Foundry.
Learning Outcomes After completing the lab, you will be able to:
Demonstrate the ability to manually scale an application on Cloud Foundry Demonstrate the ability to use autoscaling for an application on Cloud Foundry Explain the difference between vertical scaling and horizontal scaling Scaling Overview Cloud Foundry supports two types of scaling:
Vertical scaling: Each app instance has more memory or disk space. Horizontal scaling: There are more app instances serving requests. The command cf scale controls both horizontal and vertical scaling. We will demonstrate scaling using this command and view the effects on the env endpoint.
Scale the memory Use the app command to see the current memory usage. It will be something like "290M of 1024M".
Use the scale command with the -m and -f flags to scale your app's memory to 768 Mb.
Scaling memory requires restarting your app's container, and the -f flag skips the prompt for this.
Wait a moment for the app to restart then navigate to the env endpoint. See that the memory quota has changed.
Scale the number of instances Use the scale command with the -i flag to scale your app's to two instances.
Changing the number of instances does not require a restart.
Check the status of the new instance with the app command.
If you do this fast enough, you will see the second instance switch from starting to running.
Wait a moment for the app to spin up new instances then navigate to the env endpoint.
Hit refresh a few times and see that the CF_INSTANCE_INDEX eventually changes.
Enable application autoscaling Cloud Foundry supports automatic horizontal scaling based on metric thresholds.
Visit Apps Manager, navigate to your space, and click on your application name to navigate to the overview page.
Under the Processes and Instances section, toggle the Autoscaling feature on.
Click the Manage Autoscaling link to manage scaling rules.
Set your instance limits to a minimum of 1, and maximum of 3.
Add a scaling rule to scale down if HTTP Latency is less than 1ms, and scale up if more than 3ms.
Visit your app url and refresh the page several times quickly.
In the Manage Autoscaling view, check the Recent History and see that the application has scaled up due to latency.
Assignment Submit the assignment using the cloudNativeDeveloperScaling Gradle task. It requires you to provide the URL application.
For example:
cd ~/workspace/assignment-submission ./gradlew cloudNativeDeveloperScaling -PserverUrl=https://${APP_URL} Learning Outcomes Now that you have completed the lab, you should be able to:
Demonstrate the ability to manually scale an application on Cloud Foundry Demonstrate the ability to use autoscaling for an application on Cloud Foundry Explain the difference between vertical scaling and horizontal scaling