LLM Apps in Production (RAG + Vector DB + Caching) · บทเรียน

การทดสอบโหลดและการวางแผนความจุ

เรียนรู้การจำลองทราฟฟิกที่สมจริงไปยังแอปพลิเคชัน LLM ค้นหาจุดที่ระบบรับไม่ไหว และวางแผนความจุเพื่อให้ระบบจริงยังรวดเร็วและอยู่ภายในงบประมาณเมื่อมีโหลดสูง

บทเรียน 4 จาก 413 ขั้นตอน

การทดสอบโหลดและการวางแผนความจุ เป็นบทเรียน LLM Apps in Production (RAG + Vector DB + Caching) ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน LLM Apps in Production (RAG + Vector DB + Caching) และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส LLM Apps in Production (RAG + Vector DB + Caching) มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Why Load Test LLM Apps?

LLM apps behave differently under load than typical web services: token generation is slow, requests are long-lived, and upstream provider rate limits add a hard ceiling.

Load testing reveals how your system degrades before real users do.

Key Metrics

Track these under load:

  • Throughput — requests or tokens per second
  • Latency percentiles — p50, p95, p99
  • Error rate — timeouts, 429s
  • Time to first token for streaming

Open vs Closed Load Models

Two ways to generate load:

  • Closed — fixed number of virtual users, each waits for a response before sending the next
  • Open — requests arrive at a fixed rate regardless of responses

Open-model tests better expose queue buildup.

Realistic Workloads

Use realistic prompts. A test with tiny prompts hides cost; production prompts include long retrieved context. Sample real queries and vary input length to mimic actual token distributions.

Percentile Latency in Code

Averages lie; percentiles tell the truth about tail latency.

def percentile(values, p):
    s = sorted(values)
    idx = int(round((p/100) * (len(s)-1)))
    return s[idx]

lat = [120, 130, 140, 900, 150]
print('p95 =', percentile(lat, 95))

Finding the Breaking Point

Ramp the request rate gradually until latency or error rate crosses your SLO. That inflection point is your saturation capacity. Run below it in production with headroom.

Estimating Required Capacity

Use Little's Law: concurrency = arrival rate x average latency. Estimate how many concurrent slots you need for peak traffic.

def concurrency(rps, avg_latency_s):
    return rps * avg_latency_s

print('Need', concurrency(50, 2.0), 'concurrent slots')

Accounting for Provider Limits

Your effective capacity may be capped by the LLM provider's tokens-per-minute and requests-per-minute limits, not your servers. Plan around those quotas and request increases ahead of launches.

Headroom and Autoscaling

Run at a target utilization (often 60-70 percent) so spikes do not immediately saturate. Configure autoscaling on a leading signal like queue depth, since CPU is a poor proxy for LLM load.

Soak and Spike Tests

Beyond steady ramps, run:

  • Soak — sustained load for hours to catch leaks
  • Spike — sudden surge to test autoscaling reaction

From Test to Plan

Turn results into a capacity plan: peak rps, required concurrency, provider quota needs, scaling rules, and a cost estimate. Re-test after major changes since model and prompt changes shift the numbers.

Quick Check

Test your understanding of capacity planning.

Recap

You learned to load test LLM apps with realistic workloads, track latency percentiles and error rate, find the saturation point, and size capacity with Little's Law. Account for provider quotas, keep headroom, autoscale on queue depth, and run soak and spike tests.

เริ่มต้นได้ฟรี

เรียนรู้ LLM Apps in Production (RAG + Vector DB + Caching) ด้วย AI tutor — ฟรี

เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป

คอร์ส
12
บทเรียน
48

คำถามที่พบบ่อย

บทเรียน “การทดสอบโหลดและการวางแผนความจุ” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “การทดสอบโหลดและการวางแผนความจุ” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส LLM Apps in Production (RAG + Vector DB + Caching) ให้อัปเกรดเป็น CoddyKit PRO คอร์ส LLM Apps in Production (RAG + Vector DB + Caching) มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “การทดสอบโหลดและการวางแผนความจุ”

เรียนรู้การจำลองทราฟฟิกที่สมจริงไปยังแอปพลิเคชัน LLM ค้นหาจุดที่ระบบรับไม่ไหว และวางแผนความจุเพื่อให้ระบบจริงยังรวดเร็วและอยู่ภายในงบประมาณเมื่อมีโหลดสูง คุณปฏิบัติ LLM Apps in Production (RAG + Vector DB + Caching) ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน LLM Apps in Production (RAG + Vector DB + Caching) หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน LLM Apps in Production (RAG + Vector DB + Caching) บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “การทดสอบโหลดและการวางแผนความจุ” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน LLM Apps in Production (RAG + Vector DB + Caching) นี้ได้ไหม

ได้ บทเรียน LLM Apps in Production (RAG + Vector DB + Caching) ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. การขยายส่วนประกอบ RAG ในแนวนอน
  2. การสังเกตการณ์ระบบ: การบันทึกเหตุการณ์ ตัวชี้วัด การติดตามการทำงาน
  3. การแจ้งเตือนและการรับมือเหตุขัดข้องสำหรับการปฏิบัติการ LLM
  4. การทดสอบโหลดและการวางแผนความจุ
← กลับไปที่ LLM Apps in Production (RAG + Vector DB + Caching)