WB-Ch26 (production_platform_capstone_lab) — Bản thiết kế Tổng hợp Nền tảng Sản xuất Cuối khóa Track 2 (EDAI)
Hướng dẫn thực hành, cài đặt môi trường .venv/uv và tiêu chuẩn kiểm định pytest.
Unit ID:
T2-P5-U03| Chương Song hành: ch-26-production-engineering-capstone-blueprint.md
Truy xuất Giáo trình Gốc (Final Coursework — Engineering Project): Hợp nhất toàn bộ hạ tầng và quy trình Data, ML, LLM & Agent chuẩn sản xuất trên Track 2 (Part 1–5, Chuyên đề#15–#35), đối chiếu trực tiếp hai kiến trúc tham chiếuRecSys-MLops&card-fraud-platformcùng mẫu hìnhAgentic-LLM-Platform.
Kiến trúc Hai Tầng (100%Offline Verifiable,0# type: ignore,0time.sleep):
- Tầng 1 (
configs/capstone_platform_topology.yaml): Đặc tả cụm19dịch vụ xuyên5mặt phẳng Track 2 (Kafka KRaft,Debezium,Flink,Iceberg/MinIO,ClickHouse,Feast/Redis,Airflow,Vault,Istio mTLS,MCP Sandbox,Envoy AI Gateway,vLLM Disagg,Triton,MLflow 3.0,OTel Collector,Prometheus,Jaeger,Langfuse,Elasticsearch) với19ảnh chính thức ghim tag (python:3.12.8-slim-bookwormthay thế mọi image giả định,0:latest),100%cổng host bind127.0.0.1:,0bí mật tĩnh, và hộp cátmcp_tool_sandbox(cap_drop: [ALL],read_only_root_fs: true,pids_limit: 64,egress_allowlisttrỏ DNS nội bộclickhouse.data-platform.svc.cluster.local:8123&redis.serving-platform.svc.cluster.local:6379).- Tầng 2 (
production_platform_capstone_lab): Mô phỏng xác định (seed=42,N=4,000reqs/tier) độ trễ đuôi xuyên tầng &FinOps TCO, kiểm chứng6/6kịch bản tiêm lỗi thực chiến (gồm mô phỏng hàng đợi GPU sự kiện rời rạc choS3và Kaplan–Meier IPCW choS6), chấm điểm thống nhất6miền(15, 15, 20, 15, 15, 20)=100điểm (đạt>= 80.0 / 100) kèm6điều kiện loại trực tiếp (HD-1..HD-6), kiểm toán hành vi/cấu trúcaudit_behavioral_submission, và dịch vụ sốngFastAPIđo thời gian thực quatime.perf_counter()(TestClient+BoundedInMemorySpanExporter,9+5OTel spans,0PII leaks kèm Luhn check,32/32pytestpass).
1. Bất biến Kỹ thuật Được Chứng minh (artifacts/t2_ch26_wb26_results.json, seed = 42)#
-
Thực nghiệm 1 — Độ trễ Đuôi Xuyên Tầng (
p50/p95/p99),SLO&FinOps TCO(end_to_end_architecture_audit.py):RecSys-MLops(SLO <= 120.0 ms):Naive Monolithđạtp99 = 1186.86 ms(4.88%đạt SLO,$47.72/1M reqs) \(\to\)SOTA 2026 Platformđạtp99 = 86.34 ms(13.75xnhanh hơn),100.0%đạt SLO, và$11.15/1M reqs(-76.63%TCO), nângeffective_goodputtừ3.18lên298.39 rps/GPU.Card-Fraud-Platform(SLO <= 45.0 ms):Naive Monolithđạtp99 = 510.99 ms(0.0%đạt SLO,$32.62/1M reqs) \(\to\)SOTA 2026 Platformđạtp99 = 30.97 ms(16.5xnhanh hơn),100.0%đạt SLO, và$8.80/1M reqs(-73.02%TCO) (590.91 rps/GPU).Agentic-LLM-Platform(SLO <= 900.0 ms):Naive Monolithnổp99 = 10233.99 ms(2.0%đạt SLO,$1248.65/1M reqs) \(\to\)SOTA 2026 Platform(Semantic Cache34%+Disagg P/D+Piecewise CUDA Graphs) đạtp99 = 794.22 ms(12.89xnhanh hơn),99.78%đạt SLO, và$120.57/1M reqs(-90.34%TCO).
-
Thực nghiệm 2 — Kiểm toán Tiêm lỗi Sẵn sàng Sản xuất
6/6Kịch bản (end_to_end_architecture_audit.py):- S1 (
late_data_watermark,6,000sự kiện):Naive(1.0mwatermark) chỉ giữ88.43%(694rơi,11.79%MAPE) vsSOTA(18.0mEvent-Time +allowedLateness+ DLQ) đạt100.0%completeness (0rơi,0.0%MAPE). - S2 (
pit_training_serving_skew,#15,3,000dòng):Naivebị29.07%rò rỉ tương lai (auc_drop = 0.0565,PSI = 0.0699) vsSOTA ASOF PITđạt0.0%rò rỉ,PSI = 0.001(offline 0.7846vsonline 0.7841). - S3 (
bursty_gpu_surge_10x,#21/#22,SLO = 500 ms):Naive12GPU tĩnh tụt15.58%Goodput (p99 = 2509.15 ms) vsSOTA(KEDA10->14GPU + Priority Queue +Admission Controlxả tải60.89%lôbatch) giữ100.0%Goodput tương tác ởp99 = 101.06 ms. - S4 (
mcp_agent_sandbox_isolation,8vector tấn công):Naivechỉ chặn2/8(25.0%), rò rỉ3bí mật vsSOTA MCP Sandboxchặn8/8(100.0%) và0rò rỉ bí mật. - S5 (
canary_sprt_rollback,#16,3,000lượt):Big-Bangphơi nhiễm3,000lượt (351lỗi) vsSOTA Canary + Wald SPRT(boundary A = 4.554) ngắt ngay ở nấc5%(LLR = 4.698, chỉ24lượt /3lỗi), giảm99.2%bán kính nổ (ngăn chặn348lỗi). - S6 (
delayed_label_ipcw_proxy,#17,2,500giao dịch): TạiDay 21(True = 66.04%),Naiveảo giác90.53%(+24.49 pp) vsSOTA(Prediction PSI = 0.4511,Entropy +0.1159 nats,Kaplan–Meier IPCW = 79.08%,Active Audit HT = 62.95%với sai số3.09 pp, sớm39ngày).
- S1 (
-
Thực nghiệm 3 & 4 — Thang điểm
6Miền100Điểm (Đạt>= 80.0,6Lỗi Phủ quyết) & Dịch vụFastAPI+OTel(capstone_service_and_rubric.py):- Thang điểm
100Điểm (6miền(15, 15, 20, 15, 15, 20), đạt>= 80.0 / 100,6Hard Disqualifiers):sota_flagship_submissionđạt96.4/100(CERTIFIED_PRODUCTION_READY);insecure_latest_agent_submissionđạt điểm thô83.0/100nhưng bị0.0điểm hiệu lực (DISQUALIFIED) do kích hoạtunsandboxed_mcp_execution&latest_container_tag_used;naive_monolith_submission(45.5/100,4disqualifiers) cũngDISQUALIFIED; kiểm toán hành viwb26_behavioral_topology_auditđạt100.0/100. - Dịch vụ Sống
FastAPI+OTel+YAML Audit:/health/live = 200,/health/ready = 200(và503khi mất sẵn sàng),/audit/e2eđo độ trễ thật quatime.perf_counter(),/metricssạch nhãn lực lượng cao, thu9live OTel spans +5suite spans =14spans,0rò rỉ PII, vàcapstone_platform_topology.yamlsạch19/19dịch vụ chính thức (0:latest,0bí mật,127.0.0.1:host bind, DNS-onlyegress_allowlist).
- Thang điểm
2. Cấu trúc Thư mục WB-Ch26#
ch26-production-platform-capstone-workbench/
├── configs/
│ └── capstone_platform_topology.yaml # 19 dịch vụ xuyên 5 mặt phẳng (0 :latest, 127.0.0.1:, 0 secrets)
├── src/production_platform_capstone_lab/
│ ├── __init__.py
│ ├── end_to_end_architecture_audit.py # E2E Latency/TCO (3 archetypes) + 6 Failure-Injection Scenarios
│ └── capstone_service_and_rubric.py # 100-Pt Hard-Gated Rubric, YAML Audit, FastAPI + OTel Zero-PII
├── scripts/
│ └── run_lab_demo.py # CLI xuất artifacts/t2_ch26_wb26_results.json (6 KPI, 4 Bar, 4 Table)
├── tests/
│ └── test_production_platform_capstone_lab.py # 32 pytest + hypothesis tests (0 skip, 0 # type: ignore)
├── artifacts/
│ └── t2_ch26_wb26_results.json # Kết quả đo đạc xác định (seed=42)
├── pyproject.toml
├── uv.lock
└── README.md
3. Hướng dẫn Chạy Nhanh & Kiểm định Tự động#
cd 03-track-2-data-and-ai-engineering/part-05-mlops-cicd-and-observability/labs/ch26-production-platform-capstone-workbench
# 1. Sinh báo cáo kết quả tổng hợp chuẩn hóa
PYTHONPATH=src python scripts/run_lab_demo.py --seed 42 --output artifacts/t2_ch26_wb26_results.json
# 2. Kiểm định lint, kiểu tĩnh mypy strict, uv.lock và toàn bộ 32 test cases
ruff check src scripts tests
mypy --strict src tests
pytest -p no:cacheprovider -v
uv lock --check