Close Menu
ToolTechBlogToolTechBlog

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    OpenAI employee who secretly recorded meetings allegedly affiliated with the Saudi government

    November 24, 2026

    How to save your Google Nest app videos before the January shutdown

    November 24, 2026

    Claude can ship code for you now – how to try it (if you dare)

    November 24, 2026
    Facebook X (Twitter) Instagram
    ToolTechBlogToolTechBlog
    • Home
    • AI Tools
    • Web Hosting
    • Tech
    • Digital Marketing
    • Business Software
    • VPN & Cybersecurity
    ToolTechBlogToolTechBlog
    Home»Web Hosting»Sizing GPU Memory for a RAG Service: KV Cache, Context and Concurrency
    Web Hosting

    Sizing GPU Memory for a RAG Service: KV Cache, Context and Concurrency

    Tool Tech TeamBy Tool Tech TeamNovember 18, 2026No Comments7 Mins Read
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr WhatsApp Email
    Sizing GPU Memory for a RAG Service: KV Cache, Context and Concurrency
    Share
    Facebook Twitter LinkedIn Pinterest Telegram Email

    Community Article
    Community articles are authored by SitePoint Premium contributors. Content is screened before publication, and SitePoint reserves the right to moderate or remove articles that violate our guidelines. Views expressed are those of the authors and do not necessarily reflect those of SitePoint.

    Sizing GPU Memory for a RAG Service: KV Cache, Context and Concurrency

    SMSophie MarksPublished inAI·
    November 18, 2026
    ·Updated:November 18, 2026

    The AI briefing for Developers

    Stay up to date with AI tools, model releases, and developer workflows that matter.

    Weekly. Free. One click to leave.

    SitePoint Premium
    Stay Relevant and Grow Your Career in Tech

    • Premium Results
    • Publish articles on SitePoint
    • Daily curated jobs
    • Learning Paths
    • Discounts to dev tools

    7 Day Free Trial. Cancel Anytime.

    A retrieval-augmented generation (RAG) app is usually drawn as a language model plus a vector database. When it goes live, the part that fails first is rarely the retrieval. It is GPU memory on the generation model, because a model that loads fine for one request can run out of memory when several users send long questions at once.

    This article shows how to estimate that limit before you deploy, with a short script you can run, and then covers what else in the pipeline can slow responses down.

    What Actually Uses GPU Memory

    Serving a model takes more than its weights. The GPU also holds:

    • the key-value (KV) cache, which grows with the length of every active request

    • activations and batching overhead

    • memory used by the inference runtime itself

    SitePoint’s guide to running a local LLM on 10GB of VRAM makes the same point for a single desktop GPU: the usable budget is the total VRAM minus overhead, and the KV cache grows with the context window, so the real model budget is smaller than the number on the box.

    For a RAG service, the KV cache matters even more. Retrieved passages are pasted into the prompt, so every request carries a long context, and every concurrent request holds its own cache.

    Estimate the KV Cache Before You Deploy

    The cache size per token depends on the model’s architecture: two tensors (keys and values) for every layer, for every KV head. This script turns those numbers into a rough limit on concurrent requests:

    def kv_bytes_per_token(layers, kv_heads, head_dim, dtype_bytes=2):

        # Keys and values, for every layer, for one token.

        return 2 *layers *kv_heads *head_dim *dtype_bytes

    def max_concurrent(vram_gb, weights_gb, ctx_tokens, per_token, reserve_gb=2.0):

        budget = (vram_gb – weights_gb – reserve_gb) * GIB

        return int(budget // (ctx_tokens * per_token))

    Llama 3.1 8B style: 32 layers, 8 KV heads, head size 128, fp16 cache

    per_token = kv_bytes_per_token(32, 8, 128)

    print(per_token // 1024, “KiB per token”)

    for ctx in (4096, 8192, 16384):

        n = max_concurrent(24, 16, ctx, per_token)

        print(ctx, “tokens ->”, n, “concurrent requests”)

    For a 24 GB GPU holding about 16 GB of fp16 weights with 2 GB kept in reserve, it prints:

    4096 tokens -> 12 concurrent requests

    8192 tokens -> 6 concurrent requests

    16384 tokens -> 3 concurrent requests

    The numbers are estimates. Real runtimes add their own overhead, and the architecture values come from the model’s configuration file, so read them from the model you actually use. The pattern is what matters: doubling the context length halves the number of requests that fit. A RAG prompt that stuffs in ten retrieved chunks costs real capacity.

    What Happens When the Cache Runs Out

    Serving runtimes do not simply crash when the cache is full. The vLLM documentation on optimization and tuning explains that when KV cache space is insufficient for all batched requests, the engine preempts some of them and recomputes them later, which can hurt end-to-end latency. Its suggested remedies include giving the cache more memory, reducing the number of concurrent sequences or batched tokens, or sharding the model across GPUs.

    So the symptom of undersizing is often not an error. It is slow, uneven responses under load. Test with realistic prompt lengths and several simultaneous users, not a single request.

    Keep the Rest of the Pipeline in View

    Embedding and ingestion have a different profile from generation. Embedding is often lighter than serving a large language model, and some teams run it on CPU. Document parsing, chunking and tokenization also run on CPU, so a fast GPU cannot make up for a slow CPU upstream. SitePoint’s tutorial on a local RAG system for private documents walks through chunking, embeddings, vector storage and reranking, and is a good map of which stages run where.

    • RAM: vector indexes, document loaders and caches all live in system memory, so large collections need more of it.

    • Storage: model files, indexes, logs and backups add up. Fast storage shortens model loading and re-indexing.

    • Network: if the vector database, application server and model server sit in different places, latency adds to every request.

    Two layouts are common. A single instance runs everything and is simplest for prototypes and internal tools. Separated services put ingestion and retrieval on smaller machines and keep the GPU for generation, which scales better as traffic grows.

    Memory estimates only hold if the GPU memory is really yours. On a shared or time-sliced GPU, other workloads can take memory and compute away from your service, which makes capacity hard to plan. Hosting providers describe this in different terms, such as passthrough, vGPU, MIG and time-slicing. For a view of how one GPU hosting provider explains those allocation methods, GPU Mart’s GPU virtualization guide compares them. It is a hosting company’s page, so confirm any provider’s claims about isolation and performance with your own load test.

    Whatever provider you choose, ask these questions:

    • Is the physical GPU assigned to you exclusively, or partitioned or time-sliced?

    • Do you have root access to install your own drivers, CUDA libraries and containers?

    • Which minimum commitments, regions and support terms apply?

    Deploy the Pieces as Separate Services

    A small stack can run as a handful of containers: an API service for request handling and prompt assembly, an ingestion worker, a vector database and a model server. Keeping them separate lets you monitor each one’s memory and CPU use and move the heavy one to bigger hardware without rewriting the rest.

    For a service that stays up all month, a fixed monthly term is easier to forecast than hourly capacity. Hourly capacity suits testing quantization settings or processing a one-off document batch.

    Frequently Asked Questions

    Is GPU memory always the bottleneck for RAG?

    Not always. Generation usually hits memory first, but slow parsing, a small CPU or a distant vector database can dominate response time.

    Does quantization solve the memory problem?

    It shrinks the weights, but the KV cache still grows with context length and concurrency. Test with your real prompt sizes.

    Should embeddings run on the GPU?

    It depends on volume. Small workloads can run on CPU, while a large ingestion job may benefit from a GPU for a limited time.

    Summary

    Size a RAG service for the worst realistic moment, not the single-request demo. Estimate the KV cache from the model’s architecture, remember that long retrieved contexts reduce how many requests fit, watch for preemption under load, keep CPU, RAM, storage and network in the plan, and find out whether the GPU is exclusive or shared. The script above is small, but it turns a vague worry about memory into numbers you can check.

    Cache Context Memory Service Sizing
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Tool Tech Team
    • Website

    Related Posts

    Why the Agent Isn’t the Hard Part: Where Developers Go Wrong With Agentic Workflows

    November 24, 2026

    Top 10 Black Friday Deals for Designers and Agencies in 2026

    November 23, 2026

    Serving a Local LLM to Several Users: Ollama, LM Studio, llama.cpp and vLLM Benchmarked

    November 23, 2026

    How to Add AI Facial Expression Editing to Your Video Pipeline (2026)

    November 22, 2026

    5 Things Most Developers Get Wrong When Turning Images into HTML

    November 22, 2026

    What to Check Before Adding a Tripo Model to a Website

    November 21, 2026
    Leave A Reply Cancel Reply

    Top posts
    Tech

    OpenAI employee who secretly recorded meetings allegedly affiliated with the Saudi government

    By Tool Tech Team
    Business Software

    How to save your Google Nest app videos before the January shutdown

    By Tool Tech Team

    Claude can ship code for you now – how to try it (if you dare)

    By Tool Tech Team
    Editors Picks

    OpenAI employee who secretly recorded meetings allegedly affiliated with the Saudi government

    November 24, 2026

    How to save your Google Nest app videos before the January shutdown

    November 24, 2026

    Claude can ship code for you now – how to try it (if you dare)

    November 24, 2026

    Why the Agent Isn’t the Hard Part: Where Developers Go Wrong With Agentic Workflows

    November 24, 2026
    About Us

    Welcome to ToolTechBlog, your trusted source for the latest insights, reviews, and practical guides on AI tools, business software, cybersecurity, web hosting, and consumer technology.
    Our mission is simple: to help individuals, entrepreneurs, freelancers, students, and businesses discover the right digital tools to improve productivity, streamline workflows, and make informed technology decisions.

    Our Picks

    OpenAI employee who secretly recorded meetings allegedly affiliated with the Saudi government

    November 24, 2026

    How to save your Google Nest app videos before the January shutdown

    November 24, 2026

    Claude can ship code for you now – how to try it (if you dare)

    November 24, 2026
    Top Reviews

    The AI Hype Index: Unsexy AI

    July 29, 2026

    What it is and How to Fix it

    July 29, 2026

    LG to Ban Residential Proxies from Smart TV Apps

    July 29, 2026

    © 2026 tooltechblog.com. All rights reserved. Designed by DD.

    • About Us
    • Contact Us
    • Terms and Conditions
    • Privacy Policy
    • Disclaimer

    Type above and press Enter to search. Press Esc to cancel.