ai
RAG Architecture Pod Scheduling — ออกแบบ RAG บน

RAG Pod Scheduling

RAG Architecture Pod Scheduling Kubernetes GPU LLM Embedding Vector Database Retriever HPA KEDA Affinity Toleration Auto-scale
เนื้อหาเกี่ยวข้อง — TensorRT Optimization Shift Left Security
| Component | Resource | Node Type | Scale Strategy |
|---|---|---|---|
| API Gateway | CPU 0.5-2, RAM 512M-2G | CPU Node | HPA (Request Rate) |
| Embedding Service | CPU 2-4 หรือ GPU 1 | CPU/GPU Node | HPA (CPU/GPU) |
| Vector DB (Qdrant) | CPU 4-8, RAM 16-64G | High-memory Node | StatefulSet (Manual) |
| Retriever | CPU 1-2, RAM 2-4G | CPU Node | HPA (Latency) |
| LLM Service | GPU 1-2, RAM 16-32G | GPU Node | HPA (Queue Depth) |
| Queue (Redis) | CPU 1, RAM 2-4G | CPU Node | Fixed (HA) |
GPU Management

# === GPU Allocation & Management ===
# NVIDIA Device Plugin DaemonSet
# kubectl apply -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v0.14.0/nvidia-device-plugin.yml
#
# GPU Time-slicing (share GPU between pods)
# apiVersion: v1
# kind: ConfigMap
# metadata:
# name: nvidia-device-plugin
# data:
# config: |
# version: v1
# sharing:
# timeSlicing:
# resources:
# - name: nvidia.com/gpu
# replicas: 4 # 4 pods share 1 GPU
#
# Resource Quota per Namespace
# apiVersion: v1
# kind: ResourceQuota
# metadata:
# name: gpu-quota
# namespace: rag-production
# spec:
# hard:
# requests.nvidia.com/gpu: "4"
# limits.nvidia.com/gpu: "4"
@dataclass
class GPUStrategy:
strategy: str
method: str
use_case: str
cost_saving: str
gpu_strategies = [
GPUStrategy("Dedicated GPU",
"1 GPU per Pod (nvidia.com/gpu: 1)",
"LLM Inference ที่ต้อง VRAM เต็ม",
"ไม่ประหยัด แต่ Performance สูงสุด"),
GPUStrategy("Time-slicing",
"NVIDIA GPU Operator replicas: 4",
"Embedding Service หลายตัว Share GPU",
"ลดค่า GPU 75% (4 pods/GPU)"),
GPUStrategy("MIG (Multi-Instance GPU)",
"แบ่ง A100 เป็น 7 Instance",
"Mixed workload LLM + Embedding",
"ลดค่า GPU + Isolation ดีกว่า Time-slicing"),
GPUStrategy("Spot/Preemptible GPU",
"ใช้ Spot Instance สำหรับ GPU Node",
"Non-critical workload Batch Processing",
"ลดค่า GPU 60-70%"),
GPUStrategy("CPU Fallback",
"Embedding Service รันบน CPU ได้",
"เมื่อ GPU เต็ม ใช้ CPU แทน (ช้าลง)",
"ลดค่า GPU ใช้ CPU ราคาถูกกว่า"),
]
print("=== GPU Strategies ===")
for g in gpu_strategies:
print(f" [{g.strategy}] {g.method}")
print(f" Use: {g.use_case}")
print(f" Saving: {g.cost_saving}")
เคล็ดลับ
- Queue: ใช้ Queue Buffer ระหว่าง API กับ LLM ป้องกัน Overload
- GPU: ใช้ Time-slicing สำหรับ Embedding Share GPU ลดค่าใช้จ่าย
- Spot: ใช้ Spot GPU Instance สำหรับ Non-critical Workload
- Affinity: ตั้ง Retriever ใกล้ Vector DB ลด Network Latency
- Priority: ตั้ง PriorityClass ให้ LLM Pod สำคัญกว่า
RAG Architecture คืออะไร
Retrieval Augmented Generation Embedding Vector DB Retriever LLM Kubernetes Pod Microservices Scale GPU CPU Context Answer
เนื้อหาเกี่ยวข้อง — ทำความเข้าใจ ข้อดีของการใช้ EdCafe AI คืออะไร — เครื่องมือ AI
อ่านเพิ่ม: Kubernetes Cost Optimization คืออะไร? ลดค่าใช้จ่าย K8s Clust · อ่านเพิ่ม: Kubernetes Autoscaling คืออะไร? สอน HPA, VPA, KEDA และ Clust · อ่านเพิ่ม: Kubernetes Multi-Tenancy คืออะไร? สอนแชร์ K8s Cluster อย่างป
แนะนำเพิ่มเติม — ระบบเทรดของ iCafeForex
เนื้อหาเกี่ยวข้อง — ดูเพิ่มเติมเรื่อง mô hình 3 nến giảm — ข้อมูลครบถ้วน 2026





