# How Webgune works

Source : https://webgune.cloud/en-us/docs/fonctionnement · Mis à jour le 2026-11-20

# How Webgune works

This page follows a deployment from end to end: from the push to the page shown to a visitor, then what Webgune does when something goes down. Each part links to the page that details it.

## From code to a live service

```flow
title: From push to live
Build | isolated machine, 1 h at most
Image | project registry, unique ID
Start | one micro-VM per instance
*Check | the port accepts a connection
Switch | traffic moves to the new version
! Not ready within 15 min, or crash loop | the previous image is put back into service
```

### 1. The build

The builder clones the repository (10 minutes at most), detects the language and framework, installs dependencies from your lock file, then builds the application. If you chose Dockerfile mode, it builds the repository's `Dockerfile` instead.

The build runs in its own isolated machine, without privileges. It has Internet access to download dependencies and no access to any internal service: neither your database nor your API. It is stopped after one hour. An already built Docker image skips this step ([How builds work](/docs/builds-railpack)).

### 2. The image

The build's result is an image. It gets a unique identifier, taken from the commit, and joins the project's registry. The project's **Registry** tab lists each service's images. One of these images is put back online during a [rollback](/docs/deploiements-rollback), with no new build.

### 3. Startup

Each instance of the service starts in its own lightweight virtual machine, with its own Linux kernel. It sees neither the server that hosts it nor other customers' services. Three cases stay in a standard container, including services that mount a persistent volume ([One microVM per service](/docs/isolation-microvm)).

### 4. The check

Webgune considers an instance ready when its port accepts a connection. The first attempt happens 5 seconds after startup, then every 10 seconds. The deployment succeeds when all instances run the new version and are ready.

This check does not know your application's state: a port opened before initialization finishes counts as ready. Connect to the database before opening the port ([Health check](/docs/controle-de-sante)).

### 5. The switchover

For a site or an API, the new instance starts while the old one still serves visitors. Traffic switches over when the new one is ready. The old one then receives `SIGTERM` and has 30 seconds to finish its in-flight requests.

For a bot or a worker, the old instance stops completely before the new one starts. The pause lasts a few seconds.

### If the new version does not start

Webgune puts the previous image back in service in two cases: the new version crashes in a loop at startup, or it is not ready after 15 minutes. During all that time, a site or an API keeps responding with the old version. The deployment is marked as failed and the panel gives the reason.

If your application changed its database schema before failing, the old version may no longer be able to read it. This case is covered in [Database migrations](/docs/migrations-base-de-donnees).

## Service types

| Type | Examples | Instances | Update | Entry point |
|------|----------|-------------|-------------|----------------|
| Site | showcase site, Next.js, portfolio | 1 at rest, more depending on load; always 1 in "Simple service" | no downtime | domain name |
| API | REST backend, GraphQL | 1 at rest, more depending on load; always 1 in "Simple service" | no downtime | domain name |
| Bot | Discord bot | always 1 (one per shard) | the old one stops first | none, the bot connects on its own |
| Worker | sending email, processing queues | always 1 | the old one stops first | none |
| Database | PostgreSQL, MySQL, MariaDB, MongoDB, Redis | 1 | maintenance window | internal address in the project |

A bot never has two instances: two connections to Discord with the same token get disconnected or answer twice. The pause during its update is therefore intended.

A site or an API that mounts a [persistent volume](/docs/volumes-persistants) also runs as a single instance, because a volume attaches to only one instance at a time.

## The path of a visit

1. The visitor enters the site's address.
2. The request reaches the entry point, the only server visible from the Internet. Its firewall lets through only the public ports.
3. The router reads the domain name, finds the matching service and terminates the HTTPS connection with the domain's certificate.
4. The request reaches one of the service's instances, which sends back the response.

```archi
title: The path of a visit
[Internet]
Visitor | browser or app
-> HTTPS, public ports only
[Entry point]
Firewall | only server visible from the Internet
*Router | reads the domain, terminates HTTPS
-> encrypted tunnel
[Webgune servers]
Instance 1 | service micro-VM
Instance 2 | service micro-VM
```

Between the entry point and the servers, traffic travels through an encrypted tunnel. The visitor's real address is passed to your application in the `X-Forwarded-For` header.

With several instances, two successive requests from the same visitor do not necessarily reach the same one. Sessions kept in memory therefore do not work: put them in the database or in [Redis](/docs/db-redis).

## A service's resources

Each instance receives your plan's CPU and memory, with a cap of 2 CPUs and 4 GB. A quarter of the CPU and half of the memory are reserved for it, even when the server is busy. It rises to its maximum as soon as it needs to.

At the CPU maximum, the service slows down. At the memory maximum, it is stopped with code 137 then restarted ([Limits and resources](/docs/limites-ressources)).

## When something goes down

| Event | What Webgune does |
|-----------|---------------------|
| The service crashes | It is restarted. If it crashes in a loop, the delay between two restarts increases |
| The service crashes in a loop after a deployment | Webgune tries a repair based on the cause (wrong port, insufficient memory, missing variable), then puts back the last healthy image. As a last resort, the service is stopped and marked as failing |
| The service exceeds its memory | It is stopped (code 137) then restarted |
| The service exceeds its CPU | It slows down, without being stopped |
| A server goes down | Its services are restarted on another server. A service with several instances keeps responding in the meantime |
| The new version does not start | The previous version is put back in service |

A service's availability mode is set in [Availability and scaling](/docs/autoscaling).

## Sleep mode

A staging or development service with no visits is stopped after a delay that depends on your plan, from 15 minutes to 8 hours. The next visit wakes it in a few seconds. Production services, bots, workers and databases do not go to sleep ([Sleep mode](/docs/mise-en-veille)).

## What remains your responsibility

- An up-to-date [lock file](/docs/builds-railpack) in the repository.
- An application that listens on `PORT` and `0.0.0.0`, and opens its port only once ready ([Health check](/docs/controle-de-sante)).
- [Database migrations](/docs/migrations-base-de-donnees) compatible with the previous version.
- No data to keep on the service disk: a [volume](/docs/volumes-persistants) or a [database](/docs/bases-de-donnees).
- Secrets in [environment variables](/docs/variables-environnement), never in the repository.

The full list is in [Best practices](/docs/bonnes-pratiques). If something goes wrong, start with [Troubleshooting](/docs/depannage).
