Thuta Learning
Cloud Providers & Platforms
IntermediateDevOps & Toolsintermediate

Cloudflare - DNS ထက်ပိုပါတယ်

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • Cloudflare - DNS ထက်ပိုပါတယ် concept ကို နားလည်ရှင်းပြနိုင်ရန်
  • Diagram/table ကို ဖတ်ပြီး platform/provider category တွေ ဘယ်လို ကွာခြားသလဲ ခြေရာခံနိုင်ရန်
  • ကိုယ့် project အတွက် ဘယ် platform category ကို ဘယ်လို ရွေးချယ်သင့်သလဲ ရှင်းပြနိုင်ရန်

နားလည်ထားရမယ့် အချက်

လူအများစုက Cloudflare ကို DNS records စီမံတဲ့နေရာအဖြစ် စတွေ့ရပေမယ့် DNS ဆိုတာ ပိုကြီးတဲ့ edge platform တစ်ခုရဲ့ ဝင်ပေါက်တစ်ခုသာ ဖြစ်ပါတယ်။

  • CDN က static asset တွေကို visitor အနီးနားမှာ cache လုပ်ပေးပြီး latency လျှော့ချကာ origin load ကို လျှော့ပေးသည်။
  • DDoS protection နှင့် Web Application Firewall (WAF) တို့က traffic malicious ကို app ကို မထိမီ စစ်ထုတ်ပေးသည်။
  • Cloudflare Workers က code အစစ်ကို edge မှာ run ပေးသည် -- user အနီးဆုံးမှာ ဖြစ်ပြီး central region တစ်ခုတည်းမှာ မဟုတ်ပါ။
  • Cloudflare Pages က static နှင့် full-stack application တွေကို Cloudflare network ကနေ တိုက်ရိုက် deploy ပေးသည်။

mental model အနေနဲ့: User -> Cloudflare Edge (cache, security, edge logic) -> Origin။ Request တွေဟာ server အစစ်ကို မရောက်ခင် (သို့) ရောက်စရာမလိုအောင် edge ကို ဖြတ်သန်းပါတယ်။

Cloudflare ဟာ app run နေတဲ့နေရာ ဖြစ်ချင်မှ ဖြစ်ပါလိမ့်မယ်။ VPS၊ PaaS၊ cloud တခြားတစ်ခုမှာ origin ရှိပြီး Cloudflare က ရှေ့မှာ proxy/cache/protect လုပ်ပေးတဲ့ pattern ဟာ ရိုးရိုးတွေ့ရလေ့ ရှိပါတယ်။

Edge Network
End user တွေနဲ့ နီးအောင် ကမ္ဘာတစ်ဝှမ်း ဖြန့်ကျက်ထားတဲ့ data center အစုအဝေးဖြစ်ပြီး caching, security, compute အတွက် latency လျှော့ချရန် အသုံးပြုသည်။
CDN
Content delivery network -- request တောင်းဆိုသူနဲ့ နီးတဲ့နေရာကနေ static content ကို cache လုပ်ပြီး serve ပေးတဲ့ distributed server system တစ်ခုဖြစ်သည်။
text
CLOUDFLARE AS AN EDGE LAYER
---------------------------
             +-------------------------+
             |     Cloudflare Edge     |
User ------->|  Cache | Security       |------->  Origin
             |  Edge Logic (Workers)   |
             +-------------------------+

Origin can be hosted anywhere -- a VPS, a PaaS, another
cloud provider. Cloudflare proxies, caches, and protects
traffic in front of it.

လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်

Cloudflare ထဲက DNS record တစ်ခုချင်းစီကို proxied (edge ကနေ ဖြတ်) သို့မဟုတ် DNS only (origin ဆီ တိုက်ရိုက်) ဆိုပြီး သတ်မှတ်နိုင်ပါတယ်။ ဒီ toggle တစ်ခုတည်းက Cloudflare edge feature တွေ record ရဲ့ traffic မှာ အလုပ်လုပ်မလား မလုပ်ဘူးလားဆိုတာ ဆုံးဖြတ်ပေးပါတယ်။

Caching rule တွေက edge ကနေ serve မလား origin ကနေ အသစ်ယူမလား ဆုံးဖြတ်ပေးပါတယ်။ Security setting တွေကတော့ သံသယဖြစ်စရာ traffic ကို server ကို ဘာမှမထိခိုက်ခင် challenge/block လုပ်ပါတယ်။

DNS နှင့် proxying ဖြင့် စတင်ပါ

Domain ကို Cloudflare ဆီညွှန်းပြီး code ပြောင်းစရာမလိုဘဲ basic caching/security အတွက် proxying ကို ဖွင့်ထားပါ။

Caching နှင့် security ကို ချိန်ညှိပါ

Site ရဲ့ traffic pattern အစစ်ကို လေ့လာသိရှိလာသလောက် caching rule နှင့် security setting တွေကို ချိန်ညှိပါ။

လိုအပ်မှသာ Workers သို့မဟုတ် Pages ထည့်ပါ

Edge compute (သို့) edge-hosted deployment ကို တကယ့်လိုအပ်ချက် ပေါ်လာမှသာ သုံးပါ -- default အနေနဲ့ မသုံးပါနှင့်။

Dashboard workflow တွေ မကြာခဏပြောင်းလဲနေတဲ့အတွက် ရေရှည်တည်တံ့တဲ့ skill ပေါ်မှာ အာရုံစိုက်ပါ -- ဖြေရှင်းနေတဲ့ ပြဿနာက caching လား၊ security လား၊ edge compute လားဆိုတာ ခွဲခြားသိနိုင်ခြင်းပါပဲ။

အတူတူ စမ်းရေးကြည့်မယ်

javascript
function classifyCloudflareLayer(request) {
  // request: { type: "static-asset" | "dynamic-api" | "edge-logic-needed" }
  if (request.type === "static-asset" && request.cacheable) {
    return "Cache";
  }
  if (request.type === "edge-logic-needed") {
    return "Edge Logic (Workers)";
  }
  return "Origin";
}

const examples = [
  { label: "logo.png", type: "static-asset", cacheable: true },
  { label: "A/B test redirect", type: "edge-logic-needed", cacheable: false },
  { label: "POST /api/orders", type: "dynamic-api", cacheable: false },
];

for (const ex of examples) {
  console.log(`${ex.label} -> ${classifyCloudflareLayer(ex)}`);
}
You should see
logo.png -> Cache
A/B test redirect -> Edge Logic (Workers)
POST /api/orders -> Origin
(Static asset ကို Cache၊ edge logic လိုအပ်တာကို Workers၊ ကျန်တာကို Origin ဆီ ပို့ကြောင်း output က ပြသည်။)

၅ မိနစ် စမ်းကြည့်

နေ့စဉ်သုံးနေတဲ့ website တစ်ခုကို ရွေးပါ။ ဘယ် request တွေက Cache ကနေ serve ဖြစ်နိုင်လဲ၊ ဘယ်တွေက Edge Logic လိုအပ်နိုင်လဲ၊ ဘယ်တွေက Origin ကို ရောက်ရမလဲ ခန့်မှန်းပြီး အကြောင်းပြချက်ပေးပါ။

သတိလေးတစ်ချက်

DNS ကို Cloudflare ဆီညွှန်းလိုက်ရုံနဲ့ site ကို အလိုအလျောက် လုံခြုံစေမယ်၊ မြန်စေမယ်လို့ ထင်ခြင်း -- proxying, caching rule, security setting တွေကို တမင်တကာ ပြင်ဆင်ရဦးမည်။

DNS record တစ်ခု proxied မဖြစ်ရင် Cloudflare edge feature (caching, WAF, Workers) ဘယ်တစ်ခုမှ ဒီ record ရဲ့ traffic မှာ အလုပ်မလုပ်ကြောင်း မေ့သွားခြင်း။

Cloudflare: How Cloudflare WorksCloud Providers & Platforms

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • DNS ကို Cloudflare ဆီညွှန်းလိုက်ရုံနဲ့ site ကို အလိုအလျောက် လုံခြုံစေမယ်၊ မြန်စေမယ်လို့ ထင်ခြင်း -- proxying, caching rule, security setting တွေကို တမင်တကာ ပြင်ဆင်ရဦးမည်။
  • DNS record တစ်ခု proxied မဖြစ်ရင် Cloudflare edge feature (caching, WAF, Workers) ဘယ်တစ်ခုမှ ဒီ record ရဲ့ traffic မှာ အလုပ်မလုပ်ကြောင်း မေ့သွားခြင်း။
  • ဒီ course က provider/platform landscape ကို comparison-level မှာသာ သင်ပေးပါတယ် — AWS, Docker, CI/CD, Firebase, deployment fundamentals ကို နက်နက်ရှိုင်းရှိုင်း လေ့လာချင်ရင် AWS Fundamentals, Docker, CI/CD, Firebase, Cloud & Deployment tutorial တွေဆီ ဆက်သွားပါ။

လေ့ကျင့်ခန်း

နေ့စဉ်သုံးနေတဲ့ website တစ်ခုကို ရွေးပါ။ ဘယ် request တွေက Cache ကနေ serve ဖြစ်နိုင်လဲ၊ ဘယ်တွေက Edge Logic လိုအပ်နိုင်လဲ၊ ဘယ်တွေက Origin ကို ရောက်ရမလဲ ခန့်မှန်းပြီး အကြောင်းပြချက်ပေးပါ။

You'll know it worked when: logo.png -> Cache A/B test redirect -> Edge Logic (Workers) POST /api/orders -> Origin (Static asset ကို Cache၊ edge logic လိုအပ်တာကို Workers၊ ကျန်တာကို Origin ဆီ ပို့ကြောင်း output က ပြသည်။)

Cloudflare - DNS ထက်ပိုပါတယ် | Thuta Learning