You need shop-api Running in your lab environment from lab 6.2.4, room for a second Flex spherelet, and a plan with autoscaling.
Making room, and a shop if you need one
A trial account runs two Flex spherelets in total. Delete the other services in your lab environment (csph services list, then csph services delete <service-id>) so shop-api can use both.
No shop-api? Save this as shop-api.yaml and run csph deploy --file shop-api.yaml:
version: "2"
services:
- name: shop-api
type: web-service
image: quay.io/computesphere/learn-shop-api:1.4.0
port: 8080
env_vars:
REQUIRE_SIGNING_KEY: "false"
Autoscaling comes with the Team plan and above. On another plan, do steps 1 and 2, and read the rest.
Scale out to two
csph services list csph deployments list --service <service-id> csph deployments scale <deployment-id> --spheres 2You should seeThe Spherelets card shows 2, and shop-api is Running again.
See both on the graph
Open
shop-api, then Metrics. Set the time range to Last 15 minutes (or Last 5 minutes) and choose Apply: the 1-hour view may not show the step. It can take 3 to 5 minutes to appear.You should seeThe Spherelets chart steps from 1 to 2.
Hand the count to autoscaling
Open Settings. On the Spherelets card choose Edit and set Spherelets to 1. Turn on Enable Auto-Scaling; set CPU utilization threshold 50, Min spherelets 1, Max spherelets 2. Choose Save, then Save & redeploy.
You should seeThe card shows Auto scaling Enabled, CPU target 50%, and 1 — 2 under a second Spherelets label.
Put it under load
Wait for Running with one spherelet, then, with the URL from
shop-api's page in the console:curl "https://<your-shop-api-url>/burn?seconds=300"The spherelet that answers keeps one thread busy for five minutes.
You should seeJSON with burning true and seconds 300.
Watch it scale out
Watch the CPU and Spherelets charts on the Metrics tab, still on the 15- or 5-minute range.
Check yourself
You should seeThe CPU chart climbs past half the spherelet's vCPU. About a minute later a second spherelet starts; the chart shows it a few minutes after that.
Watch it scale back
Keep the Metrics tab open. The count waits for CPU to stay low before it drops.
You should seeSpherelets returns to 1 about six minutes after the burn ends.
Check your work
If this doesn't pass
If csph scale was refused or the second spherelet never started, another service is using your Flex spherelets. Delete it and scale again.
If this doesn't pass
If Enable Auto-Scaling can't be switched on and says Only 1 Spherelet possible, set Spherelets to 1 first, in the same edit.
If this doesn't pass
Still 1 on the chart? Check the time range is 15 or 5 minutes, and that CPU rose. If the burn ended, call /burn again.