A test environment on a VPS: short-lived servers without wasted spend
A test environment doesn't live long: checking a release before it goes out, showing a client the new version of a site, reproducing a bug on a clean system, running a load test or trying unfamiliar software without touching the production server. Keeping a permanent machine for this doesn't pay, and a local virtual machine on a laptop doesn't give you a real public IP, domain and network. So test environments are most conveniently spun up on a VPS with hourly billing; the table above lists such plans with 2 GB of memory or more.
What a host should offer for test environments
- Hourly billing: a server deleted after three hours costs three hours. How such billing works and how stopping differs from deleting is explained on the VPS with hourly billing page.
- Fast provisioning: a minute or two from clicking the button to SSH. Hosts with instant provisioning don't hold your order for manual review.
- Snapshots and images: save a configured environment and deploy copies of it instead of installing again.
- API and cloud-init: create and delete servers from a script or pipeline, passing the initial configuration at creation.
- A choice of OSs: new and old versions of Ubuntu, Debian, AlmaLinux, sometimes Windows Server, so you can check how the application behaves in the environment your customers run it in.
Snapshots: the main tool for a test environment
A snapshot captures the entire state of the disk. A typical technique is to bring the environment to a "golden" state (OS, dependencies, a database with test data), take a snapshot and roll back to it before every run. That way each test starts from the same state, and the result doesn't depend on leftovers from previous runs. From the same snapshot you can create several identical servers to test two branches or two configurations in parallel.
Remember that many hosts charge separately for storing snapshots and images, even after the server itself has been deleted. Old snapshots should be cleaned up as regularly as the environments themselves.
Environments from CI
The next step is creating environments automatically. For every merge request, the pipeline brings up a VPS through the API or Terraform, deploys the branch to it, runs end-to-end tests or hands out a link to a review environment, and deletes the server once the request is closed. Such scenarios need a host with an API and hourly plans; the builds themselves are better kept on a permanent runner, and choosing one is covered on the VPS for CI/CD page.
To keep an environment from living forever, add a safety net: a label with the creation date and a scheduled job that deletes everything older than a day or a week. Forgotten servers are the main source of overspending on test environments.
Which configuration to take
For a test environment for a site, bot or API, 2 cores and 2–4 GB of memory are enough. If the environment runs several containers with a database, aim for 4–8 GB. A load test is the exception: the environment must match production in CPU, disk and memory, otherwise the numbers tell you nothing. And it's better to put the load generator on a separate VPS so that it doesn't share resources with the service under test. When checking latency for different regions, create a short-lived server in each location you need: it's easier to see the real ping that way than from other people's measurements.
Typical mistakes and security
- The environment doesn't match production: a different version of the OS, PHP or database, and the test passes where the live server will fail. Pin versions in the image or deployment script.
- Manual setup: if the environment is built by hand, you won't get a second identical one. Ansible, Docker Compose or cloud-init make it reproducible.
- Stopping instead of deleting: a powered-off server often keeps being billed for its disk and IP.
- One shared environment for everyone: two developers deploy their branches at the same time and get in each other's way; it's cheaper to give each their own short-lived server.
Test environments are often brought up "for five minutes" with a root password and open ports, and a week later they end up in a botnet. Even for a temporary server, log in with an SSH key, close databases and panels to the internet, and don't copy real customers' personal data to the environment; use anonymised or generated data. Put review environments behind basic auth so that search engines don't index them.
If you only want to try a host rather than keep a test environment, look at plans with a free trial period: a few days are enough to check disk speed, the network and how convenient the panel is.