ANTIGRAVITY LABJP
Articles/App Development
App Development/2026-04-22Advanced

Running Gemma 4 on a Self-Hosted vLLM Server from Antigravity — A Practical Guide to Building High-Throughput Inference

Gemma 4 runs beautifully in Ollama for a single user. The moment a handful of teammates start hitting the same endpoint, throughput collapses. This guide walks you through replacing Ollama with a self-hosted vLLM server, wiring it into Antigravity as a custom endpoint, choosing a quantization level with real numbers, and hardening the stack with rate limits and LoRA routing — end to end.

antigravity434vllmgemma-419self-hosted2production71inference

Premium Article

The day a local Gemma 4 suddenly stops feeling local

For a while, running Gemma 4 in Ollama and pointing Antigravity at it as a custom model felt like magic. I was alone on the endpoint, and every response came back in a heartbeat. It was easy to convince myself I had all the infrastructure I would ever need.

That illusion broke the first afternoon I shared the same endpoint with a few engineers on my team. Time-to-first-token stretched from under a second to five, then ten. Antigravity began flashing timeouts in red. The Ollama logs showed exactly what had happened: every request was being handled strictly in serial, and the second person to hit "send" was politely waiting for the first person's generation to finish before anything else could start.

This guide is the note I wish I had during that transition — the gap between "it works on my laptop" and "it works for several humans and agents at once." The short version is that Ollama and LM Studio are optimized for desktop-class experiences and were not designed to absorb parallel requests. vLLM is the piece that fills that role, and Antigravity happily connects to it through the same OpenAI-compatible API you already know.

Everything below assumes you are running Gemma 4 9B, though 27B works with a few noted caveats. The VRAM numbers and dollar estimates are for 9B unless stated otherwise.

Why vLLM — and where Ollama and LM Studio still belong

Plenty of projects serve LLMs these days. I tested Ollama, LM Studio, Text Generation Inference (TGI), and vLLM side by side on the same hardware with the same prompts. From the perspective of an individual developer or a small team, the division of labor that has stuck for me is this:

  • Ollama / LM Studio: personal development, a single-user desktop experience, and quick validation. The ten-minute setup is a real feature.
  • TGI: teams deeply invested in the Hugging Face training stack. The integration with model hubs is the smoothest here.
  • vLLM: multi-user, multi-agent workloads where several concurrent requests are normal. PagedAttention and continuous batching make the throughput profile dramatically more forgiving.

The reason vLLM shines in the last category is its paged KV cache and its continuous batching scheduler. Instead of queuing incoming requests and handling them one at a time, vLLM slots new requests into the gaps between tokens of in-flight requests. The per-request latency barely degrades as concurrency grows, where other servers cliff-dive.

The trade-off is that vLLM does not ship a chat UI. It speaks OpenAI-compatible REST and a Python client, and that is essentially it. If your frontend already exists — Antigravity in our case — vLLM is a natural backend. If you need a polished UI out of the box, Ollama or LM Studio will still serve you better. There is also a hidden cost worth naming upfront: vLLM is harder to upgrade than Ollama. Ollama handles model updates with a pull command and a restart; vLLM often involves a new Docker image version, a weight re-download, and a config audit for flags that changed between releases. The payoff is that when upgrades do land, they often raise throughput by double-digit percentages with the same hardware. I budget one afternoon per quarter for vLLM upgrades and treat it as infrastructure work rather than a routine operation.

One more piece of context: vLLM's raison d'être is throughput under load, not latency for a single request. If you only ever run one prompt at a time, Ollama and vLLM will feel almost identical. The moment two requests overlap, vLLM's scheduler starts doing work that Ollama simply cannot do. That is why, counterintuitively, the benefits of switching to vLLM are invisible until you have real concurrency — and then they become dramatic almost all at once.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
A clear rule for when to move off Ollama, read straight from the request logs that show why concurrency stalls
bfloat16 / W8A8 / AWQ 4-bit measured on the same workload, so you pick a quantization tier from real throughput and quality numbers
A monthly break-even model for self-hosted GPU versus API pricing, plus the observability that catches silent latency creep
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

App Dev2026-06-28
When Streaming Works Locally but Arrives All at Once in Production — Field Notes on Proxy Buffering and Silent Stalls
Stream Gemini through Antigravity over SSE and it flows token-by-token on localhost, then freezes for seconds and dumps the whole answer in production. Field notes on measuring the stall first, then killing proxy buffering, idle disconnects, and reconnect-driven double generation.
App Dev2026-05-03
Building Idempotency Keys and Dedupe Stores in TypeScript with Antigravity
A production guide to designing idempotency keys and dedupe stores in TypeScript with Antigravity — covering Stripe webhook retries, Temporal replays, and the Cloudflare KV / Redis / Postgres trade-offs you actually need to choose between.
App Dev2026-05-01
Zero-Downtime Database Migrations with Antigravity: The Expand-Contract Pattern in Production
A complete production guide to running breaking schema changes—type swaps, column renames, table splits—with zero user-facing downtime, using the Expand-Contract pattern with Antigravity's AI assistance.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →