Implementing Scaling Capabilities in SAP BTP, Cloud Foundry Runtime

Objective

After completing this lesson, you will be able to implement scaling capabilities in SAP BTP, Cloud Foundry runtime efficiently.

Scaling Capabilities in SAP BTP, Cloud Foundry Runtime Efficiently

Introduction

Your company has recently deployed applications on the SAP BTP, Cloud Foundry runtime and needs to understand the scaling capabilities to handle fluctuations in application traffic and demand efficiently.

Horizontal and Vertical Scaling

SAP BTP, Cloud Foundry runtime offers powerful scaling capabilities, including horizontal and vertical scaling. The choice between horizontal and vertical scaling depends on the specific requirements of your application. Here are some key details about scaling capabilities in SAP BTP, Cloud Foundry runtime:

Horizontal Scaling

Also known as scaling out, is the process of adding more instances to support your application in order to handle increased load. In the context of SAP BTP and Cloud Foundry, this means increasing the number of application instances. By increasing the number of instances, you can ensure that the application remains responsive and performant even as the number of users increases. In SAP BTP, you can easily scale your applications horizontally using the SAP BTP, Cloud Foundry runtime command line interface (CLI), SAP BTP cockpit or the Application Autoscaler service. The platform will automatically distribute the instances across different virtual machines and availability zones to ensure high availability and fault tolerance

Vertical Scaling

Also known as scaling up, it's the process of adding more resources, such as memory and CPU, to your application to handle increased load. In the context of SAP BTP and Cloud Foundry, this means increasing the memory and disk quota for your application instances. Applications get a guaranteed CPU share of ¼ core per GB instance memory. The maximum instance memory per application is 16 GB, which allows for vertical scaling up to 4 CPUs. In SAP BTP, you can easily scale your applications vertically using the SAP BTP, Cloud Foundry runtime command line interface (CLI) and SAP BTP cockpit. You can specify the amount of memory and disk space for each application instance when you push or scale your application. When you scale your application vertically, the platform automatically adjusts the resources allocated to your application. This can improve the performance of your application, but it also increases the cost as you use more resources.

In the context of multitenant applications, each tenant or consumer accesses the application through a dedicated URL, and the application environment identifies them by their unique tenant ID. The application distinguishes between requests from different consumer tenants based on the tenant ID, thus ensuring data isolation. You can define the resources for each module in the mta.yaml file. This includes the memory and disk quota for each application instance. When you deploy the MTA, the platform automatically allocates the specified resources to each application instance.

Limits

SAP BTP, Cloud Foundry runtime imposes certain limits on resource usage and scaling to ensure efficient resource allocation and fair usage among applications. These limits can be customized through the use of organization and space quotas, enabling administrators to define maximum resource allocations for memory, CPU, disk space, and the number of instances per application. In the SAP BTP, Cloud Foundry runtime environment of SAP Business Technology Platform (BTP), there are certain limits when it comes to scaling applications:

  1. Memory: The maximum memory you can allocate to an application instance is 16 GB.
  2. Disk Quota: The maximum disk quota you can allocate to an application instance is 10 GB.
  3. Application Package Size: The maximum application package size is 1.5 GB. If your application is larger than that, the deployment fails.
  4. MTA Archive Size: The maximum size of a multitarget application (MTA) archive is limited to 500 MB. Deployment is denied for archives with larger size.
  5. Number of Instances: The number of instances you can scale out to will depend on the quota assigned to your organization and space in the SAP BTP, Cloud Foundry runtime environment.

Please refer to the SAP BTP - Specific Configuration documentation for the most current information on limit configurations for SAP BTP, Cloud Foundry runtime.

Remember, these limits ensure fair usage and maintain the performance and stability of the platform. If your application needs more resources, you may need to optimize your application or consider distributing your workload across multiple applications or services.

Autoscaling

Autoscaling is a crucial aspect of application development, especially in a cloud environment. SAP BTP, Cloud Foundry runtime supports autoscaling through the Application Autoscaler service, allowing applications to dynamically adjust the number of running instances based on predefined criteria such as CPU usage, memory utilization, or custom metrics. This enables applications to automatically scale up or down in response to changing load conditions, ensuring optimal performance and resource utilization. This service automatically adjusts the number of application instances based on your defined policy. These policies can be based on specific schedules or metrics such as CPU utilization, HTTP throughput, or HTTP latency. By doing so, it enables applications to scale in or out in response to changing load conditions, ensuring optimal performance and resource utilization.

The Application Autoscaler service provides the following features:

  • Dynamic Scaling: It adjusts the number of application instances automatically based on real-time application performance metrics.
  • Scheduled Scaling: It adjusts the number of application instances automatically based on predefined schedules. This is useful for scenarios where predictable load changes occur.
  • RESTful APIs: It provides APIs for managing autoscaling policies and retrieving autoscaling history.
  • Autoscaling Dashboard: It provides a user interface for you to manage autoscaling policies and view autoscaling history.

To use the Application Autoscaler service, you need to bind it to your application and define an autoscaling policy. Scaling policies with multiple rules are executed from the top down. The first rule that matches will determine the outcome of the policy evaluation. It's usually okay if scaling is based on just one metric (depending on hysteresis). Make sure to prioritize the most important rules at the top. This approach won't work for multiple metrics as there is no support for AND or OR operations. Remember to consider these factors when setting up scaling policies.

Streamlined Service Setup

  1. Create a service instance.
  2. Define scaling policy.
  3. Bind app to service instance using policy.

The figure explains the streamlined service setup: a scenario-based tutorial.

Custom metrics should be submitted if the standard metrics are not enough. They should be submitted every 40 seconds per application instance to be consistent with other metrics. However, keep in mind that there's a limit of 30 requests per second against the custom metrics API. All metrics, including custom ones, will be averaged over time and across application instances. So, it's important to submit measurements periodically from each application instance.

Load Balancing

SAP BTP, Cloud Foundry runtime includes built-in load balancing capabilities to evenly distribute incoming traffic across all running instances of an application. This helps improve the overall performance, availability, and reliability of applications by effectively utilizing the available resources and handling traffic spikes.

Summary

SAP BTP, Cloud Foundry runtime offers powerful scaling capabilities, including horizontal scaling (increasing the number of instances) and vertical scaling (increasing memory and disk space). There are also limits on resource usage, customizable through organization and space quotas, and autoscaling capabilities to dynamically adjust the number of running instances based on predefined criteria. The platform also provides built-in load balancing to distribute incoming traffic evenly. These features are essential for maintaining optimal performance, resource utilization, and application availability.

Log in to track your progress & complete quizzes