Local LLM Deployment: Model Selection and Multi-Instance Load Balancing

    This article explains how to deploy large language models locally under fixed GPU, memory, and power constraints. It covers the recommended order of model selection before architecture design, three core evaluation dimensions, common deployment shapes, the bottlenecks of single-instance inference, and how to place a reverse proxy in front of multiple inference instances to provide a unified entry point. It also includes a working Nginx configuration, four configuration details that must not be skipped, scheduling strategy and capacity planning guidance, observability and stability practices, and an optional cloud-based alternative.

    1. Why Model Selection Comes Before Architecture in Local Deployment

    Deploying a large language model locally is essentially an engineering problem under resource constraints: within a fixed number of GPUs, a fixed amount of VRAM, and a fixed power budget, you must satisfy four metrics at once — model capability, context length, concurrency, and response latency. Many teams fail not because they picked the wrong model, but because they chose the model first and then worked backward to the hardware. The result is a noticeable accuracy drop after quantization, or queuing and timeouts as soon as concurrency ramps up.

    The recommended order is therefore: define the minimum acceptable generation quality for the business, estimate VRAM usage and concurrency capacity, and only then decide between a single GPU, multiple GPUs on one machine, or a multi-instance cluster.

    1.1 Three Core Evaluation Dimensions

    • VRAM usage: Determined jointly by parameter count, precision format, and quantization scheme. Space must also be reserved for the KV cache. The longer the context and the higher the concurrency, the more significant the KV cache footprint becomes — and this part is often underestimated.
    • Throughput and latency: Time to first token shapes the interactive experience, while overall throughput determines how many requests can be served per unit of time. The two usually trade off against each other and must be balanced according to the business scenario.
    • Generation quality: Quantization introduces some accuracy loss. Evaluate on a small set of real business samples rather than relying only on general-purpose leaderboards.

    1.2 Choosing a Deployment Shape

    Smaller models can typically be hosted on a single GPU, which is the simplest deployment. Mid-sized models that no longer fit on one GPU can use tensor parallelism to split weights across multiple cards. Larger models require a higher degree of parallelism or coordination across multiple machines. Note that the higher the parallelism, the greater the inter-GPU communication overhead, so the benefit does not grow linearly.

    2. Inherent Bottlenecks of a Single-Instance Architecture

    In single-instance mode, mainstream high-throughput inference frameworks run one service process per full model replica and do not natively support data parallelism across replicas. They decide the deployment shape flexibly based on available VRAM: a single GPU is enough in some cases, while tensor parallelism can occupy multiple cards when needed.

    Take a server with 8 GPUs as an example. If the strategy is to host one model replica per 2 cards (tensor parallelism of 2), the machine starts 4 independent service processes, each listening on a different port. This shape creates two direct problems:

    1. Clients must be aware of 4 ports, which makes configuration complex and prevents smooth scale-out.
    2. When a single process exits unexpectedly, there is no automatic removal or retry mechanism, so the failure is exposed directly to the caller.

    3. Adding a Reverse Proxy for a Unified Entry Point

    The solution is to put a reverse proxy layer above the service processes, expose only one port externally, and let the proxy distribute requests to the multiple backend instances according to a scheduling policy.

    3.1 Target Architecture

    A large volume of requests hits a unified entry point (for example, port 80), and the proxy layer then distributes tasks to different inference services according to a load balancing policy. This layer takes on three responsibilities at once: a unified entry point, removal of failed instances, and health checking.

    3.2 Configuration Notes

    The main configuration file usually lives at the system default path, but it is better to split out a separate configuration file per service under the configuration directory. This makes version management and canary adjustments easier. An illustrative configuration:

    1. upstream inference_backend {
    2. server 127.0.0.1:8000 max_fails=3 fail_timeout=30s;
    3. server 127.0.0.1:8001 max_fails=3 fail_timeout=30s;
    4. server 127.0.0.1:8002 max_fails=3 fail_timeout=30s;
    5. server 127.0.0.1:8003 max_fails=3 fail_timeout=30s;
    6. keepalive 256;
    7. }
    8. server {
    9. listen 80;
    10. server_name _;
    11. client_max_body_size 20M;
    12. location / {
    13. proxy_pass http://inference_backend;
    14. proxy_buffering off;
    15. proxy_cache off;
    16. proxy_connect_timeout 300s;
    17. proxy_send_timeout 300s;
    18. proxy_read_timeout 300s;
    19. proxy_http_version 1.1;
    20. proxy_set_header Connection '';
    21. proxy_set_header Host $host;
    22. proxy_set_header X-Real-IP $remote_addr;
    23. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    24. chunked_transfer_encoding on;
    25. }
    26. }

    3.3 Four Details You Cannot Skip

    • Disable buffering and caching: Otherwise the proxy accumulates responses and sends them in batches, which completely breaks the token-by-token effect of streaming output.
    • Extend the timeouts: Long-form generation can take far longer than the defaults, and a timeout shows up directly as a 504.
    • Use HTTP/1.1 and clear the connection header: This is the prerequisite for enabling keep-alive connection reuse and significantly reduces handshake overhead.
    • Allow larger request bodies: Long prompts and batch document content are easily truncated by the default limit.

    4. Scheduling Policy and Capacity Planning

    The default round-robin policy suits scenarios where request durations are roughly uniform. But LLM inference time varies widely with input length and generation length, so round robin can leave one instance piled up while another sits idle. If the proxy supports least-connections or response-time-based scheduling, that usually fits inference workloads better.

    For capacity planning, three rules of thumb are worth following: leave headroom on per-instance concurrency to avoid queuing; round up the replica count from peak concurrency divided by safe per-instance concurrency; and treat the KV cache as a first-class citizen when budgeting VRAM.

    5. Observability and Stability

    Once a unified entry point is in place, observability must be filled in: record request volume, response latency, and error code distribution at the proxy layer; watch VRAM usage, queue length, and generation throughput at the inference layer; collect logs centrally into a logging service and configure monitoring alert thresholds. When scaling instances in or out, adjust the upstream list and reload the configuration gracefully — clients need no changes.

    6. A Cloud-Based Alternative

    If local GPU resources are insufficient, a combination of cloud capabilities can be used instead: a container platform to host inference instances with elastic scaling, a load balancer service in place of a self-built proxy, object storage for model weights, and monitoring, alerting, and logging services to close the operations loop. Baidu AI Cloud offers general product categories for this kind of scenario, which can serve as an optional foundation for building a private inference service.

    7. Summary

    The key to local LLM deployment is not stacking hardware, but whether the chain of selection, quantization, parallelism, multi-instance, and unified entry point forms a closed loop. The reverse proxy layer is only a thin layer, yet it determines whether the service can be exposed stably, scaled smoothly, and support streaming output correctly — an indispensable part of a private inference service.