Skip to main content
Request ေတြကိုကိုင္တြယ္တဲ႔အခါ Multithreading ကိုအသံုးျပဳထားေသာ web server ေတြဟာ CPU, Memory, I/O ေတြကိုစနစ္တက် အသံုးမျပဳ႔တဲ႔အတြက္ ေနွးေကြးျပီး users ေတြအမ်ားျကီး သံုးတာကို ထိထိေရာက္ေရာက္ မကိုင္တြယ္နိုင္ပါ။ ဥပမာ Microsoft IIS, Apache, Tomcat တို႔လို ေရွးဦးေပၚခဲ႔တဲ႔ web server မ်ိဳးေတြ။ ဒီျပသနာေတြကို server ေတြထက္တိုးျပီး ေျဖရွင္းေလ႔ရွိတယ္။
ေနာက္ပိုငး္မွာ server တခုထဲမွာပဲ hardware resources ေတြကိုကို ထိထိေရာက္ေရာက္သံုးနိုင္ဖို႔
single threaded asynchronous, event loop ကိုအသံုးျပဳထားတဲ႔ NGINX တို႔ Node.JS တို႔ေပၚလာတယ္။
အသံုးမမ်ားတဲ႔ web sites ေတြအတြက္ ဘယ္လို web server ေတြေပၚမွာhost လုပ္လုပ္ အဆင္ေျပေသာ္လည္း လူသံုးမ်ားျပီး ျမန္နွုန္းကို ဦးစားေပးတဲ႔ site ေတြအတြက္အဆင္မေျပဘူး။
IIS, Apache တို႔လို web server ေတြဟာ features ေတြအမ်ားျကီးေပးထားတဲ႔အတြက္ ကိုယ္အတြက္အသံုးမ၀င္တာေတြ အမ်ားျကီးပါနိုင္တယ္။ ကိုယ္လိုခ်င္သလို customize လုပ္ဖုိ႔ခက္တယ္။
Node.js ဟာ runtime environment ျဖစ္ျပီး ကိုယ္လိုခ်င္တဲ႔အပိုင္းကို ကိုင္တြက္လို႔ရတယ္။ ရွုိးရွင္းတဲ႔ html response အတြက္ view engine မသံုးပဲ ကိုယ္နညး္ကိုယ္ဟန္နဲ႔ response လုပ္လို႔ရတယ္။ တတ္နိုင္ရင္ asp.net razor view engine လိုမ်ိဳး ကိုယ္ပိုင္ render engine ဖန္တီးျပီးေတာင္သံုးလို႔ရတယ္။ CPU core တခုခ်င္စီအတြကိ process ေတြကို fork လုပ္ျပီး request ေတြကိုကိုင္တြက္လို႔ရပါတယ္။ Socket level နဲ႔ပိုျပီးနီးစပ္တယ္ဆိုရမွာေပါ႔။ Sever တခုကို Port တခုမွာ listen လုပ္ဖို႔ code ၄ ၅ ေျကာင္းေလာက္နဲ႔တင္ျပီးတယ္။ ေနာက္ပိုငး္မွာ web sites/API ေတြကိုလြယ္လြယ္ကူကူနဲ႔ ဖန္တီးနိုင္ဖို႔ Express လိုမ်ိဳး middleware ေတြေပၚလာတယ္။
Node.js နဲ႔အားမရဘူးဆိုရင္ ကိုယ္ပိုင္ http server တခုကို TCP/IP stack ေပၚမွာ ဖန္တီးနုိင္ပါတယ္။
asynchronous I/O ျဖစ္ဖို႔တြက္ Node.js ဟာ libuv သံုးျပီးဖန္တီးထားတာပါ။ စိတ္၀င္စားရင္ libuv ကုိသံုးျပီး idea အသစ္ေတြနဲ႔ ေနာက္ထက္ web server တခုကို ကိုယ္တိုင္ ဖန္တီးနိုင္ပါတယ္။ အေရးျကီးတာ အခုပဲရွိတယ္။ အဲ႔ဒါက ရွိျပီးသားေတြကို အခ်ိန္ကုန္ဖန္တီးျပီး reinvent the wheel မျဖစ္ဖို႔႔ပဲလိုပါတယ္။ :)

--NSA

Comments

Popular posts from this blog

Native app လုပ်ရတာကလည်း Android ဆိုတမျိုး iOS ဆိုတဖုံနဲ့ လုပ်ရတာ အချိန်ကုန်လက်ဝင်တယ်။ တခါတည်းနဲ့ ၂ ခုလုံးမှာသုံးလို့ရအောင်လုပ်မယ်။ Webview သုံးတဲ့ Cordova တို့ Ionic တို့ထွက်လာတယ်။ Facebook: WebView ကြီးနဲ့ မမိုက်ပါဘူးကွာ။ ပိုပြီး native ဆန်သွားအောင် React ကိုအခြေခံပြီး Reactive native လုပ်လိုက်တယ်။ တခါပဲရေး Android ရော iOS ရော ၂ ခုထွက်။ Google: မင်းတို့ဘယ်လိုပဲ native လုပ်လုပ် အစစ်မဟုတ်ပါဘူးကွာ။ native နဲ့ပိုပြီး နီးစပ်အောင်လုပ်ပြမယ်။ React စတိုင်ကို အခြေခံပြီး Flutter ထွက်လာတယ်။ Dart language သုံးတယ်။ လေ့လာရတာလွယ်ပါတယ်။ Apple: လွယ်လွယ်ကူကူလုပ်လို့ရအောင် ငါလည်းဖန်တီးတက်ပါတယ်။ ဒါပေမဲ့ Apple ရဲ့ထုံးစံအတိုင်း cross platform မလုပ်ဘူးလေ။ iOS အတွက်ပဲ declarative ပုံစံနဲ့ SwiftUI ထွက်လာတယ်။ React, Flutter ပုံစံအတိုင်းပါပဲ။ Google: မင်းတို့မှ native သီးသန့်အတွက် လွယ်လွယ်ကူကူ App ဖန်တီးလို့ရတဲ့ ပုံစံမျိုး လုပ်တက်တာမဟုတ်ပါဘူး။ ငါလည်းလုပ်တတ်တယ်ဆိုပြီး Jetpack compose ထွတ်လာပြန်တယ်။ Microsoft: IE သိပ်ခါပြန်ဆယ်ဖို့ Visual Studio ...

ကွန်ပြူတာ ပရိုဂရမ်းမင်း အကြောင်း တစေ့တစောင်း

ဤဆောင်းပါးသည် ကွန်ပြူတာကိုစိတ်ဝင်စားသူ လူတိုင်းအတွက်ရည်ရွယ်ပါသည်။ ကွန်ပြုတာဖြင့်အသက်မွေးကြောင်းမပြုသော်လည်း ဒစ်ဂျစ်တယ်ခေတ်တွင် လူတိုင်းနီးပါး ကွန်ပြုတာ၊ မိုဘိုင်းဖုန်းဖြင့်ရင်းနှီးနေကြပြီ ဖြစ်သည်။ အင်တာနက်ဆိုတာသုံးဖူးနေကြပြီ။ ထို့ကြောင့် အားလုံးအတွက် ဗဟုသုတရစေလို၍ ရေသားလိုက်သည်။ ကွန်ပြူတာအခြေခံမရှိသူ အားလုံးအတွက်ပါ ရည်ရွယ်သဖြင့် သဘောတရားနဲ့ အလုပ်လုပ်ပုံအကြာင်းကို ပိုအလေးထား ရှင်းပြထားပါသည်။ ပရိုဂရမ်းမင်း ဆိုတာဘာလဲ လူတယောက်၏ ခန္ဓာကိုယ် အစိတ်အပိုင်းကို လေ့လာကြည့်ပါ။ ဦးနှောက့်၊ မှတ်ညဏ်၊ နား၊ မျက်လုံး၊ ပါစပ်၊ မျက်နာ၊ ခြေ၊ လက် စသဖြင့်ရှိသည်။ ဒီလိုအစိတ်အပိုင်းတွေကို ပေါင်းစည်းကာ "လူ" ဟူ၍ဖြစ်ပေါ်လာခြင်းဖြစ်သည်။ ကွန်ပြုတာဆိုသည်မှာလည်း ထိုးနည်းတူဖြစ်သည်။ အီလက်ထရောနစ်  အစိတ်အပိုင်းတွေ ပေါင်းစည်းကာ ကွန်ပြုတာ ဖြစ်ပေါ်လာသည်။ ဦးနှောက့် နှင့်တူသော CPU (Central Processing Unit)၊ မှတ်ညဏ်နှင့်တူသော မန်မိုရီ၊ နား နှင့်တူသော ဆားကစ်လမ်းကြောင်း၊ ကေဘယ်တွေ ရှိသည်။ (ဥပမာ ကီးဘုတ်မှ 'A' ကိုနှိပ်တဲ့အခါ ကီးဘုတ်ကေဘယ်လ်မှ တဆင့်ခြင်းဖြတ်ကျော်ကာ CPU သို့ရောက်သည်ဟု အလွယ်မှတ်ပါ )။ မျက်လုံးနှင့်တ...

Android Photo Gallery

https://play.google.com/store/apps/details?id=com.nsoeaung.photogallery Wow photo gallery is the best and simple android photo gallery. The best photo gallery for viewing and managing albums, photos, videos and GIF. Wow photo gallery only offer features that you really need. It offers very simple and clean UI design. You will feel silky smooth and best user experience. Organize your photos and media with Wow photo gallery application. Here are main features: Filter albums by media types (photos, videos and GIF) and storage types (internal storage and SD card). Quick search bar to find what you looking for. Sort items by date, size or name. Delete/Rename or create new album at internal storage or SD card. Favourite drawer to keep your favourite photos and other media. Filter media by media types or storage types. Group media by Date, Month or Year. Delete/Copy/Move/Rename media files at internal storage or SD card. List view and Grid view with personalize grid size. V...