Cloudflare ล่ม 12 ก.ย. 2025: React useEffect Bug → Tenant Service 5xx Kubernetes
กลับหน้ารายการบทความ

Cloudflare ล่ม 12 ก.ย. 2025: React useEffect Bug → Tenant Service 5xx Kubernetes

Cloudflare outage 12/9/2025 React useEffect infinite API calls → Tenant Service overload Timeline, Kubernetes metrics, rate limiting, Argo Rollouts fix, code examples

cloudflare อัพเดต: 8 มกราคม 2569

Cloudflare ล่ม 12 ก.ย. 2025: React useEffect Bug → Tenant Service API 5xx ทั่วโลก
Cloudflare outage จาก React useEffect hook bug ใน Dashboard เรียก Tenant Service API ซ้ำ → Kubernetes pods overload Global rate limit + Argo Rollouts fix

Root Cause: React useEffect Bug

🐛 Dashboard component:
useEffect(() => {
fetchTenantAPI(); // ❌ Runs on EVERY render
}, []); // Dependency array ignored
✅ Fixed version:
useEffect(() => {
let mounted = true;
fetchTenantAPI().then(data => {
if (mounted) setTenant(data);
});
return () => { mounted = false; };
}, []);
Thundering Herd: 10K+ users hit API simultaneously

Timeline Cloudflare Outage

09:15 UTC: Dashboard deploy (buggy useEffect)
09:22 UTC: Tenant Service CPU 1200%
09:28 UTC: API 5xx errors spike
09:45 UTC: Global rate limit (100 req/min)
10:15 UTC: Scale pods 2x → Still failing
10:30 UTC: Rollback dashboard → Secondary outage
11:12 UTC: Staggered API calls (random delay)
12:05 UTC: Full recovery
Duration: 2 ชม. 50 นาที

Impact: Services & Metrics

ServiceError RateUsers Affected
Tenant Service API99% 5xx500K+
Cloudflare Dashboard95%1M+
Workers KV45%100K
Access Policies78%200K
DownDetector: 850K reports peak

Technical Deep Dive: Kubernetes Overload

Kubernetes Metrics:
- Pods: 50 → 200 (auto-scaling failed)
- CPU: 1200% sustained
- Memory: 95% cluster capacity
- API calls/sec: 50K → 500K spike
Rate Limiting Fix:
// Global rate limiter
const rateLimit = new RateLimiter({
points: 100, // requests
duration: 60, // seconds
});

Cloudflare Response & Mitigation

🔧 09:45: Global rate limit 100/min
⚙️ 10:15: Horizontal Pod Autoscaler 2x
🔄 10:30: Argo Rollout rollback
⏱️ 11:12: Random jitter (100-500ms delay)
📊 11:45: Custom metrics (new vs retry)
Argo Rollouts Config:
strategy:
canary:
steps:
- setWeight: 20
- pause: {duration: 300}

Lessons Learned: Production Best Practices

✅ useEffect cleanup + abort controller
✅ Rate limiting ALL public APIs
✅ Staggered deploys (Argo CD)
✅ Circuit breakers (Istio)
✅ Thundering herd protection

Post-Mortem Action Items

IssueFixTimeline
useEffect bugESLint rules + review✅ Done
No rate limitsGlobal API limits✅ Done
AutoscalingHPA tuning + VPAQ4 2025
MonitoringCustom retry metrics✅ Live
RollbackArgo Rollouts PA✅ Live

Code: The Bug + Production Fix

Buggy Dashboard (React 18):
useEffect(() => {
fetch('/api/tenant').then(setData); // Runs infinitely
}, [userId]); // Missing deps
Fixed Production:
const abortController = useRef();
useEffect(() => {
abortController.current = new AbortController();
fetch('/api/tenant', { signal: abortController.current.signal })
.then(setData)
.catch(err => err.name === 'AbortError' || handleError(err));
return () => abortController.current?.abort();
}, []);
D

DRITESTUDIO

บริษัท ไดรท์สตูดิโอ จำกัด - ผู้ให้บริการ Cloud, VPS, Hosting และ Colocation ในประเทศไทย

จัดการการตั้งค่าคุกกี้ของคุณ

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

คุกกี้ที่จำเป็น

คุกกี้เหล่านี้จำเป็นสำหรับการทำงานของเว็บไซต์ ช่วยให้ฟังก์ชันพื้นฐานเช่นการนำทางหน้าเว็บและการเข้าถึงพื้นที่ที่ปลอดภัย

ดูคุกกี้ที่ใช้
  • คุกกี้เซสชัน (การจัดการเซสชัน)
  • คุกกี้ความปลอดภัย (การป้องกัน CSRF)
เปิดเสมอ

คุกกี้ฟังก์ชัน

คุกกี้เหล่านี้ช่วยให้ฟีเจอร์ส่วนบุคคลเช่นการตั้งค่าภาษาและธีมทำงานได้ หากไม่มีคุกกี้เหล่านี้ ฟีเจอร์บางอย่างอาจทำงานไม่ถูกต้อง

ดูคุกกี้ที่ใช้
  • lang (การตั้งค่าภาษา)
  • theme (โหมดมืด/สว่าง)

คุกกี้วิเคราะห์

คุกกี้เหล่านี้ช่วยให้เราเข้าใจว่าผู้เข้าชมโต้ตอบกับเว็บไซต์อย่างไรโดยรวบรวมและรายงานข้อมูลแบบไม่ระบุตัวตน

ดูคุกกี้ที่ใช้
  • _ga (Google Analytics)
  • _gid (Google Analytics)

คุกกี้การตลาด

คุกกี้เหล่านี้ใช้เพื่อติดตามผู้เข้าชมข้ามเว็บไซต์เพื่อแสดงโฆษณาที่เกี่ยวข้องตามความสนใจของคุณ

ดูคุกกี้ที่ใช้
  • คุกกี้โฆษณา
  • พิกเซลรีมาร์เก็ตติ้ง

นโยบายความเป็นส่วนตัว