Mintlify Documentation
Mintlify แพลตฟอร์ม Documentation Site สวยงาม MDX Markdown JSX Built-in Components API Reference Code Blocks Deploy อัตโนมัติ GitHub Custom Domain Analytics Search
High Availability ระบบทำงานต่อเนื่อง Uptime 99.99% Redundancy Load Balancing Failover Multi-region ลด Single Point of Failure
Mintlify Configuration
# === Mintlify Setup ===
# 1. Install Mintlify CLI
# npm i -g mintlify
# mintlify dev # Local development
# 2. mint.json — Configuration File
# {
# "$schema": "https://mintlify.com/schema.json",
# "name": "My API Docs",
# "logo": {
# "dark": "/logo/dark.svg",
# "light": "/logo/light.svg"
# },
# "favicon": "/favicon.svg",
# "colors": {
# "primary": "#0D9373",
# "light": "#07C983",
# "dark": "#0D9373",
# "anchors": { "from": "#0D9373", "to": "#07C983" }
# },
# "topbarLinks": [
# { "name": "Support", "url": "mailto:support@example.com" }
# ],
# "topbarCtaButton": {
# "name": "Dashboard", "url": "https://dashboard.example.com"
# },
# "tabs": [
# { "name": "API Reference", "url": "api-reference" },
# { "name": "SDKs", "url": "sdks" }
# ],
# "anchors": [
# { "name": "Community", "icon": "slack", "url": "https://slack.example.com" },
# { "name": "Blog", "icon": "newspaper", "url": "https://blog.example.com" }
# ],
# "navigation": [
# {
# "group": "Get Started",
# "pages": ["introduction", "quickstart", "authentication"]
# },
# {
# "group": "API Reference",
# "pages": [
# "api-reference/overview",
# {
# "group": "Users",
# "pages": [
# "api-reference/users/list",
# "api-reference/users/create",
# "api-reference/users/get",
# "api-reference/users/update",
# "api-reference/users/delete"
# ]
# }
# ]
# },
# {
# "group": "Guides",
# "pages": ["guides/ha-setup", "guides/monitoring", "guides/scaling"]
# }
# ],
# "footerSocials": {
# "github": "https://github.com/example",
# "twitter": "https://twitter.com/example"
# },
# "api": {
# "baseUrl": "https://api.example.com",
# "auth": { "method": "bearer" }
# }
# }
import json
mintlify_features = {
"MDX Support": "Markdown + JSX Interactive Components",
"API Reference": "Auto-generate จาก OpenAPI Spec",
"Code Blocks": "Syntax Highlighting หลายภาษา Tabs",
"Search": "Full-text Search Built-in",
"Analytics": "Page Views, Popular Pages, Search Queries",
"Custom Domain": "ใช้ Domain ของตัวเอง SSL อัตโนมัติ",
"Versioning": "Multiple Versions ของ Docs",
"GitHub Sync": "Auto Deploy เมื่อ Push ไป GitHub",
}
print("Mintlify Features:")
for feature, desc in mintlify_features.items():
print(f" {feature}: {desc}")
High Availability Architecture
# ha_setup.py — High Availability Architecture
from dataclasses import dataclass, field
from typing import List, Dict
@dataclass
class HAComponent:
name: str
role: str
replicas: int
failover: str
health_check: str
class HAArchitecture:
"""High Availability Architecture"""
def __init__(self, target_uptime: str):
self.target_uptime = target_uptime
self.components: List[HAComponent] = []
def add(self, comp: HAComponent):
self.components.append(comp)
def show_architecture(self):
print(f"\n{'='*55}")
print(f"High Availability Architecture")
print(f"Target Uptime: {self.target_uptime}")
print(f"{'='*55}")
for comp in self.components:
print(f"\n [{comp.name}] ({comp.role})")
print(f" Replicas: {comp.replicas}")
print(f" Failover: {comp.failover}")
print(f" Health Check: {comp.health_check}")
def uptime_calculator(self):
"""คำนวณ Uptime"""
uptimes = {
"99.0% (Two Nines)": {"downtime_year": "3.65 วัน", "downtime_month": "7.31 ชม."},
"99.9% (Three Nines)": {"downtime_year": "8.77 ชม.", "downtime_month": "43.8 นาที"},
"99.95%": {"downtime_year": "4.38 ชม.", "downtime_month": "21.9 นาที"},
"99.99% (Four Nines)": {"downtime_year": "52.6 นาที", "downtime_month": "4.38 นาที"},
"99.999% (Five Nines)": {"downtime_year": "5.26 นาที", "downtime_month": "26.3 วินาที"},
}
print(f"\n Uptime Calculator:")
for level, times in uptimes.items():
print(f" {level}")
print(f" Downtime/Year: {times['downtime_year']}")
print(f" Downtime/Month: {times['downtime_month']}")
def ha_patterns(self):
"""HA Design Patterns"""
patterns = {
"Active-Active": {
"desc": "ทุก Instance รับ Traffic พร้อมกัน",
"pros": "Performance สูง ใช้ทรัพยากรเต็มที่",
"cons": "ซับซ้อน Data Consistency ยาก",
"use": "Web Servers, API Servers, CDN",
},
"Active-Passive": {
"desc": "Instance หลักทำงาน Standby รอ Failover",
"pros": "ง่าย Data Consistency ดี",
"cons": "Standby ไม่ได้ใช้งาน Failover ช้ากว่า",
"use": "Database Primary-Replica, DNS Failover",
},
"Multi-Region": {
"desc": "Deploy หลาย Region ทั่วโลก",
"pros": "Latency ต่ำ ทนภัยพิบัติ",
"cons": "Cost สูง Data Replication ซับซ้อน",
"use": "Global SaaS, CDN, DNS GeoDNS",
},
}
print(f"\n HA Patterns:")
for name, info in patterns.items():
print(f"\n [{name}]")
print(f" {info['desc']}")
print(f" Pros: {info['pros']}")
print(f" Cons: {info['cons']}")
print(f" Use: {info['use']}")
# ตัวอย่าง
ha = HAArchitecture("99.99% (Four Nines)")
components = [
HAComponent("Load Balancer", "Edge", 2,
"DNS Failover + Health Check", "/health every 10s"),
HAComponent("API Server", "Backend", 3,
"Auto-scaling + Rolling Update", "/api/health every 5s"),
HAComponent("PostgreSQL", "Database", 3,
"Primary-Replica Failover (Patroni)", "pg_isready every 5s"),
HAComponent("Redis Cluster", "Cache", 6,
"Redis Sentinel Auto-failover", "PING every 3s"),
HAComponent("Kafka Cluster", "Message Queue", 3,
"ISR Replication Factor 3", "Broker Health every 10s"),
HAComponent("Mintlify Docs", "Documentation", 0,
"Edge CDN (Vercel/Cloudflare)", "HTTP 200 check"),
]
for comp in components:
ha.add(comp)
ha.show_architecture()
ha.uptime_calculator()
ha.ha_patterns()
Monitoring และ Alerting
# ha_monitoring.py — HA Monitoring Stack
monitoring_stack = {
"Prometheus": {
"role": "Metrics Collection",
"config": "scrape_interval: 15s, evaluation_interval: 15s",
"targets": "API Servers, Database, Redis, Kafka",
},
"Grafana": {
"role": "Dashboards & Visualization",
"dashboards": "Uptime, Latency, Error Rate, Throughput",
"alerts": "Slack, PagerDuty, Email",
},
"Alertmanager": {
"role": "Alert Routing & Deduplication",
"routes": "Critical -> PagerDuty, Warning -> Slack",
"silences": "Maintenance Window Silences",
},
"Loki": {
"role": "Log Aggregation",
"sources": "Application Logs, System Logs, Audit Logs",
"query": "LogQL queries in Grafana",
},
"Uptime Kuma": {
"role": "External Uptime Monitoring",
"checks": "HTTP, TCP, DNS, Ping, Keyword",
"notifications": "Slack, Telegram, Discord, Email",
},
}
print("HA Monitoring Stack:")
for tool, info in monitoring_stack.items():
print(f"\n [{tool}] — {info['role']}")
for key, value in info.items():
if key != "role":
print(f" {key}: {value}")
# SLA & SLO
sla_slo = {
"SLA (Service Level Agreement)": {
"definition": "สัญญาระดับบริการกับลูกค้า",
"example": "Uptime 99.9%, Response < 500ms",
"penalty": "Credit/Refund ถ้าไม่ถึง",
},
"SLO (Service Level Objective)": {
"definition": "เป้าหมายภายในทีม (สูงกว่า SLA)",
"example": "Uptime 99.95%, Response < 200ms",
"penalty": "ทีมต้องแก้ไขปรับปรุง",
},
"SLI (Service Level Indicator)": {
"definition": "ตัวชี้วัดจริง",
"example": "Actual Uptime, P99 Latency, Error Rate",
"penalty": "ใช้ตัดสินว่าถึง SLO/SLA หรือไม่",
},
"Error Budget": {
"definition": "งบ Downtime ที่ยอมรับได้",
"example": "SLO 99.9% = Error Budget 0.1% = 43.8 นาที/เดือน",
"penalty": "หมด Error Budget = Freeze Deployment",
},
}
print(f"\n\nSLA / SLO / SLI / Error Budget:")
for term, info in sla_slo.items():
print(f"\n [{term}]")
for key, value in info.items():
print(f" {key}: {value}")
Best Practices
- Mintlify: ใช้ mint.json กำหนด Navigation, API Reference, Components
- MDX: เขียน Interactive Docs ด้วย Markdown + JSX Components
- Multi-Region: Deploy หลาย Region ลด Latency ทน Disaster
- Health Checks: ทุก Service ต้องมี Health Endpoint ตรวจสอบทุก 5-10 วินาที
- Error Budget: กำหนด Error Budget Freeze Deploy เมื่อหมด
- Runbook: เขียน Runbook สำหรับ Incident Response ใน Mintlify Docs
Mintlify คืออะไร
แพลตฟอร์ม Documentation Site สวยงาม MDX Markdown JSX Built-in Components API Reference Deploy GitHub Custom Domain Analytics Search
High Availability คืออะไร
ระบบทำงานต่อเนื่อง Uptime สูง 99.99% Redundancy Load Balancing Failover Health Checks Multi-region ลด Single Point of Failure
Mintlify ใช้กับ HA อย่างไร
Mintlify Deploy Edge CDN อัตโนมัติ SSL Backend API HA Setup แยก Load Balancer หลาย Instances Database Replica Health Checks Failover
MDX คืออะไร
Markdown JSX รวม Markdown เขียนง่าย React Components ยืดหยุ่น Interactive Documentation API Playground Code Tabs Callouts Cards Mintlify Docusaurus
สรุป
Mintlify Documentation Site MDX Markdown JSX API Reference Deploy GitHub High Availability Uptime 99.99% Redundancy Load Balancing Failover Multi-region Health Checks Monitoring Prometheus Grafana SLA SLO Error Budget
