drift Docs
Pages
drift Docs
Start
What is Drift?
The tour, if you are new here.
Use cases
Whether Drift does your thing.
Getting started
Nothing to deployed, in one command.
Architecture
How a slice is put together.
What it costs
The free grant, four unit prices, two rules.
Moving off Azure
Estimate, snapshot and transform a resource group.
Build
Canvas
Static sites, same origin as your API.
Tools
Operate
Auth
Route gates, API keys and your account.
Teams
More than one person on one account.
Security
Boundaries, sandboxing and hardening.
Troubleshooting
Error codes
What went wrong, and what to do about it.
Legal
Acceptable use
What a slice may not be used for.
Data processing
The DPA, and every sub-processor.

Backends

A backend is a single-language backend, Drift's unit of a “service” (what you'd put in one container elsewhere), minus the container. One language, one dependency manifest (go.mod / requirements.txt / package.json / …), and as many functions as you like across flat files in one folder.

The common case is the simplest there is: drop your handlers straight into atomic/ as flat files, with no per-function folders. That flat set is a backend (the implicit default one), and a function belongs to it by being declared in backend "default" inside the atomic block:

  • atomic/one backend, one language, one backend
    • auth.goPOST /signup · POST /login · GET /me
    • groups.gocreate · list · join · get
    • lib.goshared helpers, just a sibling file
    • go.modone manifest for the whole backend

Need a second language? That's a second backend, a second service. Give each its own folder under atomic/ (say atomic/api/ in Go and atomic/ml/ in Python), each with its own manifest, and declare those functions inside a backend block named for the folder:

Driftfile
slice "shop" {}

atomic {
  # Go, in ./atomic/api
  backend "api" {
    function "POST /signup" {
      handler = "PostSignup"
      memory  = "32MiB"
    }
  }

  # Python, in ./atomic/ml
  backend "ml" {
    function "POST /predict" {
      handler = "post_predict"
      memory  = "128MiB"
    }
  }
}

A backend named anything but "default" lives in ./atomic/<name>; dir on the backend points it at another folder.

Mixing languages within one backend is refused before anything builds; a second language is, by definition, a second backend. Backends integrate through Backbone (queues, NoSQL, locks), exactly the way microservices integrate through a broker, never by importing each other.

A backend is an authoring + dependency boundary, not a URL one: a route comes from the function's label ("POST /predict"), so the backend never appears in the path. It is also the scope a handler is looked up in, which is why two backends can each have a handle. Shared code (lib.go, crypto.go) is an ordinary file in the same package and never a copy. Go, Python, Node, Ruby and PHP build as multi-function backends; a Rust backend holds one function.