Scaling Your Apps Automatically with Zerops – Both Vertically and Horizontally
Tags: cloud, showdev, tooling
Published: 2022-09-21 10:42:56

Auto scaling is one of the key features of PaaS systems, such as Heroku or Render. That is why we made sure to include it in [Zerops](https://contabo.com/en/zerops/) and to finetune it to developers’ needs. 

## What is autoscaling?

This feature performs an automated scaling of resources required to run your application based on its demand. So if your application isn’t used so often the auto scaling reduces the amount of required resources and thus reduces the costs. If your application is used more, then auto scaling increases the resources for the application to make sure it runs smoothly even with the higher demand.

The result?

On [Zerops](https://contabo.com/en/zerops/), you never pay for resources you don’t need. At the same time you don’t have to worry about traffic peaks or fast growth as the auto scaling feature handles this with no trouble.

## Zerops automatically scales services both horizontally and vertically

Each service you install starts with the minimum technical amount of resources: vCPU, RAM and Disk. [Zerops](https://contabo.com/en/zerops/) monitors the usage of these 3 resources and if the usage exceeds a set threshold, more vCPU, RAM or Disk is allocated to the service. This is called vertical scaling. 

When creating a new runtime service, you can choose the minimum and maximum number of containers. If you set the maximum limit to one, the service will be run in a single container and no horizontal scaling will occur. By increasing the maximum number of containers for your service, you enable horizontal auto scaling. Zerops will then add containers depending on your application’s load. Application running on two or more containers is in High-Availability mode, which we highly recommend for production. When the load drops, containers will be gradually removed to the defined minimum. 

Each container and each metric (vCPU, RAM, Disk) is scaled separately. If you run your application in High-Availability mode, different containers can allocate different amounts of resources based on the current usage. There are no fixed tiers or pricing packages, you pay only for the performance and storage your application needs.


## Auto scaling configuration for runtime services
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5kqnityilsql9jvmafk6.png)

Both minimum and maximum limits for auto scaling are under your control. Technical minimums for vCPU, RAM and Disk are preset for each runtime service. Set the minimums and maximums for vCPU, RAM and Disk depending on the needs of your application and Zerops will scale them within defined limits. You can change the settings any time, Zerops will update the number of containers and their allocated resources accordingly. 

Vertical auto scaling of vCPU, RAM or Disk can be disabled independently by setting the same value for minimum and maximum. For example, you can control your RAM manually and let Zerops scale vCPU and Disk automatically. 

Horizontal scaling can be disabled by setting the same number for the minimum and maximum container count. Zerops then scales the service only vertically.

## Auto scaling configuration for databases
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h1wv7mny358yw3m4trvd.png)

Vertical auto scaling configuration for databases and shared storage is identical to runtime services. Technical minimums for vCPU, RAM and Disk are preset according to the service type and version. 

You can choose 2 modes for each database and shared storage: Single Container or Highly Available mode. In the Single Container mode the database or shared storage is deployed in a single container. The number of containers cannot be increased. 

If the Highly Available mode is chosen, [Zerops](https://contabo.com/en/zerops/) will deploy the database cluster with a fixed number of containers and control mechanisms for automatic cluster repair. Shared storage cluster contains 3 containers with all files redundantly stored on all 3 containers. The KeyDB (Redis) cluster consists of 2 containers in the master-master replica. MariaDB, PostgreSQL databases and RabbitMQ message broker are deployed in 3 containers connected in the High Availability cluster with 2 additional application balancers which ensures high reliability. You are not charged for the resources consumed by application balancers. 

## Object Storage
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c0f7jdfkbdoztcmgnarp.png)

Amazon S3 compatible object storage is operated as a CEPH cluster and is always in the Highly Available mode. When creating a new object storage service, you set the Disk Capacity and Zerops takes care of the rest. You will be charged for the allocated disk space only. You can change the disk capacity on the go. Object storage doesn't scale automatically. 


## Zerops Auto Scaling Mechanisms

[Zerops](https://contabo.com/en/zerops/) prefers vertical scaling over horizontal scaling because vertical scaling is faster and allows finer adjustment to the required performance. Zerops checks vCPU, RAM and Disk usage in all running containers each 10 seconds. If a threshold for vertical scale up is reached, Zerops scales the container up. The minimum step for the vertical scaling is 1 vCPU, 0.25 GB RAM and 0.5 GB Disk, when the application is under a heavy load and needs to scale up fast, the steps will be automatically increased. After the application no longer needs as much power or disk space, each container is gradually scaled down to the defined minimum.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4gvl5nojohx1cifgnilk.png)

Zerops will add a new container (scale out your service) when a single container reaches the maximum defined limit for vertical scaling of vCPU or RAM. Zerops doesn't start a new container when the maximum disk space is reached or when the maximum container count is reached. 

By customizing the vertical auto scaling limits, you can cause the horizontal scaling to start earlier. For example set the vertical auto scaling maximum to 10 vCPU. Zerops will start a new container if some of the running containers are using the 10 vCPU for more than a minute.

If the application no longer needs as much power, Zerops will gradually remove containers to the defined minimum count.

[Find out more about Zerops.](https://contabo.com/en/zerops/)