နားလည်ထားရမယ့် အချက်
Production app တိုင်းမှာ data အမျိုးအစား သုံးမျိုး ကွဲပြားစွာ ရှိပြီး၊ အားလုံးကို တစ်ပုံစံတည်း သိမ်းလိုက်တာက launch ပြီးနောက် app ပျက်စီးရတဲ့ အဖြစ်များဆုံး အကြောင်းရင်းတွေထဲက တစ်ခုပါ။
- Structured data (user, order, comment) ကတော့ database ထဲမှာ — transaction, index, consistent query ရရှိမယ်။
- File တွေ (image, video, PDF, report) ကတော့ object storage ထဲမှာ — binary blob ကြီးတွေအတွက် HTTP ကနေ serve ဖို့ ဒီဇိုင်းလုပ်ထားပါတယ်။
- Object storage ဟာ database မဟုတ်သလို၊ server ပေါ်က folder တစ်ခုလည်း မဟုတ်ပါဘူး။
Ephemeral disk က upload ဖိုင်တွေကို စားလိုက်တယ်
Production server ရဲ့ local disk ပေါ် သိမ်းထားတဲ့ file — upload avatar, generate လုပ်ထားတဲ့ PDF — ဟာ platform က redeploy လုပ်တာ၊ container restart လုပ်တာ၊ machine အသစ်ကို ရွှေ့တာ ဖြစ်တဲ့အခါ တိတ်တဆိတ် ပျောက်သွားနိုင်ပါတယ်။ Platform အများစုမှာ git push တိုင်းမှာ ဒါက auto ဖြစ်နေပါတယ်။
Production database connection ဟာ local တစ်ခုထက် stakes ပိုမြင့်ပါတယ် — credential အစစ်၊ customer data အစစ်၊ network rule၊ backup schedule အားလုံး အခုအရေးကြီးလာပါပြီ။
Upload code မရေးခင် သိမ်းမယ့် data က database record လား၊ object storage file လား၊ ပျောက်ရင်လည်း ကိစ္စမရှိတဲ့ data လား ဆုံးဖြတ်ထားပါ။ ဒါမှားရင် development ထဲမှာ ခဏတောင် မပေါ်တတ်ပါဘူး — production ထဲမှာ support ticket အနေနဲ့ ပေါ်လာလေ့ ရှိပါတယ်။
- Object Storage
- Binary file ကြီးတွေ (image, video, backup) ကို ဈေးသက်သက်နဲ့ သိမ်းပြီး HTTP ကနေ serve လုပ်ဖို့ ဆောက်ထားတဲ့ system, folder path မဟုတ်ဘဲ key နဲ့ index လုပ်ထား။
- Ephemeral Filesystem
- Container restart, redeploy, ဒါမှမဟုတ် machine အသစ်ကို ရွှေ့တဲ့အခါ ဖျက်ပစ်နိုင်တဲ့ local disk storage။
- Persistent Storage
- App ရဲ့ container ကိုယ်တိုင် အပြင်ဘက်မှာ ရှိပြီး restart/redeploy ကို survive တဲ့ storage, managed database ဒါမှမဟုတ် object storage bucket လိုမျိုး။
PRODUCTION DATA PATHS
---------------------
PRODUCTION DATA PATHS
----------------------
[ APP SERVER ]
| |
writes | | writes
v v
[DATABASE] [OBJECT STORAGE]
rows/tables files/images/videos
(structured) (blobs)
LOCAL DISK (container) MANAGED STORAGE
----------------------- -----------------------
EPHEMERAL PERSISTENT
wiped on redeploy/restart survives redeploy/restartလက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
Classifier ငယ်လေးတစ်ခုက ဆုံးဖြတ်ချက်ကို ရှင်းရှင်းလင်းလင်း ပြပါတယ် — data တစ်ခုပေးရင် ဘယ် destination သုံးခုထဲက ဘယ်ဟာနဲ့ သက်ဆိုင်လဲ ဆုံးဖြတ်ပေးပါတယ်။
| Data အမျိုးအစား | ဘယ်နေရာမှာ ရှိသင့်လဲ |
|---|---|
| image / video / document / backup | object storage |
| user-profile / order / comment | database |
| cache-value / session-token | ephemeral (ပျောက်လည်း ရ) |
မေးပါ — နောက် deploy မှာ ဒါပျောက်ရင် disaster လား၊ inconvenience လား၊ non-event လား။ ဒီအဖြေက ambiguity ကို almost always ဖြေရှင်းပေးပါတယ်။
Ephemeral disk က upload တွေကို စားလိုက်တယ်
Platform ရဲ့ local/ephemeral disk ပေါ် သိမ်းထားတဲ့ file တွေဟာ နောက် deploy မှာ ပျောက်နိုင်ပါတယ် — beginner တွေ ဖြစ်လေ့ရှိတဲ့ ဈေးကြီးတဲ့ အမှားတစ်ခုပါ။
အတူတူ စမ်းရေးကြည့်မယ်
function classifyStorage(type) {
const objectStorageTypes = ["image", "video", "document", "backup"];
const databaseTypes = ["user-profile", "order", "comment"];
const ephemeralTypes = ["cache-value", "session-token"];
if (objectStorageTypes.includes(type)) return "object-storage";
if (databaseTypes.includes(type)) return "database";
if (ephemeralTypes.includes(type)) return "ephemeral (ok to lose)";
return "unknown";
}
const items = [
{ type: "image", label: "user avatar upload" },
{ type: "user-profile", label: "username + email row" },
{ type: "cache-value", label: "rate-limit counter" },
{ type: "backup", label: "nightly database dump" },
];
for (const item of items) {
console.log(`${item.label.padEnd(28)} -> ${classifyStorage(item.type)}`);
}user avatar upload -> object-storage
username + email row -> database
rate-limit counter -> ephemeral (ok to lose)
nightly database dump -> object-storage
(output က locale နှစ်ခုစလုံးအတွက် တူညီပါတယ် — code output ဖြစ်လို့ပါ)၅ မိနစ် စမ်းကြည့်
classifyStorage ကို type နှစ်ခုထပ်ထည့်ပါ — 'export-csv' (user တစ်ခါ download လုပ်မယ့် generate လုပ်ထားတဲ့ report) နဲ့ 'auth-session' (login ဝင်ထားတဲ့ user ရဲ့ session state)။ ဘယ် bucket နဲ့ သက်ဆိုင်လဲ ဆုံးဖြတ်ပြီး comment ထဲမှာ အကြောင်းပြချက်ရေးပါ။
သတိလေးတစ်ချက်
User upload ဖိုင်တွေကို app server ရဲ့ local disk ပေါ် တိုက်ရိုက် သိမ်းထားပြီး redeploy တစ်ခါလုပ်မှ ပျောက်သွားတာ တွေ့ရတာ။
'Temporary' cache value ကို ပျောက်လည်း ရတယ်လို့ ယူဆထားပြီး၊ နောက်ပိုင်း ဒါပျောက်လို့ မရဘူးဆိုတဲ့ feature တွေကို တိတ်တဆိတ် ဆောက်ထားမိတာ။
MDN — HTTP and file uploads — Cloud & Deployment