Skip to content
Immutable infrastructure

Immutable infrastructure

On Clever Cloud, you don’t administer servers: the platform runs your application on instances it creates and replaces. It never updates a running instance: it starts new ones from your runtime image and your code, then stops the old ones. This is immutable infrastructure.

What replaces an instance

  • A deployment: a push, a restart, or a redeployed commit. With zero downtime deployment, the new instances get the traffic once they pass the health check, then the old ones stop. Without it, the old instances stop first.
  • A change of size that you or autoscaling trigger. Changing the number of instances doesn’t replace the others.
  • A maintenance or an image update, when Clever Cloud moves your application to a new runtime image, with updated packages
  • The monitoring, when an instance stops answering

The activity of your application lists each of these deployments.

What persists

Your code, your environment variables, the data of your add-ons, and files in an FS Bucket or Cellar Object Storage persist.

What only exists on an instance disappears with it: files written on its disk, packages installed by hand, changes made through SSH, and data in memory. Sessions kept in memory, for instance, log your users out when their instance is replaced.

Build for this model

  • Keep your configuration in environment variables, and install your tools during the build, with deployment hooks or Mise
  • Store your data and your sessions outside the instance, in add-ons, an FS Bucket, or Cellar Object Storage
  • Start fast to shorten each replacement: with zero downtime deployment, old instances serve until the new ones are healthy
  • Debug an instance through SSH if you need to, then bring the fix to your code and redeploy
  • To roll back, redeploy a previous commit from the activity of your application
Last updated on