Choosing a runtime
DigitalOcean gives you several places to run code. They differ in what starts your program, how long it lives, and how much of the machine underneath is yours to look after. App Platform and Functions run the same kind of Alchemy program and take the same bindings. Kubernetes and Droplets run what you put on them.
The same program on App Platform and Functions
Section titled “The same program on App Platform and Functions”You declare either one with an id, its configuration and an Effect. Construction binds what the program uses, and it returns a fetch handler:
import * as DigitalOcean from "@alchemy.run/digitalocean";import * as Effect from "effect/Effect";import * as HttpServerResponse from "effect/http/HttpServerResponse";import { Uploads } from "./resources.ts";
export default class Api extends DigitalOcean.App<Api>()( "Api", { main: import.meta.url, region: "nyc" }, Effect.gen(function* () { const getObject = yield* DigitalOcean.Spaces.GetObject(Uploads); return { fetch: Effect.gen(function* () { const object = yield* getObject({ Key: "hello.txt" }); return HttpServerResponse.text(String(object.ContentLength ?? 0)); }).pipe(Effect.orDie), }; }).pipe(Effect.provide(DigitalOcean.Spaces.GetObjectHttp)),) {}Change DigitalOcean.App to DigitalOcean.Functions.Function and region to namespace, and the same handler runs as a Function. The bindings don’t change.
App Platform services: answer HTTP
Section titled “App Platform services: answer HTTP”An App runs your program as a container behind HTTPS, with as many instances as you ask for. Instances keep running between requests, so there’s no cold start, and you pay for them by the second whether or not traffic arrives.
It’s an easy place to start, and it fits APIs, websites and anything that holds state in memory between requests.
App Platform jobs: run on a schedule
Section titled “App Platform jobs: run on a schedule”A scheduled job runs the App’s own image on a cron schedule, does its work and exits. It shares the App’s code and bindings, so a nightly report is a few lines next to the handler.
Functions: run per request
Section titled “Functions: run per request”A Function runs only while a request is in flight and is billed per run, in gigabyte-seconds. An idle Function costs nothing. A cold one takes a moment to start.
It fits spiky or rare traffic: webhooks, small APIs, scheduled tasks with a trigger.
Kubernetes: run anything on a cluster
Section titled “Kubernetes: run anything on a cluster”DigitalOcean Kubernetes runs the control plane; your workloads run on node pools, groups of Droplets of one size. You apply manifests from the same Stack.
A cluster takes about ten minutes to create and its nodes cost money while they exist. Choose it when you want Kubernetes itself: Helm charts, operators, or workloads you already run on it.
Droplets: a virtual machine
Section titled “Droplets: a virtual machine”A Droplet is a VM: you choose its size and image, and everything on it is yours, from the packages to the security updates. It runs, and is billed, until you destroy it.
Choose it for software that needs a whole machine: a game server, a database you run yourself, a long-running process with local disk.
- size
- s-1vcpu-1gb
- image
- ubuntu-24-04-x64
- region
- nyc3
Mix runtimes in one app
Section titled “Mix runtimes in one app”An app rarely needs just one. A common shape is an App for the API with a nightly job, and a Function for webhooks the API calls:
Each runtime gets its own keys from its own bindings, each reaching one resource.