Dormeto

Docs

Napping

An idle workload naps: its requests go to the waker, then its backends stop.

4 min read

A workload naps once no request reached it for its idle window. Each timeline replays one workload, a nap cancelled, then a nap.

Amazon Web ServicesAWS

Elapsed

  1. your load balanceryour instancesA visitor’s last request reaches your instances.
  2. EventBridge Schedulerthe controllerThe idle check runs, every 5 minutes. A request came within 15 minutes: no nap.
  3. EventBridge Schedulerthe controlleryour load balancerThe check finds no request for 15 minutes. The controller switches your rules to the waker.
  4. your load balancerthe wakerA request reaches the waker during the drain. The waker keeps its wake, and holds it.
  5. the controlleryour load balancerThe drain ends with a wake kept: the rules go back, and nothing stops.
  6. the wakerFifteen seconds later, the held request gets a 307 to the same URL, and your instances answer.
  7. EventBridge Schedulerthe controlleryour load balancerNo request since 18:45: the check naps it again, and the rules switch to the waker.
  8. the controlleryour instancesThe 30 s drain ends. The controller stops the instances: a request now waits for the stop, then wakes it.
  9. the controllerthe manager’s busThe instances are stopped: the workload is asleep. The router puts the change on the manager’s bus.
The check, the idle window and the drain are the built-in values. The stop’s minute is an example: it depends on your backends.

Google Cloud

Elapsed

  1. your load balanceryour VMsA visitor’s last request reaches your VMs.
  2. Cloud Schedulerthe controllerThe idle check runs, every 5 minutes. A request came within the window: no nap.
  3. Cloud Schedulerthe controlleryour URL mapNo request for 15 minutes and 210 s more. The controller writes the nap’s error response to your URL map.
  4. your load balanceryour VMsA request reaches your VMs: they serve while the change spreads.
  5. the controlleryour URL mapAfter 5 minutes, the controller reads the requests again. One came: it gives the nap up and removes the error response.
  6. Cloud Schedulerthe controlleryour URL mapNo request since 25:00: the check asks for the nap again, and the error response is written.
  7. the controlleryour VMsFive minutes later, no request came. The controller stops or suspends the VMs.
  8. the controllerthe manager’s busThe VMs are down: the workload is asleep. The router puts the change on the manager’s bus.
Behind a global load balancer, with the built-in idle window. The stop’s minute is an example: it depends on your VMs.

The steps

  1. The idle check runs the controller every 5 minutes, on the clock’s 5-minute marks.
  2. The controller reads each awake workload’s requests over its idle window.
  3. With none, the controller sends the workload’s requests to the waker, then waits.
  4. A request during the wait cancels the nap: the route goes back, and nothing stops.
  5. After the wait, the controller stops the backends, scales them to zero or suspends them.
  6. A request during the stop wakes the workload once the stop ends.
  7. Asleep, the router reports the change to the manager, as it reports every change of state.

Amazon Web ServicesAWS

  • The check reads CloudWatch’s RequestCount of the target group, in one-minute sums.
  • The switch sets your rules’ forward weights: 0 to your target group, 1 to the waker’s.
  • The wait is the Drain: the rule change reaches every load balancer node.
  • A request at the waker during the drain is held, then redirected once the rules are back.

Google Cloud

  • The check reads the request counts, or the request logs, 210 s further back: Google publishes them late.
  • On a global load balancer, the switch writes a custom error response in each path matcher. The other kinds swap the map’s references.
  • The wait lets the change reach the load balancer: 5 minutes for the error response. A swap’s own wait is on Waking.
  • After the wait, the controller reads the requests again: one gives the nap up.

Parts and permissions

Each part calls with its own role, which Roles lists.

ComponentAWSGoogle CloudWhat it does
The idle checkAmazon EventBridge SchedulerEventBridge Scheduler, as the scheduler roleCloud SchedulerCloud Scheduler, as the router’s accountRuns the controller every 5 minutes.
The controllerAWS LambdaLambda, as the controller roleCloud RunCloud Run, as dormetoRouterReads the requests, switches the route, stops the backends.
Request countsAmazon CloudWatchCloudWatchCloud Monitoring and Cloud LoggingCloud Monitoring, Cloud LoggingRead by the controller.
The routeElastic Load BalancingYour listener rulesCloud Load BalancingYour URL mapSent to the waker for the nap.
Your backendsTagged dormeto:workloadTagged dormeto=managed, as dormetoRouterBackendsStopped, suspended or scaled to zero.
The managerAmazon EventBridgeIts event busAmazon EventBridgeIts event bus, with credentials from its APITakes each change of state (Architecture).

What can go wrong

  • A paused workload never naps, and a pause written during a nap cancels it.
  • A nap that fails leaves the workload failed, with its reason: Workloads.
  • A schedule’s windows win over the idle rules: Scheduler.

Amazon Web ServicesAWS

  • A rule that forwards to the target group without Dormeto’s rule is an issue. The workload naps only once it is fixed.
  • A router runs at most 10 naps at a time: Workloads.

Google Cloud

  • A change of the backends since the onboarding gives the nap up as backends-changed.
  • A router has at most 20 naps in flight: Workloads.