Thuta Learning
Cloud & Deployment
BasicDevOps & Toolsbeginner

Website တစ်ခု ဖွင့်လိုက်ရင် ဘာတွေ ဖြစ်လဲ?

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

  • Website တစ်ခု ဖွင့်လိုက်ရင် ဘာတွေ ဖြစ်လဲ? concept ကို နားလည်ရှင်းပြနိုင်ရန်
  • Diagram ကို ဖတ်ပြီး architecture ထဲမှာ request/data ဘယ်လိုစီးဆင်းသလဲ ခြေရာခံနိုင်ရန်
  • ကိုယ့် project အတွက် ဘယ်လို ဆုံးဖြတ်သင့်သလဲ ရှင်းပြနိုင်ရန်

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

Domain တစ်ခုကို browser ထဲ ရိုက်ထည့်တာဟာ ချက်ချင်းဖြစ်သလို ခံစားရပေမယ့် pixel တစ်ခုမှ မပေါ်ခင် အဆင့်တစ်ခုလုံး run သွားတာပါ။

Domain ရိုက်

User က thutatech.com ကို browser ထဲ ရိုက်ထည့်တယ်။

DNS lookup

DNS က domain name ကို IP address အဖြစ် ပြန်ပြောင်းပေးတယ် — phonebook လိုပါပဲ။

Connect

Browser က အဲဒီ IP address ရှိတဲ့ server ကို connection ဖွင့်တယ်။

HTTPS handshake

Content ဘာမှ မဖလှယ်ခင် connection ကို encrypted ဖြစ်အောင် handshake လုပ်တယ်။

HTTP request ပို့

Browser က server ကို "ဒီ page ကို ပို့ပါ" လို့ တောင်းဆိုတယ်။

Server တုန့်ပြန်

Server (သို့) CDN က HTML, CSS, JS တွေကို ပြန်ပို့တယ်။

Render

Browser က ရလာတာအားလုံးကို တကယ်မြင်ရတဲ့ page အဖြစ် ပြောင်းပေးတယ်။

ဒီ lesson က DNS နဲ့ HTTPS ကို conceptual level မှာပဲ တမင် ထားပါတယ်။ ဒီ site ရဲ့ Networking tutorial က DNS record resolution နဲ့ TCP/TLS handshake တွေကို အသေးစိတ် technical depth နဲ့ ဖုံးလွှမ်းထားပါတယ်။

text
HOW A WEBSITE LOADS
-------------------
1. You type: thutatech.com
        |
        v
2. DNS lookup -> finds the server's IP address
        |
        v
3. Browser connects to that server (TCP)
        |
        v
4. HTTPS handshake -> connection becomes encrypted
        |
        v
5. Browser sends an HTTP request ("send me this page")
        |
        v
6. Server or CDN sends back HTML, CSS, and JS
        |
        v
7. Browser renders the page you see

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

အောက်က code ဟာ simulation တစ်ခုပါ၊ network call အစစ် မဟုတ်ပါ — ဒီ lesson ရဲ့ အစီအစဉ်ကို abstract အဖြစ် မထားဘဲ ပီပြင်စွာ မြင်ရအောင် ဖန်တီးထားတာပါ။ resolveDNS က domain ကို IP address အဖြစ် ပြန်ပြောင်းဖို့ DNS ကို တောင်းဆိုတာကို ကိုယ်စားပြုတယ်၊ connect က browser က အဲဒီ address ကို connection ဖွင့်တာကို ကိုယ်စားပြုတယ်၊ sendRequest ကတော့ page တောင်းဆိုတဲ့ HTTP request အစစ်ကို ကိုယ်စားပြုတယ်။

Function သုံးခုကို အစီအစဉ်အတိုင်း run ပြီး ရလဒ်တစ်ခုစီကို log ထုတ်တာက အစီအစဉ်အစစ်ကို အဆင့်ဆင့် ထင်ဟပ်ပါတယ် — အရင်ဆုံး name တစ်ခုကို address အဖြစ် ပြောင်းမှ၊ ဘာတစ်ခုနဲ့မဆို ချိတ်ဆက်နိုင်ပြီး၊ ချိတ်ဆက်ပြီးမှသာ content တောင်းဆိုနိုင်ပါတယ်။ Browser အစစ်တစ်ခုမှာ ဒီအဆင့်တစ်ခုစီက network traffic အစစ်ကို involve လုပ်ပြီး၊ HTTPS site အတွက် connect နဲ့ request အဆင့်ကြားမှာ encryption handshake တစ်ခုပါ ပါဝင်ပါသေးတယ် — ဒီ simplified version ကတော့ shape ကို မြင်နိုင်ဖို့ တမင် ချန်ထားခဲ့ပါတယ်။

ဒီအစီအစဉ်အစစ်ကို ကိုယ်တိုင်တွေ့ချင်ရင် browser ရဲ့ developer tools ကို ဖွင့်ပြီး Network tab ဆီ သွားပြီး page တစ်ခုကို reload လုပ်ကြည့်ပါ — DNS lookup, connection, request/response entry အစစ်တွေကို တွေ့ရပါလိမ့်မယ်။

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

javascript
function resolveDNS(domain) {
  return "203.0.113.42";
}

function connect(ip) {
  return `Connected to ${ip} over TCP`;
}

function sendRequest(path) {
  return `GET ${path} -> 200 OK`;
}

console.log("Simplified simulation (not a real network call):");
const ip = resolveDNS("thutatech.com");
console.log(`1. DNS resolved thutatech.com -> ${ip}`);
console.log(`2. ${connect(ip)}`);
console.log(`3. ${sendRequest("/index.html")}`);
You should see
Simplified simulation (not a real network call):
1. DNS resolved thutatech.com -> 203.0.113.42
2. Connected to 203.0.113.42 over TCP
3. GET /index.html -> 200 OK

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

sendRequest function ကို ပြင်ပြီး path parameter အစား "/about.html" ကို hardcode ထည့်ပါ၊ ပြီးရင် resolveDNS ကို "learn.thutatech.com" domain အသစ်တစ်ခုနဲ့ ခေါ်ပြီး IP address value ကို ပြောင်းလိုက်ကာ output ဘယ်လို ပြောင်းလဲသွားလဲ ကြည့်ပါ။

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

HTTPS site တစ်ခုမှာတောင် HTTP request ကို DNS lookup မလုပ်ခင် ပို့လို့ရမယ်လို့ ထင်ခြင်း — connection အရင် ရှိရပါမယ်

DNS lookup ဆိုတာ တစ်ခါတည်း ဖြစ်ပြီး ထာဝရ တစ်ခြားမပြောင်းဘူးလို့ ထင်ခြင်း (တကယ်က cache expire ဖြစ်နိုင်၊ ပြန် resolve ဖြစ်နိုင်ပါတယ်)

Website Load လုပ်ငန်းစဉ် အစီအစဉ်

အောက်ပါ အဆင့်များထဲက ဘယ်စီစဉ်မှုက မှန်ကန်လဲ — DNS lookup, HTTPS handshake, HTTP request?

MDN: Populating the page: how browsers workCloud & Deployment

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

  • HTTPS site တစ်ခုမှာတောင် HTTP request ကို DNS lookup မလုပ်ခင် ပို့လို့ရမယ်လို့ ထင်ခြင်း — connection အရင် ရှိရပါမယ်
  • DNS lookup ဆိုတာ တစ်ခါတည်း ဖြစ်ပြီး ထာဝရ တစ်ခြားမပြောင်းဘူးလို့ ထင်ခြင်း (တကယ်က cache expire ဖြစ်နိုင်၊ ပြန် resolve ဖြစ်နိုင်ပါတယ်)
  • Localhost မှာ အလုပ်လုပ်တာနဲ့ Production မှာ အလိုအလျောက်အလုပ်လုပ်မယ်လို့ မယူဆပါနှင့် — environment, network, database, security ကွာခြားချက်တွေ ရှိနိုင်ပါတယ်။

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

sendRequest function ကို ပြင်ပြီး path parameter အစား "/about.html" ကို hardcode ထည့်ပါ၊ ပြီးရင် resolveDNS ကို "learn.thutatech.com" domain အသစ်တစ်ခုနဲ့ ခေါ်ပြီး IP address value ကို ပြောင်းလိုက်ကာ output ဘယ်လို ပြောင်းလဲသွားလဲ ကြည့်ပါ။

You'll know it worked when: Simplified simulation (not a real network call): 1. DNS resolved thutatech.com -> 203.0.113.42 2. Connected to 203.0.113.42 over TCP 3. GET /index.html -> 200 OK