---
title: Infrastructure architecture
slug: hosty/infrastructure-architecture
createdAt: 2026-11-08T12:13:24.422Z
---

This page explains what Hosty builds in AWS, how the parts fit together and where to find them in the code. It's written for admins. For a simpler overview, see [What is Hosty?](https://wiki.systemseed.com/hosty).

![Infrastructure of Hosty](https://api.archbee.com/api/optimize/J5fagZai1i-rRUBgkgJC3/5nJIjlBLNqYEqJChmamfa_hosty-architecture.png)

## How the code is organised

The infrastructure is code in `terraform/`, applied with OpenTofu. `terraform/main.tf` describes one install of Hosty: its AWS account, users, projects and clusters. It uses three modules:

| Module    | What it creates                                                                                          | How many                                    |
| --------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
| `hosting` | Route53 zone, IAM users and groups, S3 buckets for backups, logs and VPN profiles, the state of OpenTofu | One per AWS account                         |
| `project` | IAM groups of the project, its ECR repository and its SSL certificates                                   | One per project                             |
| `cluster` | VPC, EKS cluster, load balancers, database, file storage, VPN, alarms                                    | One per cluster, each in its own AWS region |

Every project lives on one cluster, set by `cluster` of the project in `main.tf`. To add a cluster, add another `cluster` module with its own region and VPC range, as described in [Adding a new cluster](https://wiki.systemseed.com/hosty/adding-a-new-cluster).

Applications are deployed with the Helm charts in `helm/` (`php`, `node`, `python` and `redis`). Hosty CLI fills them in from `.hosty/hosty.yaml` of the project.

## Network

Each cluster has its own VPC, spread over 3 availability zones. Every zone has 4 kinds of subnets:

- **public**: the load balancers and the NAT gateway;
- **private**: the servers (nodes) and the pods;
- **intra**: the EKS control plane and the VPN;
- **database**: Aurora and OpenSearch.

Servers reach the internet through a single NAT gateway, and S3 directly through a gateway endpoint, which is cheaper. To save money on a small install, `single_availability_zone` puts the servers and the database in one zone, but the sites then lose their failover.

## Traffic

- Each cluster has two load balancers (ALB): one for production and one for development environments. OpenTofu creates them, and the AWS Load Balancer Controller adds the environments to them from their ingresses.
- With `alb_cloudflare_only`, the production load balancer accepts traffic only from Cloudflare. The development one stays open.
- HTTP is redirected to HTTPS. The load balancers check `/.healthz` of every pod and send traffic only to healthy ones.
- Each project gets two SSL certificates in ACM:
  - one for its own domains, validated with DNS records in the DNS of those domains, such as in Cloudflare;
  - a wildcard `*.<project>.<hosted zone>` for development environments, validated in Route53 automatically.
- Hosty CLI doesn't deploy a domain until its certificate is issued.
- An optional internal load balancer (`internal_load_balancer`) lets applications reach each other inside the VPC by their domains.

## Kubernetes cluster

- Amazon EKS, with the API closed to the internet (`cluster_endpoint_public_access = false`), so it's reachable only through the VPN.
- Two groups of nodes: **production** and **development**. They run Bottlerocket, a small operating system made for containers. Instance type, processor architecture and the minimum and maximum number of nodes are set for each cluster.
- The cluster autoscaler adds nodes when pods don't fit, and removes them when they're no longer needed.
- Nodes update their operating system every day: a maintenance window of AWS Systems Manager runs `AWS-UpdateEKSManagedNodeGroup` at 4am London time (`updates.tf`). See [Software updates](https://wiki.systemseed.com/hosty/software-updates).
- Add-ons: VPC CNI with network policies, CoreDNS, kube-proxy, metrics-server, EFS CSI driver, CloudWatch observability, AWS Load Balancer Controller and the cluster autoscaler.

## Applications

- Each project has two namespaces, `<project>-production` and `<project>-development`. Every environment of every application is a Helm release in one of them.
- **Production** runs at least 2 pods of each application, one per node, in different zones where possible. They scale up to the number of production nodes on CPU and memory use (HPA).
- **Development** environments run 1 pod each, without autoscaling.
- Cron jobs, backups, imports and `hosty run` prefer the development nodes, so they don't take resources from production sites.
- The code in PHP and Node.js images belongs to root, so the site can't change it. Only the persistent storages (`files`, `private`, `tmp`) are writable.
- Redis runs as its own pod next to the application, with its data on EFS.

### Isolation

- **Network policies** (`network_policies.tf`): pods of a project accept connections only on the ports of their web servers, and from their own namespace. They can't reach EFS directly.
- **Pod Security**: the namespaces of projects enforce the `baseline` level.
- **Admission policies** (`helm/access-policies`) enforce rules that nobody can get around with `kubectl`:
  - only admins can delete production environments;
  - development pods run only on development nodes;
  - images come only from the ECR repository of the project;
  - ingresses serve only the domains of the project;
  - only the backup jobs of Hosty can use the backup account of production.

## Data

| Service                      | What it holds                 | Details                                                                                                                                                                                                     |
| ---------------------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Aurora (MySQL or PostgreSQL) | Databases of all projects     | One cluster with a primary and a standby instance in different zones. Each project has its own accounts, `<project>_production` and `<project>_development` (MySQL). AWS keeps 7 days of its own snapshots. |
| OpenSearch                   | Search indexes                | Optional (`opensearch_enabled`). Each environment gets its own user and index prefix.                                                                                                                       |
| EFS                          | Uploaded files and Redis data | Two file systems, production and development. Rarely used files move to cheaper storage classes automatically.                                                                                              |
| S3                           | Backups, logs, VPN profiles   | Shared by all clusters of the account. Backup buckets keep previous versions for 14 days.                                                                                                                   |
| ECR                          | Docker images                 | One repository per project. Only CI can push to it.                                                                                                                                                         |

### Backups

- Production is backed up at 0:00, 8:00 and 16:00 UTC by default. A project can change the hours with `backup.hours` in `hosty.yaml`.
- Each backup has a full dump of the database, a partial dump without the data of the tables the project lists (such as personal data), and a copy of the files.
- Database dumps are kept for `database_backup_retention_days` (365 by default), and move to S3 Glacier Instant Retrieval after 30 days.
- A production environment is backed up once more before it is deleted.
- New development environments import the latest partial dump and the files. Production imports the full one.

## Access and security

- **IAM**: every person has their own IAM user. Admins need MFA for almost everything, and developers need it to reach backups.
- **Groups per project**: developers, lead developers and release managers (CI). In Kubernetes they map to roles of their project, as described in [Roles & Permissions](https://wiki.systemseed.com/hosty/roles-and-permissions).
- **Hosty CLI** gets a 12-hour session with MFA (`hosty auth`) and talks to the cluster through the VPN.
- **Client VPN**: one connection profile per person, stored in S3. Connections are logged.
- **Pods** get their own IAM roles (IRSA): an empty one for the application, one to import backups, and one to write backups (production only).
- **Encryption**: S3, EFS, the disks of the nodes and the secrets of Kubernetes are encrypted with KMS keys.

## Monitoring and logs

- **Container Insights** collects the performance of nodes and pods, and the logs of applications.
- **Alarms** fire on high CPU, memory or disk use of nodes and pods, on pods that stopped running, on errors of the load balancer controller, on 5xx errors of production sites, and on high CPU or low memory of the database.
- Alarms go to an SNS topic. A Lambda function (`terraform/functions/alarms`) posts them to Slack, and they're also sent by email.
- **Logs** are kept for 90 days: Kubernetes audit, applications, the database, the VPN, the access logs of the load balancers and the access to backups (CloudTrail).

See [Observability](https://wiki.systemseed.com/hosty/observability) for more.
