Hitesh Sahu
Hitesh SahuHitesh Sahu
  1. Home
  2. โ€บ
  3. posts
  4. โ€บ
  5. โ€ฆ

  6. โ€บ
  7. Agent Deployment

Loading โณ
Fetching content, this wonโ€™t take longโ€ฆ


๐Ÿ’ก Did you know?

๐ŸŒ Bananas are berries, but strawberries are not.

๐Ÿช This website uses cookies

No personal data is stored on our servers however third party tools Google Analytics cookies to measure traffic and improve your website experience. Learn more

Loading โณ
Fetching content, this wonโ€™t take longโ€ฆ


๐Ÿ’ก Did you know?

๐Ÿฏ Honey never spoils โ€” archaeologists found 3,000-year-old jars still edible.
AI-AgenticAI

    AI-AgenticAI
    • NVIDIA Agentic AI Professional Certification Path

    • Building Production-Ready Agentic AI Systems

    • Understanding Agentic AI Workflows

    • Understanding Agentic AI Memory

    • Evaluating Agentic AI Systems

    • Error Analysis in Agentic AI

    • Error Analysis for Agentic AI

    • Tool Use in Agentic AI

    • Code Execution in Agentic AI

    • Understanding the Model Context Protocol (MCP)

    • Optimizing Agentic AI Systems

    • Multi-Agent Systems in Agentic AI

    • Understanding Model Fusion in AI Systems

    • Deploying Agents at Scale

    • Deploying Agentic AI to Production

    • AI-AgenticAI Index


    AI-DeepLearning

    AI-GenAI

    AI-Infrastructure

    AI-Machine-Learning

    AI-Math

    AWS

    Azure

    Hobbies

    kubernetes

    Management

    Programming

    Terraform

    Z_Appendix

    0-root

Cover Image for Deploying Agents at Scale
AI-AgenticAI

Deploying Agents at Scale

Learn how to deploy AI agents reliably in production using containerization, orchestration, observability, evaluation pipelines, guardrails, retries, scaling strategies, and resilient architectures. Explore best practices for running agentic systems across cloud environments while maintaining performance, reliability, security, and cost efficiency.

Artificial Intelligence
Agentic AI
AI Agents
Deployment
MLOps
Kubernetes
โ† Previous

Stanford AI Scientist Roadmap 2026

Next โ†’

Deploying Agentic AI to Production

Deploying Agents at Scale

NVIDIA Inference Stack โšก

flowchart TD

    Training["Training <br/> PyTorch / NeMo Model"]--> Model["ONNX ๐Ÿ“ฆ"]

    User --> NIM["NIM <br/> Production APIs"]

    NIM --> Triton["Triton Server ๐Ÿณ <br/>Inference"]


    Triton--> TensorRT-LLM["TensorRT-LLM ๐Ÿ–ฒ <br/> Runtime"]

    Model-->TensorRT-LLM

    TensorRT-LLM--> GPU["GPU Rack ๐Ÿงฎ"]

Components

Component Purpose
CUDA GPU execution platform
TensorRT-LLM LLM optimization
Triton Model serving
NIM Packaged inference microservice
Kubernetes Deployment & scaling

Build using Docker ๐Ÿณ

Packages the agent, its model config, tool dependencies, and runtime into a single reproducible image.

Pin all versions model weights, libraries, Python for deterministic builds.

Pipeline

flowchart TD
    
    Commit["code commit ๐Ÿ“ค"]
    Eval["Automated Eval ๐Ÿ”Ž"]
    Build["Container Build ๐Ÿ“ฆ"]
    Deploy["Shadow Deployment ๐Ÿš› "]
    rollback["Promote/Rollback ๐Ÿณ"]

    Commit-->Eval-->Build-->Deploy-->rollback

Automated Eval ๐Ÿ”Ž

Running a benchmark suite against a golden dataset to catch regression in agent behaviour before it reaches users.

Shadow Deployment ๐Ÿš›

Benchmarking new build with real user traffic against existing prod deployment without affecting any user

Goal

  • Observe performance with real world traffic
  • Validate if model is performing well
  • Benchmark with current Live Model

More of this in next Post

Validate with real traffic.

flowchart LR

    User
    --> Production

    User -. Mirror .-> Shadow

    Production --> Response

    Shadow -. Discard .-> Trash

Promote/Rollback ๐Ÿณ

Final Rollout to production using BlueGreen or Canary Deployment

Expose to a real users gradually with Canary.


Kubernetes โ˜ธ๏ธ

Orchestrates multiple containers at scale.

Handles scheduling, health checks, rolling updates, and auto-scaling.

Each agent type runs as a Deployment with its own replica count and resource limits.

production-grade pattern used by many AI agent platforms.

  1. Deploy stateless agent workers as a Kubernetes Deployment.
  2. Use Redis or Kafka as a task queue.
  3. Expose queue depth as an external metric.
  4. Configure an HPA or KEDA ScaledObject.
  5. Scale replicas based on queue depth.
  6. Store session state and memory externally.

flowchart LR

    Producers --> Queue

    Queue --> Agent1
    Queue --> Agent2
    Queue --> Agent3

    Queue -. task_queue_depth .-> HPA

    HPA -. Scale Up/Down .-> Deployment

    Deployment --> Agent1
    Deployment --> Agent2
    Deployment --> Agent3

Horizontal Pod Autoscaler (HPA) โ†”๏ธ

Scales replica count up/down based on CPU, memory, or custom metrics (e.g. queue depth).

Handles traffic spikes without manual intervention.

Example application/deployment.yaml

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler # Horizontally scale pods
metadata:
  name: agent-worker-hpa  # identifier for deployment
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: agent-worker
  minReplicas: 2 # HPA will never scale below 2 replicas
  maxReplicas: 20 # Never scale above 20 pods
  metrics:
  - type: External
    external:
      metric:
        name: task_queue_depth   # custom metric from Redis
      target:
        type: AverageValue
        averageValue: "10"       # scale when >10 tasks/replica

Deploying agent-worker-hpa

Deployment

kubectl apply -f https://k8s.io/examples/application/deployment.yaml

Validate

# Verify deployment
kubectl get deployment agent-worker

# Verify HPA
kubectl get hpa

# Debug HPA
kubectl describe hpa agent-worker-hpa


Hierarchical orchestration

One orchestrator agent fans out sub-tasks to specialist workers.

The orchestrator holds the plan; workers are stateless executors.

At scale, the orchestrator itself can be replicated with task queues (Redis, Kafka) providing coordination.

Horizontal agent scaling

Deploy multiple identical worker agent replicas behind a load balancer.

Each replica handles independent tasks

Stateless design is key so any replica can pick up any task.

flowchart TD

    Producers["Producers / API Gateway ๐Ÿ”€ "]
    LoadBalancer["Load Balancer ๐Ÿšฆ "]

    AgentA["Agent Replica A ๐Ÿค– <br/>Stateless"]
    AgentB["Agent Replica B๐Ÿค– <br/>Stateless"]
    AgentC["Agent Replica C ๐Ÿค–<br/>Stateless"]

    Queue["Task Queue ๐Ÿ“ฅ <br/>Redis / Kafka"]

    Session["Session State โ„น๏ธ <br/>Redis / DynamoDB"]
    LTM["Long-Term Memory ๐Ÿ›ข <br/>Vector DB / RAG"]
    ToolCache[Tool Cache<br/>Redis / Memcached]

    Producers --> LoadBalancer

    LoadBalancer --> |monitor| AgentA
    LoadBalancer --> |monitor| AgentB
    LoadBalancer --> |monitor| AgentC

    Producers --> Queue

    Queue --> |poll| AgentA
    Queue --> |poll| AgentB
    Queue --> |poll| AgentC

    AgentA <--> Session
    AgentB <--> Session
    AgentC <--> Session

    AgentA <--> LTM
    AgentB <--> LTM
    AgentC <--> LTM

    AgentA <--> ToolCache
    AgentB <--> ToolCache
    AgentC <--> ToolCache

KEDA (Kubernetes Event-Driven Autoscaling)

Extends Kubernetes autoscaling beyond CPU and memory.

Common triggers:

  • Redis Queue Depth
  • Kafka Lag
  • RabbitMQ Queue Length
  • AWS SQS Messages

KEDA automatically creates and manages an HPA.

flowchart LR

    Queue -. Queue Depth .-> KEDA

    KEDA --> HPA

    HPA --> Deployment

Task queue decoupling ๐Ÿ“ฅ

Decouple task submission from execution via a queue.

Producers push tasks; agent workers pull and process.

Enables backpressure, retry, and independent scaling of producers vs consumers.

1. Routes by queue depth

Reads the actual task queue depth from each replica (or from Redis) and routes to the one with the shortest queue.

The most accurate signal for agent workloads โ€” accounts for queued but not-yet-started tasks.

2. Round Robin

Cycles through replicas in order regardless of their current load.

Simple and fair for uniform workloads, but can create hotspots when some agent tasks take much longer than others.

3. Least Connection

Always picks the replica with the fewest active tasks.

Ideal for agents because task duration varies wildly

a 20-step reasoning chain holds a connection far longer than a 2-step lookup.

4. Weighted

Replicas are assigned weights reflecting their capacity.

  • A GPU-backed replica might get weight 3, a CPU replica weight 1 โ€” meaning it receives 3ร— the traffic.

Good when replicas have different specs.

5. Random

Picks a replica at random.

Statistically converges to even distribution at scale but can cluster by chance on small request counts.

Low overhead โ€” no state to track.

ConfigMap / Secret ๐Ÿ”‘

Externalise model endpoint URLs, API keys, and policy configs from the image enables config changes without a rebuild.

GPU node pool

Schedule inference pods on GPU nodes using nodeSelector or taints/tolerations. NVIDIA device plugin exposes GPUs as schedulable resources.


Related Posts

  • NVIDIA NIM: Optimized Inference Microservices โ€” the NVIDIA inference stack referenced in this post; NIM Operator manages the LLM endpoints that agents call
  • GPU Autoscaling: KEDA, HPA, Cluster Autoscaler โ€” deep dive into the HPA and KEDA patterns described here: DCGM metrics pipeline, ScaledObject for queue depth, Cluster Autoscaler for GPU node groups
  • Kueue: Job Queuing and Quota Management โ€” managing GPU quota across multiple agent deployments sharing the same cluster
  • Kubernetes Networking: Pods, Services, Ingress, and CNI โ€” Service types and Ingress routing for exposing agent API endpoints
  • Helm: Kubernetes Package Manager โ€” deploying agent infrastructure (NIM, monitoring, Kueue) via Helm charts
Hitesh Sahu
Written by Hitesh Sahu, a passionate developer and blogger.

Sun Jun 07 2026

Share This on

โ† Previous

Stanford AI Scientist Roadmap 2026

Next โ†’

Deploying Agentic AI to Production

AI-AgenticAI/Agent-Deployment
Let's work together
+49 176-2019-2523
hiteshkrsahu@gmail.com
WhatsApp
Skype
Munich ๐Ÿฅจ, Germany ๐Ÿ‡ฉ๐Ÿ‡ช, EU
Playstore
Hitesh Sahu's apps on Google Play Store
Need Help?
Let's Connect
Navigation
ย  Home/About
ย  Skills
ย  Work/Projects
ย  Lab/Experiments
ย  Contribution
ย  Awards
ย  Art/Sketches
ย  Thoughts
ย  Contact
Links
ย  Sitemap
ย  Legal Notice
ย  Privacy Policy

Made with

NextJS logo

NextJS by

hitesh Sahu

| ยฉ 2026 All rights reserved.