How can I run multiple AI engines on the same server?
To run multiple LLMs on one server, put a single OpenAI-compatible gateway in front, run each local engine in its own container with CPU and RAM limits, and send large models to an external API.
To run multiple LLMs on one server, put a single access layer in front (a gateway or your own OpenAI-compatible API) that receives every request and decides which engine handles it. Run each local engine in its own container with CPU and RAM limits and internal ports, and send models your hardware can't handle to an external API.
On a server without a GPU, the realistic setup combines small local models for simple tasks with large models via API (for example, Dongee AI Router, a unified API that gives you several models with a single key).
What managing several AI engines on one server means
Here an “engine” is any component that takes an input and returns a model's output. It can be a local inference runner (a model server such as Ollama, llama.cpp or vLLM), an embeddings service, a speech recognition service, an OCR service or a commercial model API you call over the internet. Managing them on the same server isn't just installing them side by side. They have to coexist without getting in each other's way, and your application has to be able to use them without knowing the details of each one.
When several engines share a machine, the same problems always show up:
- Shared memory: every loaded model takes up RAM (or VRAM if there's a GPU). If two engines load models at the same time, the system can run out of memory, start swapping or kill processes.
- Ports: each engine listens on its own port. If you expose them all to the internet, you multiply the attack surface.
- Versions: one engine may need a library version that breaks another if they're installed directly on the system.
- Keys: external APIs use keys that shouldn't live in your code or be scattered across several apps.
- Costs: local engines have a fixed cost (the server) and APIs a variable cost (per use). Without control, variable spend can skyrocket.
- Who uses what: if several teams, customers or apps share the server, you need to know how much each one consumes and be able to limit it.
If you're still deciding what kind of server to use, first check what a VPS is and how it differs from other types of hosting.
Recommended architecture
The core idea is that your application talks to a single entry point and never directly to the engines. That way you can change, add or remove engines without touching the app's code.
- Client or application: your backend, a bot, an internal tool or a script.
- Reverse proxy (for example, Nginx): terminates TLS (HTTPS), filters traffic and forwards only to the gateway. If you're torn between web servers, here's a comparison of Nginx vs Apache.
- AI gateway with a single OpenAI-compatible API: it can be a proxy like LiteLLM or your own service. It's responsible for:
- Authenticating with internal keys (one per app, team or customer).
- Routing by model name or by task type.
- Applying limits per user or per key.
- Logging usage (requests, tokens, errors, latency).
- Handling fallback: if an engine fails or is overloaded, sending the request to another one.
- Local engines in containers: each one with its own memory and CPU limit, listening on an internal port that isn't exposed to the internet.
- External APIs: models you can't or don't want to run locally, with their keys stored in the gateway's environment variables.
Internet (HTTPS)
|
+-------------+
| Nginx | TLS, forwarding
+-------------+
|
+---------------------------------+
| AI gateway (OpenAI API) |
| internal keys · limits |
| routing · logs · fallback |
+---------------------------------+
| | | |
internal net internal net internal net internet egress
| | | |
+-----------+ +------------+ +-----------+ +-------------------+
| Small LLM | | Embeddings | | Voice/OCR | | External APIs |
| engine | | (local) | | (local) | | (large models) |
| RAM limit | | RAM limit | | limit | | key in env |
+-----------+ +------------+ +-----------+ +-------------------+
To dig into how to decide which model each query goes to, see this comparison for routing queries between language models. And if the difference between spreading traffic and choosing a model is confusing, read AI model routing vs load balancing.
Step by step
1. Take an inventory of models and tasks. List what your product needs: chat, classification, summaries, embeddings for search, audio transcription, document OCR. For each task, note how demanding it is on quality, what volume you expect and whether the data can leave your server. That already shows you what belongs locally and what belongs on an API.
2. Size the server starting with RAM. The rule is simple: memory must cover the models you'll have loaded at the same time, plus the operating system, the gateway and your app. A quantized model takes up much less than its full version, but it also loses some quality. Then look at CPU, because on a server without a GPU inference runs on the cores, and more cores help with latency and concurrency. Finally, disk: model weights are large files, and an NVMe SSD speeds up loading them.
3. Install Docker and Docker Compose. Isolating each engine in a container avoids version conflicts and lets you limit resources per service. Use an unprivileged user for administration and keep the system up to date.
4. Create one container per engine, with limits. Each engine runs in its own service, with a memory and CPU limit and no ports published to the outside. This is an illustrative example: the images are generic and the values are only examples, so adjust them to your server and your models.
# docker-compose.yml — ILLUSTRATIVE example, adjust images and values
services:
chat-engine:
image: example/llm-server:version # example image
volumes:
- chat-weights:/models
networks: [ai-internal]
deploy:
resources:
limits:
cpus: '3' # example value
memory: 8g # example value
restart: unless-stopped
# no ports: only reachable from the internal network
embeddings-engine:
image: example/embeddings-server:version # example image
volumes:
- emb-weights:/models
networks: [ai-internal]
deploy:
resources:
limits:
cpus: '1' # example value
memory: 2g # example value
restart: unless-stopped
gateway:
image: example/ai-gateway:version # e.g. a LiteLLM-style proxy
env_file: .env # keys outside the code
volumes:
- ./gateway.yaml:/config/gateway.yaml:ro
networks: [ai-internal, egress]
ports:
- '127.0.0.1:4000:4000' # only local Nginx can reach it
depends_on: [chat-engine, embeddings-engine]
restart: unless-stopped
networks:
ai-internal:
internal: true # no internet access
egress: {} # the gateway needs to reach external APIs
volumes:
chat-weights:
emb-weights:
With internal: true the engines have no internet access. Download the model weights beforehand or in a separate step. That way, even if an engine has a vulnerability, it isn't exposed and can't exfiltrate data.
5. Load and unload models on demand. Don't keep everything in memory all the time. Many model servers let you unload a model after a period of inactivity or limit how many models stay loaded at once. Keep resident only the ones in constant use (for example, embeddings) and load the rest when needed, accepting a slower first response.
6. Configure the gateway with logical model names. Your app shouldn't ask for “model X version Y on port Z”, but for something like fast, precise or embeddings. The gateway maps each name to a real engine. That way, tomorrow you can swap a local model for an API one, or vice versa, without redeploying the app.
# gateway.yaml — CONCEPTUAL example (syntax depends on your gateway)
models:
- name: fast
target: http://chat-engine:8080/v1 # local engine
- name: embeddings
target: http://embeddings-engine:8080/v1 # local engine
- name: precise
target: https://external-api.example/v1 # external API
key: ${EXTERNAL_API_KEY}
fallback: fast
7. Get keys and secrets out of your code. Store external API keys in a .env file with restricted permissions or in a secrets manager, and don't commit it to the repository. Give each app or customer an internal gateway key, never the external provider's key. If an internal key leaks, you revoke it without affecting anyone else.
8. Set limits and queues for heavy tasks. Limit requests per minute and concurrency per key in the gateway. For long jobs (transcribing audio, OCR on batches of PDFs, generating embeddings for thousands of documents), use a job queue with workers that process a few at a time. That way a bulk load doesn't leave the real-time chat unresponsive.
9. Monitor and log without storing sensitive data. Track RAM and CPU usage per container, latency per model, error rate and usage per key. Tools like Prometheus and Grafana are common for this. In the logs, keep metadata (model, key, duration, tokens, response code) and avoid storing the content of prompts and responses, especially if you handle personal data.
10. Back up or snapshot before updating. Updating an engine or changing a model can alter responses, formats or memory usage. Take a server snapshot, pin image versions in the compose file and test first with an internal test key before changing the logical name in production.
If you want to control token spend within this architecture, see how to optimize token usage with AI routers.
All local, all API or hybrid?
| Criterion | Local engines only, on your server | External APIs only | Hybrid (gateway + local + API) |
|---|---|---|---|
| Cost type | Fixed: you pay for the server whether you use it a lot or a little | Variable: you pay per use | Fixed for simple, frequent tasks; variable for complex ones |
| Privacy | Data never leaves your server | Data travels to the API provider | You can keep sensitive data local and send the rest |
| Quality of available models | Limited to what your hardware can run | Access to large models | Large models when needed, small ones for routine work |
| Latency | No network round trip, but inference is slower on CPU | Depends on the network and the provider's load | You pick the engine based on the latency each task can accept |
| Maintenance | High: you update engines, models and the system | Low: you just integrate and manage keys | Medium: you maintain the gateway and a few local engines |
| Scaling | Requires a bigger server or more servers | Handled by the provider, within your usage limits | You scale local capacity gradually and offload peaks to the API |
| GPU requirement | Needed for large models; without one, only small or quantized models | Not needed | Not essential if the heavy lifting goes through the API |
| Third-party dependency | Minimal | Total: if the API fails, your service fails | Partial: fallback can cover outages |
| When it makes sense | High, steady volume of simple tasks, or data that can't leave | Prototypes, low or irregular volume, need for top quality | Most SMBs, agencies and startups in production |
When a single server is no longer enough
A well-organized server can handle a lot, but there are clear signs it has hit its limit:
- The system swaps routinely and responses become erratic.
- Job queues grow faster than they drain.
- Models get evicted from memory and reloaded all the time.
- One engine affects another: when OCR or transcription runs, the chat slows down.
- You can no longer raise one container's limits without taking resources from another.
The next step is to split things up: for example, one server for the gateway and the app, another for language engines and another for batch tasks (voice, OCR, bulk embeddings). Connect them over a private network so the engines stay off the internet. If you also replicate the gateway across several instances, you can put your own Nginx or HAProxy load balancer in front. To plan that growth, see this guide to cloud infrastructure to scale AI applications.
Common mistakes
- Exposing each engine's ports to the internet instead of keeping them on an internal network behind the gateway.
- Not setting memory limits on containers, so a single model brings down the whole server.
- Trying to run large models on CPU while expecting GPU speed.
- Hard-coding specific model names in the app, which forces a redeploy every time you change engines.
- Sharing the external API key across all apps, with no way to know who consumes what or to revoke just one.
- Mixing batch tasks with real-time traffic without queues or priorities.
- Storing full prompts and responses in logs, including personal data.
- Updating engines or models without a snapshot or pinned versions, with no way to roll back.
How to do it with Dongee
To build this architecture you can use Dongee Cloud: a cloud server with Intel Xeon processors and full root access over SSH, where you can install Docker and Docker Compose without restrictions, and which deploys in minutes. It includes NVMe SSD, free private networking between your instances, snapshots, disk backup included on all plans, a dedicated IP, a control panel, a 99.9% uptime guarantee and 24/7 support. Dongee Backup, for copies of internal files, is a separate paid product. Locations include Atlanta, Miami, NY, Dallas, Mexico, São Paulo, Santiago (Chile), Frankfurt, Madrid, London and Amsterdam.
Some example plans, according to Dongee's website as of November 14, 2026 (USD/month):
| Plan | CPU | RAM | SSD disk | Price |
|---|---|---|---|---|
| Cloud 1 | 1 | 1 GB | 25 GB | 17 USD |
| Cloud 3 | 2 | 4 GB | 80 GB | 68 USD |
| Cloud 4 | 4 | 8 GB | 160 GB | 136 USD |
| Cloud 5 | 6 | 16 GB | 320 GB | 272 USD |
| Cloud 6 | 8 | 32 GB | 640 GB | 544 USD |
| Cloud 7 | 10 | 64 GB | 1280 GB | 1088 USD |
If no combination fits, Cloud On Demand lets you choose CPU, RAM and disk to measure. Keep in mind that Dongee Cloud plans are CPU-based (Intel Xeon), with no GPU. That's why the hybrid approach is recommended: small or quantized local models for embeddings, classification and simple tasks, and large models via API.
For the API side there's Dongee AI Router, a unified API for several AI models that prioritizes fast models hosted in Dongee's data center in Canada. How it works:
- You use a single key for several models, and it's compatible with the OpenAI standard: in your gateway you only change the base URL and the key.
- It supports streaming: the model's response arrives in chunks as it's generated.
- You can restrict each key to specific models.
- It's prepaid from 3 USD, with no monthly fee, and new accounts get 3 USD in free starter credit. If your balance runs out, requests stop without creating debt.
- It doesn't store conversation content, only the billing data of each request.
- You can see usage by model, by key and per request in your client area, where you also activate it.
You program the model choice and the fallback in your gateway. AI Router can be used as a target from your own gateway, for example a LiteLLM-style proxy: it's one more target within your routing and it can't host your own models (those run on your cloud server).
If what you want is to publish the web app (built with ChatGPT, Lovable, Bolt, v0, Cursor…) without managing a server, Dongee Live, Dongee's hosting for apps built with AI, publishes Node.js apps and static sites. Note that Live doesn't run or deploy AI models. And if you need help, you get 24/7 human support in your language (the platform translates on the fly).
Frequently asked questions
Can I run several AI models on a VPS without a GPU?
Yes, if they're small or quantized models and you accept higher latency than with a GPU. They work well for embeddings, classification, extraction and short answers. Large models aren't viable on CPU for real use, so the practical choice is to consume them via API.
How much RAM do I need?
It depends on which models you'll have loaded at the same time. The rule is that memory must cover those models plus the operating system, the gateway and your app, with headroom so it doesn't swap. Quantized versions take up much less. Measure each container's real usage with your models before choosing the final plan.
Is Docker required?
No, but it's highly recommended. Without containers you'd have to manage each engine's dependencies, resource limits and network isolation by hand. Docker Compose lets you describe everything in one file and repeat the setup on another server. On Dongee Cloud you can install Docker and Docker Compose without restrictions.
How do I stop one model from using all the memory?
Set a memory limit on each container, limit how many models each engine can keep loaded, configure automatic unloading of idle models and control concurrency from the gateway. Send heavy tasks to a queue.
How do I expose a single API for all engines?
With an OpenAI-compatible gateway behind Nginx. Your apps always call the same URL with their internal key and a logical model name, and the gateway decides which local engine or external API gets the request.
Is local or API cheaper?
It depends on volume. Local is a fixed cost: with high, steady use for simple tasks, you get more out of it. The API is a variable cost: with low or irregular volume, or when you need large models, it usually works out better. That's why hybrid is the most common choice.
Can I use Dongee AI Router alongside local models?
Yes. Since it's compatible with the OpenAI standard, you add it to your gateway as one more target, with its base URL and key. Your gateway decides when to use the local model and when to send to AI Router, including whatever fallback you configure.
Can Dongee Live host models?
No. Dongee Live publishes Node.js apps and static sites, but it doesn't run or deploy AI models. For local engines you need a server like Dongee Cloud.
When should I split into several servers?
When you see routine swapping, queues that don't shrink, models constantly loading and unloading, or engines affecting each other. At that point, split the engines into instances connected by a private network and, if you replicate the gateway, put your own Nginx or HAProxy load balancer in front.
Start simple
You don't need every engine from day one. First set up the gateway with logical names, add one or two local engines with clear limits and connect an API for the heavy work. Measure real usage and grow when the data tells you to. You can deploy your server on Dongee Cloud and activate Dongee AI Router from your client area to try the hybrid architecture with the starter credit.
Comenta lo que quieras
Unete a la charla
Solo ingresa tu email