Previous | Next | |
---|---|---|
Exercise 10 - Test Order New Items with User Input | Overview | Exercise 12 - Blue Green Deployment of Comments and Ratings |
- Overview
- Prerequisites
- Configure Manual Scaling in the SAP Cloud Platform Cockpit
- Configure Auto Scaling in the SAP Cloud Platform Cockpit
Scaling of an application is adding more resources (Memory, CPU, Disk) to it and distributing the load between multiple servers. Two types of scaling that are available are:
- Scaling Up/Vertical Scaling: change the disk and memory quota.
- Scaling Out/Horizontal Scaling: increase/decrease the number of instances.
Key benefits:
- Scaling an application ensures its ability to handle more requests, if necessary. Scalability also provides failover capabilities - if one application process crashes, the application will continue to work. First, when deploying the application, you need to define the minimum and maximum number of application processes. Then, you can scale the application up and down by starting and stopping additional application processes. In addition, you can also choose the compute unit size, which provides a certain central processing unit (CPU), main memory and disk space.
You have completed till Exercise 06 - Comments and Ratings and you should have the applications up and running on your SAP Cloud Platform.
In this exercise, we will be performing manual and auto scaling on the comments and ratings backend logic. Consider a scenario where the review application is used by a large number of employees just like Mary, and the memory consumption, CPU usage is increased for this application. To cater to the increasing demand for this application we need to scale up the application so that request can be fulfilled.
Below we will be using SAP Cloud Platform cockpit and auto scaling policies to perform these operations.
We will configure the scaling manually in the SAP Cloud Platform Cockpit. Please make sure you complete the pre-requisites as mentioned above.
-
Open your SAP Cloud Platform cockpit and go to Org - Space - Applications.
-
Locate the
ratings_backend
application. -
Click on the application to go to the Overview page.
-
Scroll down to see the number of instances already running for the application. It should be 1 and will show Memory usage and Disk usage. Check the quota assigned to the application which is
256 MB
. -
Scroll up and increase the instance of the application by clicking the + Instance button. This will do the horizontal scaling i.e scaling out.
-
When you scroll down you will see the instances count increased to two.
-
Now reduce the instance count back to 1 to ensure that we do not exceed the quota limits for the next set of exercises.
-
Now click on Change Quota under Quota Information to do the vertical scaling i.e. scaling up where we will increase the disk and memory quota from 256 MB to 512 MB.
-
Click Save and you will see the quota increased.
-
Let’s get back the application to original state, click on change quota to reduce the quota back to
256 MB
.Not doing say may cause issues in the upcoming steps.
-
Click Save.
-
Go to your SAP Cloud Platform cockpit under Org - Space.
-
Expand the Services tab on left.
-
Click Service Marketplace.
-
Click Application Autoscaler, we are performing this step to create an instance of application autoscaler.
-
Click Instances on the left side.
-
Click New Instance.
-
Finish configuration by accepting default values and clicking Next on the subsequent screens
-
Enter the instance name as
myautoscaling
. -
Click Finish, this will create a autoscaling instance for your applications to use.
-
Click on the newly created
myautoscaling
instance. -
Click Bind Instance, we are performing this step to bind our application to this autoscaler instance.
-
In the Application dropdown select the ratings_backend app.
-
Now copy the contents of
policy.json
from below, edit in Notepad++ editor and then paste it into theEnter Parameters
text box shown on SAP Cloud Platform cockpit. Scroll down and editstart_time
to your current time + 4 minutes. andend_time
to your start time + 4 minutes.{ "instance_min_count": 1, "instance_max_count": 2, "schedules": { "timezone": "Asia/Kolkata", "scaling_rules": [ { "metric_type": "memoryused", "stat_window_secs": 60, "breach_duration_secs": 60, "threshold": 70, "operator": ">", "cool_down_secs": 60, "adjustment": "-1" }], "recurring_schedule": [ { "start_time": "<Edit this:enter a suitable time in 24 hr format, your current time + 4 minutes. for ex:> 15:10", "end_time": "<Edit this:enter a suitable time in 24 hr format, your start time + 4 minutes. for ex:> 15:14", "days_of_week": [1, 2, 3, 4, 5, 6, 7], "instance_min_count": 1, "instance_max_count": 3, "initial_min_instance_count": 3 }] } }
For example if your current time is 16:00 then
- your
"start_time
should be 16:04, and - your
"end_time"
should be 16:08.
We are adding this time so that once we upload this policy the application will scale up and down per this time frame.
- your
-
Click Save.
-
Explanation of the above parameters used: Here we are increasing the number of instances from 1 to 3, and then bringing it down. Other parameters are mentioned below:
schedules A schedule enables you to configure scaling rules for specific days or on a recurring basis. Schedule guards against expected high surges or low activity period.
recurring_schedule Triggers the scaling rule recursively during the specified intervals.
start_time Start time of a recurring schedule in 24-hr format (HH:MM).
end_time End time of a recurring schedule in 24-hr format (HH:MM).
days_of_week Trigger scaling on weekdays ranging from 1 (Monday) to 7 (Sunday). The rule will execute during the weekdays specified within the array.
instance_min_count Minimum number of instances during the recurrence period.
instance_max_count Maximum number of instances during the recurrence period.
initial_min_instance_count Minimum number of instances to scale up during the start of recurrence period.
For more information on parameters refer our help guide.
-
You can now see your application under Referencing Apps.
-
Click on your
ratings_backend
application, to go back to your Application Service Bindings page. Here you can see the auto scaler instance being created. -
Click Overview, on the left side.
-
Scroll down you can see the instances of your application increased to 3 as per the defined policy and the start time mentioned.
-
As per the current policy based on memory threshold, the number of application instances will come down to 2.
© 2018 SAP SE
Previous | Next | |
---|---|---|
Exercise 10 - Test Order New Items with User Input | Overview | Exercise 12 - Blue Green Deployment of Comments and Ratings |