Skip to content
Coritan Docs

Choose locations and scaling

Choose locations, scale instances with traffic, set the largest memory limit, sleep when idle, and add workers and scheduled jobs.

View as Markdown

A deployment runs in the locations you choose, and each location runs its own instances: running copies of the live release, each with a memory limit (Memory grows automatically). By default a deployment runs one instance in each location. The edge sends each visitor to the closest location that is serving, so running in several locations brings the deployment closer to its visitors and keeps it answering when one location has a problem.

A web service or a hybrid site can change its locations at any time, scale between a minimum and a maximum number of instances as traffic changes, and sleep when nobody is using it. A game server or a database keeps its own data in each location, and a static site answers from every location without instances (How each kind runs).

  • A deployment billed by use can run in up to 20 locations and scale above its minimum, once your account has made the first deposit (What you need to run an instance). On older terms the plan sets how many locations one deployment can run in: 1 on Free, 5 on Pro, and as many as you need on Business and Enterprise, up to 20. Scaling above the minimum needs Pro, Business or Enterprise there (Pricing).
  • Each instance is billed by the memory and CPU it uses while it runs, and a sleeping instance costs nothing. A deployment ordered before usage billing pays the price of its plan instead (How App Deployment is billed).
  1. Open the deployment and select the Instances tab.
  2. Under Locations, select Change locations…. The Change locations page opens.
  3. Under Where it runs, choose One location, Several or All locations. All locations takes in every location that can run it, including locations we add later.
  4. Under Instances in each location, set the fewest instances the location keeps running and the most it can scale to.
  5. Turn on Sleeps when idle to let a location stop its instances when nobody uses it (Sleep when idle).
  6. Select Save locations. We return you to the Instances tab, where the Locations card shows the change.

The live release starts in the locations you added straight away. Instances beyond a location's new count, and those of a location you removed, stop once another location is serving, so the deployment is never without an instance.

A location can run a minimum of up to 5 instances and a maximum of up to 10. A location with no room left for the plan is refused, and the error names it.

A location scales when its maximum is above its minimum. Under Scaling, select Change scaling… to open the Change scaling page. Under Scale on, choose what one instance should carry:

  • Requests a second: requests each instance should answer every second.
  • Requests at once: requests each instance should be working on at the same time.
  • CPU: how busy each instance's processor should be, as a share of its plan. Without any target, we scale to keep it at 70%.

The target that needs the most instances decides. A location adds instances when the load needs more than 10% above what it runs, at most once a minute. It removes them when one instance fewer would still carry the load at 80% of every target, at most once every five minutes and never more than half at once.

Instances above a location's minimum run only while no spend limit is reached. A deployment on older terms also needs a plan that includes autoscaling, and no used-up allowance when it is set to Stop at the allowance (At a limit). When a limit holds them back, every location goes back to its minimum until the limit is raised or the month turns. On a monthly commitment, instances above the ones you committed to are billed by the hour, as pay as you go is. A deployment billed by use has no allowance to stop at.

Each instance of a web service or a hybrid site that is billed by use runs with a memory limit. You do not choose it. We move it one step at a time along 256 MB, 512 MB, 1 GB, 2 GB, 4 GB, 8 GB and 16 GB, and you set how far it may go. A deployment on older terms keeps the memory of its plan, and its limit does not change by itself.

Where it starts
A new deployment starts at 512 MB, or at 1 GB for a Next.js app. When an order names a size, it starts at the memory of that size.
When it grows
When an instance's memory stays at or above 90% of the limit over five minutes, the limit goes up one step. The CPU cap goes up with it: 1 vCPU up to 4 GB, 2 vCPUs at 8 GB and 4 vCPUs at 16 GB. In each location we start a new instance at the new limit first, then stop the old one, so visitors see no gap. The next step waits until every instance is healthy and runs the new limit, and 10 minutes more.
When it shrinks
After 24 hours in which every instance stays under 60% of the next limit down, the limit goes down one step. It never goes below the limit the deployment started at.
The largest limit
The limit never goes past the largest limit, which is 4 GB until you change it. You can set it to any step from the current limit up to 16 GB. You can also set it when you order: Largest memory limit under Advanced on the order page, or max_memory_mb in the scaling block of the order (Order a deployment). The order refuses a value that is below the memory the deployment starts with or is not one of the steps above.

A bigger limit costs nothing until the app uses the memory. A deployment billed by use pays for the memory its instances use, and the limit itself adds nothing (How App Deployment is billed).

  1. Open the deployment and select the Instances tab.
  2. Under Scaling, read the Memory limit, the Starting limit, the Largest memory limit and the Last change, such as Grew from 1 GB to 2 GB, 3 days ago.
  3. Select Change scaling…. The Change scaling page opens.
  4. Under Memory, open Largest memory limit and choose a step. The list starts at the current limit.
  5. Select Save scaling. We return you to the Instances tab.

With the API, send max_memory_mb to PUT /scaling, or in the scaling block of the order. Leave it out, or send null, to keep the largest limit as it is. The other keys work as they always do: PUT /scaling clears a target or a sleep time you leave out, so send the ones you want to keep.

Shell
curl -X PUT https://api.coritan.com/api/v1/client/deployments/$DEPLOYMENT/scaling \
  -H "Authorization: Bearer $CORITAN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"autoscale": {"cpu": 70}, "sleep_after_seconds": 900, "max_memory_mb": 8192}'

The answer's memory block shows the new max_mb (With the API).

The limit stays where it is when an instance is near it and one of three things holds:

  • The limit is already the largest limit. The Scaling card says so, and raising the largest limit lets it grow.
  • A location has no room for the next limit. We try again until there is room, and the Scaling card says the step is waiting for room.
  • A spend limit that blocks the deployment holds it (At a limit).

An instance that runs out of memory meanwhile restarts on its own (Restarts and running out of memory).

Every step is an event, memory.limit_changed, which an organization's webhooks receive as deployment.memory.limit_changed (Deployment events). Its reason is memory_high for a step up and memory_low for a step down.

When an instance is at 90% or more of its limit and the limit cannot grow, we email the owner and send deployment.alert.memory_at_limit, at most once every 6 hours for a deployment (Get alerts). Raise the largest limit, or find what holds the memory (Restarts and running out of memory).

A location with Sleeps when idle turned on stops its instances once no request has reached them for the idle time: 15 minutes unless you set another under Sleep after, from one minute to seven days. A sleeping instance is not billed.

The next request wakes it. The edge holds the request for up to 25 seconds while an instance starts and passes its health check, then answers it as usual. If the instance is not ready by then, the visitor sees a page headed This deployment is starting, which reloads by itself after five seconds; an API client gets a 503 with Retry-After: 5. Use it for a deployment that can take a slow first answer, such as a staging copy or an internal tool.

Previews always sleep when idle. Workers and scheduled jobs never sleep, because no request comes to wake them.

Add workers and scheduled jobs

Section titled Add workers and scheduled jobs

Besides the web instances that answer requests, a web service or a hybrid site can run other commands from the same release. Under Processes, select Add process…. The Add a process page opens. Choose its Kind:

Worker
A command that runs all the time, such as a queue consumer, with the number of instances to run in each location, up to 10. A worker has no address and no health check: it is healthy once it has kept running for 10 seconds, and we replace one that stops.
Cron
A command that runs on a schedule, written as a cron expression such as */15 * * * *. It runs in the deployment's first location, never twice at once, and is stopped after an hour.
Web
The instances that answer requests. Give it a command only to run something other than the image's own start command.

Only production runs workers and scheduled jobs; previews run the web only. A worker or a scheduled job can read its process's name in CORITAN_PROCESS. A changed command reaches a scheduled job at its next run, and a worker when it next starts.

Web service or hybrid site
Everything on this page applies. The web instances answer on the port in PORT and pass the health check before they serve: two good answers in a row from the health check path. An instance that keeps using 95% or more of its memory limit is replaced with a fresh one in the same location (Restarts and running out of memory), and its limit grows first when memory stays at or above 90% (Memory grows automatically).
Game server or database
One instance in each location you chose when you ordered it, each with its own files and databases. Its locations cannot change afterwards: to run it somewhere else, take a snapshot and start a new deployment from it in that location (Start from a snapshot). Its instances have their own tabs: select one on the Instances tab, under More, to open its console, files and the rest.
Static site
No instances at all. The edge serves its files from every location (Host a static site).

The Instances tab lists every instance with its location, its release and its state, and the deployment's Overview shows each location's health, traffic and errors today.

These locations cannot run App Deployment instances now: ...
The locations it names have no room for this kind right now. Choose others; the answer lists the ones that can.
A template deployment keeps its own data in each location, so it runs where you name: single or several
A game server or a database cannot use All locations. Choose One location or Several.
The deployment does not scale above its minimum
Check that the location's maximum is above its minimum, that no spend limit is reached, and that your account has made the first deposit. On older terms, check that your plan includes autoscaling. The Instances tab says until when bursts are held when a limit or an allowance was reached.
The memory limit does not grow
The limit grows only when memory stays at or above 90% of it, and never past the largest limit. Read Largest memory limit and Memory limit under Scaling. When they match, raise the largest limit (Set the largest limit). When a notice says the step is waiting for room, the location has no room for it yet (When there is no room).
The first request after a quiet time is slow
The location was asleep. Turn off Sleeps when idle, or set a longer Sleep after.
An instance was replaced, or restarted by itself
A web instance that stays near its memory limit is replaced with a fresh one, one instance of a location at a time, and the old one stops once the new one serves. An instance that ran out of memory restarts on its own. Both are events and, for an out of memory restart, an alert. Restarts and running out of memory says how to find the cause.

The routes are under /api/v1/client/deployments/{uuid} for your own deployment and /api/v1/orgs/{org_slug}/deployments/{uuid} for an organization's.

GET /placements answers where the deployment runs and the locations it could run in now. PUT /placements takes the same block as an order's placement: mode (single, several or all), locations with each location's min, max and sleep (never or idle), and min, max and sleep for every location it does not name:

Shell
curl -X PUT https://api.coritan.com/api/v1/client/deployments/$DEPLOYMENT/placements \
  -H "Authorization: Bearer $CORITAN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"mode": "several", "locations": {"fra": {"min": 1, "max": 3}, "iad": {"min": 1, "max": 1, "sleep": "idle"}}}'

A game server or a database answers 409 with template_placement. A static site takes only {"mode": "all"}.

PUT /scaling takes {"autoscale": {"rps": 50, "concurrency": 20, "cpu": 70}, "sleep_after_seconds": 900}; a key you leave out is cleared. It also takes max_memory_mb, the largest memory limit (Set the largest limit). GET /scaling and PUT /scaling answer a memory block, which is null for a static site:

JSON
{
  "memory": {
    "limit_mb": 2048,
    "start_mb": 1024,
    "max_mb": 4096,
    "ladder_mb": [256, 512, 1024, 2048, 4096, 8192, 16384],
    "last_change": {"from_mb": 1024, "to_mb": 2048, "at": "2026-10-08T23:52:17Z", "reason": "memory_high"},
    "at_max": false,
    "waiting_for_room": false,
    "automatic": true
  }
}

limit_mb is the current limit and start_mb the one it started at. max_mb is the largest limit and ladder_mb the steps max_memory_mb may name. last_change is null until the limit first moves, and then has from_mb, to_mb, at and reason (memory_high or memory_low). at_max is true when the limit is the largest one, and waiting_for_room is true while a step waits for room. automatic is false for a deployment on a plan: its limit is its plan's size, max_mb is that limit and nothing changes by itself.

max_memory_mb must be one of the steps in ladder_mb and not below the current limit, or the answer is 422. A deployment on a plan answers 409 with memory_fixed.

PUT /processes replaces the whole list, each with name, kind (web, worker or cron), command, instances, schedule and enabled. GET /instances lists the running instances.

API operations on this page