We buy the servers we test with our own money. Some links are affiliate links; they never change a verdict. Disclosure · How we test

To host an AI agent 24/7 you need three things: a supervisor that restarts it, enough RAM for its peak rather than its idle, and a decision on where the model runs. If the model is an API, a 6.64 € Hetzner CX23 (2 vCPU, 4 GB) is enough: our n8n agent runtime peaked at 1003.0 MiB under 50 concurrent requests. If the model runs on the same box, Llama 3.1 8B needs at least 8 GB; on 4 GB it was killed by the kernel.

This matters now because agents moved from notebooks to things that answer webhooks, watch inboxes and run on schedules. Hosted agent platforms are multiplying and the prices on their landing pages rarely say what hardware you get. We rented the servers, ran n8n and Ollama on them and kept the numbers.

Verdict

For an agent that calls a model API, rent a Hetzner CX23 at 6.64 €: n8n handled 15.04 executions/s with zero failed requests on it. For an agent with a local model, rent a CX43 at 19.35 €: it ran Llama 3.1 8B at 9.7 tokens/s using 6023 MiB, leaving room for n8n beside it.

Tested in the Lab Hetzner CX23, CX33, CX43, CAX11, CAX21 · Nov 2026

This guide is part of our self-hosted LLM section. If you only need a model server without an agent, see Ollama on a VPS.

What "always on" actually requires

An agent is a loop: it waits for a trigger (a webhook, a cron schedule, a new message), calls a model, maybe calls tools, and writes a result. Running it 24/7 is less about speed and more about not dying quietly. The checklist:

  1. Process supervision. Something must restart the agent after a crash and after a reboot. In Docker that is a restart policy; for a bare process it is systemd.
  2. RAM for the peak. Agents spike when several triggers arrive at once or when a payload is large. Our test servers had no swap configured (0 MiB), so running out of memory meant the kernel's OOM killer stopped a process. OOM is "out of memory".
  3. A model that is ready. A local model must be loaded in RAM to answer quickly. An API model must have a key, a budget cap and a retry plan.
  4. Logs and a heartbeat. You want to know it stopped before your users tell you.
  5. Memory leaks under control. A long-running Python or Node process can grow slowly. A scheduled restart or a memory limit in the supervisor keeps it bounded.

Supervision: the exact settings

Docker: restart policies

Our production n8n compose file sets restart: unless-stopped on both containers:

services:
  postgres:
    image: postgres:16
    restart: unless-stopped
  n8n:
    image: docker.n8n.io/n8nio/n8n:2.46.6
    restart: unless-stopped

Docker's docs define the options: no is the default and never restarts; on-failure restarts after a non-zero exit code; always restarts whenever the container stops; unless-stopped is like always except a container you stopped by hand stays stopped, even after the Docker daemon restarts. One trap: "A restart policy only takes effect after a container starts successfully", which Docker defines as being up for at least 10 seconds. An agent that crashes on start loops in a broken state rather than recovering, so check docker compose ps after deploying.

systemd: for a Python or Node agent

For a LangChain, CrewAI or AutoGen script running as a plain process, systemd is already on every Ubuntu server. Its manual lists the Restart= values no, on-success, on-failure, on-abnormal, on-watchdog, on-abort and always; the default is no, and RestartSec= defaults to 100 ms. A minimal unit, using only those documented options plus standard fields:

[Unit]
Description=My AI agent
After=network-online.target

[Service]
WorkingDirectory=/opt/agent
ExecStart=/opt/agent/venv/bin/python agent.py
Restart=always
RestartSec=5
User=agent

[Install]
WantedBy=multi-user.target

Save it as /etc/systemd/system/agent.service, then run systemctl daemon-reload and systemctl enable --now agent. Logs: journalctl -e -u agent.

Ollama itself

Ollama's Linux docs give a service unit with Restart=always and RestartSec=3, and logs via journalctl -e -u ollama. On our servers, the official install script left Ollama answering on port 11434 straight away. To change its settings, the FAQ says to run systemctl edit ollama.service and add an Environment line under [Service].

While you are in systemd land: on Ubuntu 24.04 and newer, sshd runs via ssh.socket, so systemctl reload ssh fails with "ssh.service is not active" even though new connections already use your new SSH config. We hit it on every test server. Our hardening steps are in securing an Ubuntu VPS.

Sizing the agent runtime: our n8n numbers

n8n is a common agent runtime: its AI Agent node calls a model and tools from a workflow, and webhooks or schedules trigger it. We ran n8n 2.46.6 with Postgres 16 on five Hetzner servers and hit a webhook → Code node → response workflow at 1, 10, 25 and 50 concurrent requests:

ServerConcurrent requestsExecutions/sMedianp95Failedn8n peak RAM
Hetzner CX232 vCPU · 4 GB · x86_64110.1104 ms162 ms0520 MiB
Hetzner CX232 vCPU · 4 GB · x86_641014.8697 ms893 ms0660 MiB
Hetzner CX232 vCPU · 4 GB · x86_642515.01,651 ms1,936 ms0825 MiB
Hetzner CX232 vCPU · 4 GB · x86_645014.23,445 ms3,954 ms01,003 MiB
Hetzner CX334 vCPU · 8 GB · x86_64113.572 ms133 ms0543 MiB
Hetzner CX334 vCPU · 8 GB · x86_641031.9311 ms438 ms0574 MiB
Hetzner CX334 vCPU · 8 GB · x86_642529.5841 ms986 ms0803 MiB
Hetzner CX334 vCPU · 8 GB · x86_645030.11,647 ms1,846 ms01,050 MiB
Hetzner CX438 vCPU · 15 GB · x86_64114.678 ms123 ms0546 MiB
Hetzner CX438 vCPU · 15 GB · x86_641036.1280 ms341 ms0544 MiB
Hetzner CX438 vCPU · 15 GB · x86_642535.0714 ms800 ms0694 MiB
Hetzner CX438 vCPU · 15 GB · x86_645032.41,539 ms1,682 ms01,016 MiB
Hetzner CAX112 vCPU · 4 GB · aarch64110.3113 ms156 ms0585 MiB
Hetzner CAX112 vCPU · 4 GB · aarch641013.9755 ms934 ms0640 MiB
Hetzner CAX112 vCPU · 4 GB · aarch642512.91,909 ms2,279 ms0729 MiB
Hetzner CAX112 vCPU · 4 GB · aarch645013.23,786 ms4,114 ms01,038 MiB
Hetzner CAX214 vCPU · 8 GB · aarch64112.0107 ms128 ms0539 MiB
Hetzner CAX214 vCPU · 8 GB · aarch641025.4402 ms528 ms0579 MiB
Hetzner CAX214 vCPU · 8 GB · aarch642525.8965 ms1,106 ms0824 MiB
Hetzner CAX214 vCPU · 8 GB · aarch645024.52,019 ms2,197 ms0859 MiB

Measured by AI Hosting Lab on 2026-11-05 · 5 servers · method · raw data

Idle, n8n used 402.7 MiB on the CX23 and Postgres 58.75 MiB. Under 50 concurrent requests, n8n peaked at 1003.0 MiB on the CX23 and at 1038.3 MiB on the ARM CAX11, with zero failed requests on every server. (MiB is a mebibyte, 1,048,576 bytes.) For an agent whose model sits behind an API, the runtime is light: the 4 GB plans are enough, and the work is mostly waiting on the API.

Throughput is rarely your limit for an agent. The CX23 managed 15.04 executions/s with our tiny workflow. A real agent run that waits several seconds for a model answer will be far slower per run, and that waiting costs no CPU.

Sizing a local model: our Ollama numbers

We ran Ollama natively, CPU only, with Llama 3.2 1B, Llama 3.2 3B and Llama 3.1 8B (the default q4 quantization from the Ollama library), a 256-token answer at temperature 0. Tokens/s is how many tokens (word pieces) the model writes per second.

ServerModelGeneration
tokens/s
Prompt
tokens/s
Load timeRAM used (system)Note
Hetzner CX232 vCPU · 4 GB · x86_64Llama 3.2 1B10.3454.03.5 s2,001 MiB
Hetzner CX232 vCPU · 4 GB · x86_64Llama 3.2 3B5.8325.28.8 s3,002 MiB
Hetzner CX232 vCPU · 4 GB · x86_64Llama 3.1 8Bdid not run–––OOM-killed after ~50 s: Ollama fit check reported it would leave 1698 MiB free,
Hetzner CX334 vCPU · 8 GB · x86_64Llama 3.2 1B23.21,322.82.0 s2,205 MiB
Hetzner CX334 vCPU · 8 GB · x86_64Llama 3.2 3B13.5776.53.7 s3,068 MiB
Hetzner CX334 vCPU · 8 GB · x86_64Llama 3.1 8B6.3258.610.0 s5,941 MiB
Hetzner CX438 vCPU · 15 GB · x86_64Llama 3.2 1B37.51,910.91.7 s2,293 MiB
Hetzner CX438 vCPU · 15 GB · x86_64Llama 3.2 3B21.21,161.33.7 s3,196 MiB
Hetzner CX438 vCPU · 15 GB · x86_64Llama 3.1 8B9.7447.47.9 s6,023 MiB
Hetzner CAX112 vCPU · 4 GB · aarch64Llama 3.2 1B15.0835.54.8 s2,203 MiB
Hetzner CAX112 vCPU · 4 GB · aarch64Llama 3.2 3B6.5376.46.0 s3,214 MiB
Hetzner CAX112 vCPU · 4 GB · aarch64Llama 3.1 8Bdid not run–––llama-server process has terminated: exit status 1: ggml_aligned_malloc: insuffi
Hetzner CAX214 vCPU · 8 GB · aarch64Llama 3.2 1B26.81,427.13.2 s2,315 MiB
Hetzner CAX214 vCPU · 8 GB · aarch64Llama 3.2 3B12.2664.15.2 s3,282 MiB
Hetzner CAX214 vCPU · 8 GB · aarch64Llama 3.1 8B5.7226.512.3 s5,796 MiB

Measured by AI Hosting Lab on 2026-11-05 · 5 servers · method · raw data

Three results decide the server:

  • Llama 3.1 8B does not run on 4 GB. On the x86 CX23, Ollama's fit check reported it would leave 1698 MiB free, then the kernel OOM killer stopped llama-server after about 50 seconds. On the ARM CAX11 it failed at once while trying to allocate 4402.48 MB.
  • On 8 GB it runs, but slowly. 6.3 tokens/s on the CX33 with 5941 MiB of system RAM used; 5.7 tokens/s on the CAX21 with 5796 MiB.
  • On 16 GB it has room. 9.7 tokens/s on the CX43 with 6023 MiB used out of 15613 MiB.

For an agent that chains several model calls per task, speed adds up. At 9.7 tokens/s a 256-token answer takes about 26 seconds; at 13.5 tokens/s (Llama 3.2 3B on the CX33) about 19 seconds. That is fine for an inbox triage agent that runs in the background, and too slow for a live chat agent. More per model: Llama 3.1 8B requirements.

The cold-start trap

Ollama's FAQ says: "By default models are kept in memory for 5 minutes before being unloaded." An agent that fires every 15 minutes therefore loads the model from disk on almost every run. We measured that load time on the first request:

ServerLlama 3.2 3B loadLlama 3.1 8B load
CX33 (4 vCPU, 8 GB)3.7 s10 s
CX43 (8 vCPU, 16 GB)3.7 s7.9 s
CAX21 (4 vCPU ARM, 8 GB)5.2 s12.3 s

To keep the model loaded, set OLLAMA_KEEP_ALIVE to a negative value such as -1 (the FAQ: "any negative number which will keep the model loaded in memory"), or pass keep_alive per request. The price is RAM that is never free, which is exactly why the 8B model belongs on 16 GB when n8n shares the box.

Two more defaults matter for agents: Ollama processes 1 request per model at a time unless you raise OLLAMA_NUM_PARALLEL, and it uses a 4096-token context window by default. Long agent histories need a bigger context, which needs more RAM; we have not measured that yet.

Put it together: RAM for your agent

Tick what runs at the same time. The calculator adds our measured idle figures for Ubuntu, Docker and n8n with Postgres, the measured RAM of the model you pick and some headroom, then names the cheapest tested server that fits. It is an estimate built from separate measurements; we have not yet measured n8n and a local model loaded on the same server.

Recommended servers for a 24/7 agent

SetupServerPrice/monthMeasured reason
Agent runtime, model via APIHetzner CX23, 2 vCPU, 4 GB6.64 €n8n 15.04 executions/s, peak 1003.0 MiB, 0 failed
Agent runtime on ARM, model via APIHetzner CAX11, 2 vCPU, 4 GB7.25 €n8n 13.9 executions/s, 0 failed
Agent + small local model (1B to 3B)Hetzner CX33, 4 vCPU, 8 GB10.27 €Llama 3.2 3B 13.5 tokens/s, 3068 MiB used
Agent + Llama 3.1 8BHetzner CX43, 8 vCPU, 16 GB19.35 €9.7 tokens/s, 6023 MiB used of 15613 MiB

Prices are gross from the Hetzner Cloud API (Helsinki), checked 5 November 2026:

PlanCPUvCPURAMDiskPer month excl. VATPer month incl. 21% VATPer hour incl. VAT
CAX11arm24 GB40 GB5.99 €7.25 €0.0116 €
CAX21arm48 GB80 GB10.49 €12.69 €0.0203 €
CAX31arm816 GB160 GB20.99 €25.40 €0.0407 €
CAX41arm1632 GB320 GB40.99 €49.60 €0.0795 €
CCX13x8628 GB80 GB42.99 €52.02 €0.0834 €
CCX23x86416 GB160 GB85.99 €104.05 €0.1667 €
CCX33x86832 GB240 GB138.49 €167.57 €0.2685 €
CCX43x861664 GB360 GB275.99 €333.95 €0.5352 €
CCX53x8632128 GB600 GB533.49 €645.52 €1.0346 €
CCX63x8648192 GB960 GB853.49 €1,032.72 €1.6550 €
CPX11x8622 GB40 GB5.49 €6.64 €0.0106 €
CPX02x8611 GB20 GB5.99 €7.25 €0.0116 €
CPX21x8634 GB80 GB9.49 €11.48 €0.0184 €
CPX12x8612 GB40 GB11.49 €13.90 €0.0223 €
CPX31x8648 GB160 GB17.49 €21.16 €0.0339 €
CPX22x8624 GB80 GB19.49 €23.58 €0.0378 €
CPX41x86816 GB240 GB32.49 €39.31 €0.0630 €
CPX32x8648 GB160 GB35.49 €42.94 €0.0688 €
CPX42x86816 GB320 GB69.49 €84.08 €0.1348 €
CPX51x861632 GB360 GB70.99 €85.90 €0.1377 €
CPX52x861224 GB480 GB100.49 €121.59 €0.1948 €
CPX62x861632 GB640 GB129.99 €157.29 €0.2520 €
CX23x8624 GB40 GB5.49 €6.64 €0.0106 €
CX33x8648 GB80 GB8.49 €10.27 €0.0165 €
CX43x86816 GB160 GB15.99 €19.35 €0.0310 €
CX53x861632 GB320 GB29.49 €35.68 €0.0572 €

From the Hetzner Cloud API, location hel1, checked 2026-11-05. "Incl. VAT" is what our Czech (EU consumer) account pays; businesses and buyers outside the EU usually pay the price excl. VAT. Primary IPv4 is billed separately.

Hetzner CX23: agent with an API model

  • Best for: n8n or a Python agent that calls OpenAI, Anthropic or another API.
  • Main drawback: no room for a local model beyond 1B to 3B, and Llama 3.1 8B was OOM-killed on it.
  • Skip it if: you want any local model loaded next to n8n permanently.

Hetzner CX33: agent with a small local model

  • Best for: classification, extraction and summaries with Llama 3.2 3B, keeping data in-house.
  • Main drawback: 8B runs at 6.3 tokens/s and fills most of the 7751 MiB.
  • Skip it if: your agent needs an 8B model and n8n together.

Hetzner CX43: agent with Llama 3.1 8B

  • Best for: a fully local agent where no prompt leaves your server.
  • Main drawback: 9.7 tokens/s is still too slow for live chat.
  • Skip it if: an API model is acceptable; a CX23 plus API spend is cheaper at low volume.

Hetzner CAX21 (ARM): the alternative

4 ARM vCPUs and 8 GB for 12.69 €. n8n reached 25.77 executions/s, Llama 3.1 8B 5.7 tokens/s. n8n, Postgres and Ollama all ran on ARM in our tests; check that every other image you need has an arm64 build. Details: Ollama on ARM.

Order at Hetzner Cloud. We earn no commission there; it wins on our measurements, not on payouts.

Model on the server or via API?

A CPU server has a fixed price and a fixed speed. An API has no fixed price and charges per token. The calculator below takes a measured server and model, the hours a day it generates, and your API price per million output tokens, and tells you which is cheaper per million tokens:

For most agents the honest answer is the API, because an agent generates in bursts and a server you pay for 24 hours sits idle most of the day. The local model wins when privacy is the requirement, or when the agent works through a queue for many hours every day. Full method on cost per million tokens.

Other hosts (not yet tested in our Lab)

We have not run agents, n8n or Ollama on these yet; testing is scheduled and this page will be updated. Figures are from official pricing pages opened on 5 November 2026:

Provider and planSpecsPriceRegular or usage price
Hostinger KVM 22 vCPU, 8 GB, 100 GB NVMe$8.79/month, paying $210.96 for 24 monthsRenews at $14.99/month
Hostinger KVM 44 vCPU, 16 GB, 200 GB NVMe$12.99/month, paying $311.76 for 24 monthsRenews at $28.99/month
DigitalOcean Basic Droplet4 vCPU, 8 GiB, 160 GiB SSD$48.00/monthSame
Railway HobbyPer-second usage, up to 48 GB RAM per service$5/month incl. $5 of usage$10 per GB RAM and $20 per vCPU per month

Railway's usage pricing deserves a calculation: an agent process that holds 1 GB of RAM around the clock costs about $10 a month in memory alone before CPU, so its fit is small agents that sleep. Hostinger's KVM 2 has the RAM of a CX33 at a promo price; compare its renewal price, which is what you pay after the first term. Links: Hostinger VPS, DigitalOcean, Railway, none with commission today.

Hosted "agent platforms" that run the agent for you exist too. They trade control for setup time, and most of their pricing pages do not say what CPU or RAM you get. If you compare one, ask for the RAM figure and the restart behaviour, then check it against the numbers on this page.

Next step: set up the agent runtime with our n8n install guide for Hetzner, using the same compose file and restart policy as the servers measured here.

Hetzner prices on this page include 21% VAT, as charged to our Czech (EU consumer) account by the Hetzner API on 2026-11-05. Without VAT (businesses, most buyers outside the EU): CX23 5.49 €, CX33 8.49 €, CX43 15.99 €, CAX11 5.99 €, CAX21 10.49 € per month.

FAQ

What server do I need to run an AI agent 24/7?

If the agent calls a model over an API, a 2 vCPU, 4 GB server is enough for the agent runtime: our n8n peaked at 1003.0 MiB under 50 concurrent requests on a Hetzner CX23. If the model runs on the same server, plan 8 GB for a 3B model with headroom and 16 GB for an 8B model next to n8n.

How do I keep an agent running after crashes and reboots?

Use a supervisor. In Docker, set a restart policy such as unless-stopped. For a plain process, write a systemd unit with Restart=always or Restart=on-failure. Ollama's Linux docs give a unit with Restart=always and RestartSec=3.

Why is the first answer of my local agent so slow?

Ollama unloads a model after 5 minutes without requests by default. The next request loads it again: on our servers Llama 3.1 8B took 7.9 to 12.3 seconds to load. Set OLLAMA_KEEP_ALIVE to a negative value to keep it in memory, at the cost of that RAM.

Is a local model cheaper than an API for an agent?

Only at high, steady use. A CPU server generates a fixed number of tokens per second, for example 9.7 tokens/s for Llama 3.1 8B on our CX43. Use the cost per million tokens calculator on this page to compare with your API price.

Sources

  1. Docker Docs, Start containers automatically (2026)
  2. systemd, systemd.service manual (2026)
  3. Ollama Docs, Linux (2026)
  4. Ollama Docs, FAQ (2026)
  5. Hostinger, VPS hosting (2026)
  6. DigitalOcean, Droplet pricing (2026)
  7. Railway, Pricing (2026)