Skip to main content
Question 4. Which software architecture is most appropriate for deploying an LLM application that needs to handle variable workloads with periodic high demand? Answer: microservices architecture with horizontal scaling.
The image is a question and answer regarding the most appropriate software architecture for deploying an LLM application with variable workloads, recommending a microservices architecture with horizontal scaling. It highlights the benefits and drawbacks of different architectural approaches.
Overview
  • Microservices combined with horizontal scaling are the recommended pattern for LLM applications with variable and bursty workloads. This approach enables rapid scaling of the services under pressure while keeping costs and latency manageable.
  • Horizontal scaling lets you replicate only the components that need capacity (e.g., inference servers), while keeping other services lightweight and inexpensive.
Why microservices + horizontal scaling fits LLM workloads
  • Autoscaling: Orchestrators such as Kubernetes can add or remove replicas of API, preprocessing, and model-serving components based on CPU, memory, or custom metrics (for example, queue length or GPU utilization). Tools like KEDA or a custom metrics adapter can trigger scaling on application-specific signals.
  • Isolation of concerns: Separate services for the API gateway, request router, model inference, preprocessing/postprocessing, and observability allow targeted scaling and reduce blast radius for failures.
  • Stateless frontends: Keeping inference services as stateless as possible simplifies scaling operations—instances can be created or terminated without complex state migration.
  • Model-serving patterns: Use dedicated inference servers such as TensorFlow Serving, TorchServe, NVIDIA Triton, Ray Serve, or BentoML. Put them behind load balancers and autoscalers. Pooling GPUs and batching requests increases throughput and amortizes per-request overhead.
  • Asynchronous handling: Use request queues (e.g., Kafka, RabbitMQ, or managed queues) and worker pools for long-running inference to absorb bursts and smooth capacity requirements.
  • Cost control: Keep GPU-backed inference nodes scaled only when necessary and aggressively scale cheaper stateless services. Batching, request priority, and pre-warming strategies help reduce per-request cost during spikes.
Best practices
Put a model-serving layer behind a load balancer, use autoscaling policies driven by meaningful metrics (GPU utilization, queue length, tail latency), implement batching for inference, and offload non-ML responsibilities (caching, static asset hosting) to separate services.
Comparison: architectural alternatives Why the other options are less appropriate
  • Monolithic + vertical scaling: Scaling up has practical limits (cost, available hardware), increases downtime risk for upgrades, and mixes concerns that can lead to resource contention between model inference and other services.
  • Serverless (synchronous): Many providers enforce time and resource limits and have limited or no first-class GPU support. Cold starts and memory/CPU caps make serverless functions a poor fit for latency-sensitive or GPU-bound LLM inference unless you use asynchronous patterns and offload heavy work to specialized services.
Warning: If you consider serverless, verify provider GPU support, execution-time limits, and cold-start behavior. For production-grade LLM inference, serverless is typically impractical without async/offload approaches.
  • Peer-to-peer distributed computing: P2P systems introduce significant complexity around orchestration, security, and consistent performance, making them unsuitable for production LLM serving.
Operational considerations
  • Observability: Implement metrics, logs, and distributed tracing (OpenTelemetry, Prometheus, Grafana) to locate bottlenecks (CPU, GPU, memory, queue latency).
  • CI/CD and model lifecycle: Automate model packaging, testing, versioning, canary releases, and rollbacks to reduce deployment risk.
  • Resource optimization: Use GPU pooling, model quantization, and batching to reduce cost and improve throughput.
  • Reliability: Design for graceful degradation (e.g., cached responses, lower-fidelity fallbacks) and enforce timeouts/retries to protect downstream services.
  • Security and governance: Secure model artifacts, access controls, and data handling policies (encryption in transit/at rest, audit logs).
Links and references

Watch Video