Automation of application scaling is one of the key benefits of PaaS. The following example shows how you can use this ability in , a developer-first app platform – specifically when transforming images by scaling or rotating them using . Zerops Node.js (Zerops command line tool) available. Note: Please be aware that the example code is not meant to have production code quality. The purpose is to demonstrate the scaling feature of . In the following, we assume that you have a account and an installed Zerops Zerops zcli Writing your code The code is fairly simple. It uses and to perform the actual work. Thus please execute the following in a folder of your choice: Express Sharp npm i express sharp This will install all dependencies in a folder and more importantly, create files and . node_modules package.json package-lock.json Then please create the file and insert the following code: index.js const sharp = require("sharp") const express = require('express') const expressServer = express() expressServer.get('/image', (request, response) => { const requestedWidth = request.query.width ? parseInt(request.query.width) : 300; const requestedHeight = request.query.height ? parseInt(request.query.height) : 300; const requestedAngle = request.query.angle ? parseInt(request.query.angle) : 0; const format = 'jpg'; console.log(`Handling image: size to ${requestedWidth}x${requestedHeight} and rotation to ${requestedAngle}`) sharp('example.jpg') .resize(requestedWidth, requestedHeight, { fit: sharp.fit.inside, }) .rotate(requestedAngle) .toFormat(format) .toBuffer() .then(function (outputBuffer) { response.type(format); response.end(outputBuffer) }); }) expressServer.listen(3000, () => { console.log(`Listening on port 3000.`) }) You can use any jpg image as . Please put one in that folder. That's it. Just regular code (and an image). example.jpg Setting up the project in Zerops Once you have the code ready, you need to create a project in . For that purpose, please: Zerops Login to Zerops Create a project by clicking on Add new project Specify a project name e.g. image Choose as service to be added Node.js Click Set to high availability? Click add This sets your Node.js runtime to high availability meaning it will perform vertical and horizontal scaling automatically. Vertical scaling means simply adjusting the amount of resources in your container whereas horizontal scaling adjusts the number of containers. You can read more about it . here Build and deploy on Zerops The following steps describe how you can build and deploy the example as a application. Zerops For to know which files to use please also create a file next to the other files: Zerops zerops.yml nodejs0: build: base: [ nodejs@16 ] build: - npm ci cache: [ node_modules ] deploy: [ index.js, example.jpg, node_modules ] run: start: node index.js Simply deploy your file zcli push "image" nodejs0 Enable Zerops subdomain access via on the service and invoke the pre-generated URL in your browser. Public access & internal ports nodejs0 Autoscaling in action So far we deployed the code only without seeing the autoscaling in action. For that purpose, we will use to generate some load. k6 No worries, won't scale to infinity without keeping your expenses under control. You can adjust the maximum and minimum resources for both vertical and horizontal scaling easily every time you see fit. will do the rest. Zerops Zerops Here is the script to generate some load : k6.js import http from 'k6/http'; import { check } from 'k6'; export default function () { const baseUrl = "https://<your-generated-subdomain>.usc1.contabozerops.com" const width = 300 + Math.random() * 1000 const height = 300 + Math.random() * 1000 const angle = Math.random() * 360 const res = http.get(`${baseUrl}/image?width=${width}&height=${height}&angle=${angle}`) check(res, { 'is status 200': (r) => r.status === 200, }); } And then run it by invoking k6 run --vus 100 --duration 120s k6.js This will simulate 100 users requesting the image service as fast as possible for 120 seconds. Our example is mainly a CPU-intensive task so you will see the number of vCPUs (virtual CPUs) rise -- vertical scaling -- and after a short time also see more containers being created -- horizontal scaling. Please refer to the following screenshot where you see many vCPUs and 4 containers. After the k6 script finished generating the load, will wait for a moment to make sure the demand has really gone down. Then you'll first see the vertical autoscaling taking action by reducing vCPUs (due to the nature of our example). The number of vCPUs has dramatically decreased. Zerops After a while, will perform the horizontal autoscaling as well. As the k6 script finished generating load and we don't have any more coming, the starting point with two containers will be reached as shown in the screenshot. Zerops Summary is performing both vertical and horizontal autoscaling out of the box with a single click. Just like shown in the example above. No need to have a special code or knowledge. It both saves money and gives you more power when required. Zerops For a deeper dive into what’s happening behind the scenes of Zerops autoscaling, check out . my previous article Also published . here