บทที่ 2: Hosting & Cloud
“บ้านสวยแค่ไหน ถ้าไม่มีที่ดินตั้ง ก็เป็นได้แค่แบบบ้านบนกระดาษ”
The Blueprint (พิมพ์เขียว)
Section titled “The Blueprint (พิมพ์เขียว)”คุณเขียนโค้ดเสร็จแล้ว ทุกอย่างทำงานได้บนเครื่องคุณ แต่คำถามคือ:
“แล้วจะเอาไปวางไว้ไหน ให้คนทั่วโลกเข้าถึงได้?”
Hosting/Cloud = การเช่าที่ดินที่มีระบบสาธารณูปโภคพร้อม
🤔 ปัญหาที่ต้องแก้
Section titled “🤔 ปัญหาที่ต้องแก้”- คอมพิวเตอร์ของคุณไม่ได้เปิด 24/7
- อินเทอร์เน็ตบ้านไม่มี Static IP
- รับโหลดหนักไม่ได้
- ไม่มีระบบ Backup
The Construction Site (หน้างานก่อสร้าง)
Section titled “The Construction Site (หน้างานก่อสร้าง)”🏢 ประเภทของ “ที่ดิน” ในโลกดิจิทัล
Section titled “🏢 ประเภทของ “ที่ดิน” ในโลกดิจิทัล”| ประเภท | เปรียบเทียบ | ราคา | เหมาะกับ |
|---|---|---|---|
| Shared Hosting | คอนโด | $ | บล็อก, Landing Page |
| VPS | ทาวน์เฮาส์ | $$ | SME, Startup |
| Dedicated Server | บ้านเดี่ยว | $$$ | องค์กรใหญ่ |
| Cloud | ที่ดินยืดหยุ่น | $-$$$$ | ทุกขนาด |
🏠 Shared Hosting — คอนโดมิเนียม
Section titled “🏠 Shared Hosting — คอนโดมิเนียม”ข้อดี:
- ราคาถูกมาก (99฿/เดือน)
- ตั้งค่าง่าย มี cPanel
- มีคนดูแลเซิร์ฟเวอร์ให้
ข้อเสีย:
- แชร์ทรัพยากรกับคนอื่น
- เพื่อนร่วมห้องใช้หนัก เว็บคุณก็ช้า
เหมาะกับ: บล็อก WordPress, Landing Page
🏘️ VPS — ทาวน์เฮาส์
Section titled “🏘️ VPS — ทาวน์เฮาส์”ข้อดี:
- มีทรัพยากรของตัวเอง
- ได้สิทธิ์ Root Access
- ราคาปานกลาง ($5-50/เดือน)
ข้อเสีย:
- ต้องดูแลเซิร์ฟเวอร์เอง
เหมาะกับ: Web App, API Server, Startup
☁️ Cloud — ที่ดินยืดหยุ่น
Section titled “☁️ Cloud — ที่ดินยืดหยุ่น”ข้อดี:
- ยืดหยุ่น คนเยอะก็ขยาย คนน้อยก็ลด
- จ่ายตามใช้
- บริการครบ
ข้อเสีย:
- ค่าใช้จ่ายอาจบานปลาย ถ้าไม่ควบคุม
เหมาะกับ: Startup ที่ต้อง Scale, Enterprise
Material Selection (เลือกสเปกวัสดุ)
Section titled “Material Selection (เลือกสเปกวัสดุ)”📊 Platform แนะนำ
Section titled “📊 Platform แนะนำ”| Platform | ประเภท | ฟรี Tier | เหมาะกับ |
|---|---|---|---|
| Vercel | PaaS | ✅ | Next.js, Frontend |
| DigitalOcean | IaaS | ❌ | VPS, Backend |
| AWS | IaaS/PaaS | ✅ (12 เดือน) | Enterprise |
| GCP | IaaS/PaaS | ✅ ($300) | ML/AI |
| Supabase | BaaS | ✅ | MVP, Startup |
🚀 Vercel — สำหรับ Next.js
Section titled “🚀 Vercel — สำหรับ Next.js”- Deploy จาก GitHub อัตโนมัติ
- Preview Deployments สำหรับทุก PR
- Global CDN ในตัว
- ฟรี สำหรับโปรเจกต์ส่วนตัว
🟢 Supabase — Backend-as-a-Service
Section titled “🟢 Supabase — Backend-as-a-Service”- PostgreSQL Database
- Auto-generated API
- Authentication, Storage ครบ
- Firebase alternative ที่เป็น Open Source
Architect’s Note (บันทึกสถาปนิก)
Section titled “Architect’s Note (บันทึกสถาปนิก)”⚠️ ข้อควรระวัง
Section titled “⚠️ ข้อควรระวัง”- Vendor Lock-in — ใช้ Containers (Docker) เพื่อความยืดหยุ่น
- อย่าเลือก Over-spec — เริ่มเล็กๆ แล้วค่อย Scale
💡 Best Practices
Section titled “💡 Best Practices”- ใช้ Infrastructure as Code (Terraform)
- แยก Development / Staging / Production
- Backup อย่างสม่ำเสมอ
- Monitor ทุกอย่าง (Uptime, Performance)
📝 สรุป
Section titled “📝 สรุป”| หัวข้อ | สรุป |
|---|---|
| Shared Hosting | คอนโด แชร์ทรัพยากร ราคาถูก |
| VPS | ทาวน์เฮาส์ ทรัพยากรของตัวเอง |
| Cloud | ยืดหยุ่น จ่ายตามใช้ |
| Vercel | Deploy Next.js ง่ายสุด |
| Supabase | Backend สำเร็จรูป PostgreSQL |