2026 · 11 · 25 AI lab

Running our own 4B model on a 4-core, 8 GB server

System baseline and host environment

On 25 Nov 2026, we set up a self-hosted language model on our existing production host. The box is a Contabo VPS provisioned with 4 vCPUs and 7.9 GB of RAM. Prior to this test, the host was already serving active production workloads: standard mail server components, hosted websites, and several running background agents. Because of these existing services, the system swap on the host was already completely full before we pulled any model files or container images.

We selected Qwen3.5-4B as our test model, specifically using the Q4_K_M GGUF quantized format. To host the model, we used the llama.cpp server running inside a Docker container. Within llama.cpp, we set the context window size to 4096 tokens and configured the runtime to use 2 execution threads.

Initial unconstrained run and system failure

Our first attempt to launch the container was executed without applying explicit Docker resource limits. We booted the llama.cpp container and initiated inference requests. Without memory boundaries defined for the container, the runtime immediately attempted to claim system memory alongside our running web, mail, and agent processes.

Because system swap was already fully occupied by existing host applications, the operating system could not page memory out to disk efficiently. The host entered severe disk thrashing as processes fought for remaining physical RAM. Within moments, the server load average spiked to approximately 400. Web requests to hosted sites timed out, and mail processing slowed to a crawl across the board. We manually killed the Docker container to stabilize the host system.

Resource cleanup and hard container limits

Before making a second attempt, we audited running services on the server to clear out unnecessary memory overhead. We identified an unused service, a duplicate mail application running in the background, and shut it down to regain physical memory margin on the host.

We then reconfigured the Docker run flags to strictly constrain the llama.cpp container. For our second attempt, we applied four specific hardware controls:

With these hard resource boundaries active, the host stayed fully operational throughout model execution. Server load averages remained normal, and co-located mail and website processes experienced zero performance drop during inference runs.

Inference performance benchmarks

Once the host remained healthy under load, we measured the execution performance of Qwen3.5-4B Q4_K_M across prompt ingestion and response generation tasks running on the 2 assigned CPU cores.

Execution Phase Measured Speed / Processing Time
Prompt reading (ingestion) ~8.6 tokens/s
Response writing (generation) ~2.6 tokens/s
Latency per short response 30 to 118 seconds

The system read input prompts at roughly 8.6 tokens per second and generated output text at approximately 2.6 tokens per second. Complete execution times for short response generation varied between 30 and 118 seconds, depending on the combined prompt length and token count requested.

Gateway routing and app integration

With the local endpoint running reliably within its resource sandbox, we integrated it into our core infrastructure network. We placed the llama.cpp instance behind OmniRoute, our internal model router that acts as an OpenAI-compatible API gateway.

Inside OmniRoute, we mapped the container endpoint to the model alias gmx/qwen4b. Standardizing this endpoint through an OpenAI-compatible routing layer allowed us to expose the model to our application stack. We hooked gmx/qwen4b directly into our primary chat application, Hermes, allowing any service or user in our network to target the local model by name.

Production trade-offs and operational rules

This test provided clear verification that we can run an in-house model on our existing hardware infrastructure at zero incremental platform cost. However, the benchmark metrics clarify exactly where this deployment fit lies across our production environments.

Generating output at 2.6 tokens per second with total latency ranging from 30 to 118 seconds makes this setup far too slow for real-time conversational user interfaces inside Hermes. Users engaged in live chat require far faster turnarounds than a two-minute waiting window per response.

On the other hand, the deployment is fully adequate for background tasks. Asynchronous agent processing, offline batch jobs, queue summarization, and scheduled automated workers that can wait a minute or two for completion can utilize this endpoint effectively without consuming external API credits.

From an infrastructure safety perspective, this experiment established a core rule for our deployment pipelines: never run a local model on a shared server without a hard memory cap. Uncapped local model containers on shared servers will consume available RAM, exhaust host swap, drive load averages to severe levels, and degrade adjacent services.

Hardware upgrade options

To move self-hosted models out of background processing and into real-time interactive workloads, we evaluated two potential upgrade paths to scale processing speed.

Upgrade Option Server Specifications Cost Structure Target Model Strategy Performance Estimate
High-CPU VPS 12 cores, 48 GB RAM ~EUR 25 / month 30B parameter sparse model 8 to 15 tokens/s (estimated)
GPU Node 24 GB VRAM dedicated GPU Variable hosting rates Dense / quantized local models 60 to 100 tokens/s (estimated)

The CPU upgrade path involves moving to a 12-core, 48 GB RAM VPS instance at an estimated cost of EUR 25 per month. On this hardware, running a 30B parameter sparse model is estimated to achieve generation speeds between 8 and 15 tokens per second. While faster than our current 2.6 tokens per second output, this rate remains at the lower margin for comfortable live chat interaction.

The GPU upgrade path requires migrating inference to a server equipped with a 24 GB VRAM dedicated GPU. That hardware is estimated to produce execution speeds of 60 to 100 tokens per second, fully supporting low-latency, real-time conversational streaming in Hermes.

What we do next

We are keeping gmx/qwen4b active in production under its 3300 MB RAM limit, routed through OmniRoute for asynchronous background jobs and non-urgent agent tasks. For live chat in Hermes, we will evaluate upgrading to either the EUR 25 per month 48 GB VPS instance or a dedicated 24 GB GPU server based on our latency requirements and budget limits.

Building something similar, or want to follow along?

Tell me what you're training and where it broke. I read every message, and the useful ones end up in the next entry.

Get in touch →
← All notes