Multi-arch Images والـ Native Modules: اشتغلت عندي
الـ image اتبنت على Mac M واشتغلت، وعلى الـ server وقعت بـ exec format error. و sharp بيقع بـ ERR_DLOPEN_FAILED لأن node_modules اتنسخت من الـ laptop، أو اتعملت على glibc واتنقلت لـ alpine. بنفهم الـ platforms و amd64 و arm64، والـ manifest lists، و buildx و QEMU، و BUILDPLATFORM و TARGETPLATFORM، والـ native addons والـ prebuilds، و glibc مقابل musl. والتحدي: platforms.js بيقرا الـ ELF header بجد ويطلّع المشاكل قصاد أربعتاشر حالة.
نص شرح المعلم والكود الذي كتبه ونتيجة تشغيله، بنفس ترتيب الدرس.
أهلًا بيك. الـ image مش JavaScript بس. جُوّه فيها الـ node binary نفسه، والـ libraries بتاعة الـ OS، وأحيانًا native modules زي sharp و bcrypt، ودول code متعمل compile لـ CPU معيّن. الـ CPUs اللي هتقابلها: amd64، يعني x86 العادي في أغلب الـ servers. و arm64: الـ Macs الجديدة، و AWS Graviton، و Raspberry Pi الجديد. وده أرخص في الـ cloud بنسبة محترمة، فناس كتير بتنقل له. فلو عملت build على Mac M، الـ image هتبقى arm64. تشغّلها على server amd64: exec format error. والعكس. بص على Dockerfile dot naive. المشاكل: platform linux slash amd64 مكتوبة بإيدك. على Mac M الـ build والتشغيل هيبقوا بـ emulation، أبطأ بكتير، وأحيانًا بيقع في حاجات غريبة. والأخطر: COPY node_modules من الـ laptop. node_modules مش JavaScript بس. خد sharp: فيها file بينتهي بـ dot node، وده binary متعمل لـ macOS و arm64. جُوّه container Linux و amd64، أول require ليها: ERR_DLOPEN_FAILED، invalid ELF header. وحتى لو الـ laptop Linux، الـ glibc version ممكن تختلف. القاعدة اللي من درس الـ layers: node_modules في الـ dockerignore، و npm ci جُوّه الـ build. بس حتى ده فيه فخ، هنشوفه.
الـ manifest list: tag واحد زي node اتنين وعشرين مش image واحدة. ده list: لكل platform، image بـ digest مختلف. docker pull بيشوف الـ machine بتاعتك إيه، ويجيب النسخة بتاعتها. فـ node اتنين وعشرين على Mac M بتجيب arm64، وعلى الـ server بتجيب amd64، من غير ما تعمل حاجة. لو مفيش نسخة لـ platform بتاعتك: no matching manifest. والـ platform فيها os و arch وأحيانًا variant، زي arm slash v7. و arm64 و arm64 slash v8 نفس الحاجة. buildx بيبني لأكتر من platform مرة واحدة، ويعمل push لـ manifest list واحدة بنفس الـ tag. والـ platform اللي مش زي الـ machine بتتبني بـ QEMU، emulator. شغّال، بس npm ci ممكن ياخد عشر أضعاف الوقت.
الـ native modules: أغلب الـ packages JavaScript بس، وتشتغل في أي حتة. بس فيه packages فيها C أو C plus plus أو Rust، زي sharp للصور، و bcrypt، و better-sqlite3. دي فيها file بينتهي بـ dot node، و Node بيعمله load بـ dlopen. علشان npm ما يعملش compile على جهازك، الـ packages دي بتنزّل prebuilds: binary جاهز لكل مجموعة: الـ OS، و process arch، والـ libc. زي linux x64 gnu، أو linux arm64 musl. npm ci بيختار الـ prebuild على حسب الـ machine اللي شغّال عليها وقتها. ودي الحكاية كلها. ولو مفيش prebuild لمجموعتك، npm بيحاول يعمل compile بـ node-gyp، ومحتاج python3 و make و g plus plus. والـ slim image مفيهاش الحاجات دي، فالـ build يقع. و glibc مقابل musl: Debian و Ubuntu والـ slim بيستخدموا glibc. و alpine بيستخدم musl. binary متعمل لواحدة مش هيشتغل على التانية.
والفخ: Dockerfile dot cross. BUILDPLATFORM ده متغير من BuildKit: الـ machine اللي بتعمل build، مش اللي هتشغّل. و TARGETPLATFORM: الـ platform اللي الـ stage بتتبني ليها. platform BUILDPLATFORM على stage معناها: شغّلها native على الـ build machine من غير QEMU. سريع أوي. وده صح لأي حاجة الـ output بتاعها مش معتمد على الـ CPU: TypeScript compile، أو bundling، أو Go cross compile. بس npm ci هنا بيختار prebuilds للـ build machine. لو الـ CI amd64 والـ target arm64، الـ node_modules فيها x64. والـ image الـ arm64 هتقع بـ ERR_DLOPEN_FAILED. وكمان الـ deps stage على node اتنين وعشرين، يعني glibc، والـ final على alpine، يعني musl. فحتى على نفس الـ CPU، sharp هتقع. ده الـ Dockerfile الجديد. stage build على BUILDPLATFORM: npm ci للـ dev dependencies، و npm run build للـ TypeScript. الـ output هو dist، JavaScript عادي، فمش فارق اتعمل على أنهي CPU. stage deps من غير platform، يعني على الـ target نفسها: npm ci omit dev. هنا sharp بياخد الـ prebuild الصح لكل platform. والـ cache mount ليه id فيه TARGETPLATFORM، علشان كل platform ليها cache لوحدها. والـ final بياخد node_modules من deps، و dist من build. ونفس الـ base، slim، فنفس الـ libc. و buildx dot sh: QEMU، و builder، و build للاتنين مع push، و imagetools inspect تشوف الـ digests، و docker run بـ platform تجرّب. وآخر سطر: أسرع حل في الـ CI إنك تستخدم runner arm64 حقيقي بدل QEMU، وتجمع الاتنين في manifest واحدة.
lab dot js بيبص على الـ machine اللي شغّال عليها فعلًا: process arch والـ libc، وبيقرا أول bytes من الـ node binary نفسه. وبعدين docker pull هيجيب إيه لكل machine، والـ native modules في أربع حالات، والـ lint على التلات Dockerfiles. التحدي: اكتب platforms dot js. التفاصيل كلها في الكومنت، و test dot js فيه أربعتاشر حالة.
platforms.js: parsePlatform بالأسامي البديلة والـ variants، و platformString و nodeArch و libcOf و prebuildKey، و binaryInfo بيقرا ELF و Mach-O و PE، و selectManifest بالـ fallback والـ emulation، و checkNative، و lintDockerfile بـ PLATFORM-HARDCODED و COPY-NODE-MODULES و BUILDPLATFORM-NATIVE و LIBC-MISMATCH.
الحل. parsePlatform: table للأسامي البديلة، لأن uname بيقول x86_64 و aarch64، و Docker بيقول amd64 و arm64، و Node بيقول x64 و arm64. binaryInfo: كل executable على Linux بيبدأ بـ ELF، وعند offset تمنتاشر رقم الـ machine. ده بالضبط اللي dlopen بيبص عليه قبل ما يقول invalid ELF header أو wrong ELF class. selectManifest: exact، وبعدين نفس الـ arch، وبعدين emulation لو مسموح. والـ lint: بنتبع node_modules رايحة من أنهي stage لأنهي stage، ونقارن الـ platform والـ libc. نشغّل lab dot js.
// platforms.js: الـ platforms والـ manifest lists، والـ native binaries بتاعة Node، و lint للـ multi-arch Dockerfile
const ARCH = { x86_64: "amd64", x64: "amd64", amd64: "amd64", aarch64: "arm64", arm64: "arm64", armv7l: "arm", armhf: "arm", arm: "arm" };
export function parsePlatform(s) {
const [os = "linux", rawArch, rawVariant] = String(s).toLowerCase().split("/");
const arch = ARCH[rawArch];
if (!arch) throw new Error(`arch مش معروفة: ${rawArch}`);
let variant = rawVariant ?? null;
if (rawArch === "armv7l" || rawArch === "armhf") variant ??= "v7";
if (arch === "arm64" && variant === "v8") variant = null; // arm64 و arm64/v8 هما نفس الحاجة
return { os, arch, variant };
}
export const platformString = ({ os, arch, variant }) => [os, arch, variant].filter(Boolean).join("/");
export const nodeArch = (arch) => ({ amd64: "x64", arm64: "arm64", arm: "arm" })[arch];
export function libcOf(image) {
const [name, tag = "latest"] = String(image).split("@")[0].split(":");
if (name === "scratch") return null;
if (/alpine/.test(tag) || /alpine/.test(name)) return "musl";
return "glibc"; // node:22 و node:22-slim و bookworm و distroless كلهم glibc
}
export function prebuildKey(platform, libc) {
const p = typeof platform === "string" ? parsePlatform(platform) : platform;
const base = `${p.os}-${nodeArch(p.arch)}`;
if (p.os !== "linux") return base;
return `${base}-${libc === "musl" ? "musl" : "gnu"}`;
}
const MACHINES = { 0x3e: "amd64", 0xb7: "arm64", 0x28: "arm", 0x03: "386" };
export function binaryInfo(buf) {
if (buf.length >= 4 && buf[0] === 0x7f && buf.toString("latin1", 1, 4) === "ELF") {
const le = buf[5] === 1;
const m = le ? buf.readUInt16LE(18) : buf.readUInt16BE(18);
return { format: "elf", bits: buf[4] === 2 ? 64 : 32, arch: MACHINES[m] ?? `unknown-${m}` };
}
const magic = buf.length >= 4 ? buf.readUInt32BE(0) : 0;
if ([0xcffaedfe, 0xcefaedfe, 0xfeedfacf, 0xfeedface].includes(magic)) return { format: "mach-o", bits: magic === 0xcffaedfe || magic === 0xfeedfacf ? 64 : 32, arch: null };
if (buf.length >= 2 && buf.toString("latin1", 0, 2) === "MZ") return { format: "pe", bits: null, arch: null };
return { format: "unknown", bits: null, arch: null };
}
export function selectManifest(entries, host, { emulation = false } = {}) {
const h = typeof host === "string" ? parsePlatform(host) : host;
const list = entries.map((e) => ({ ...e, p: parsePlatform(e.platform) }));
const exact = list.find((e) => e.p.os === h.os && e.p.arch === h.arch && (e.p.variant ?? null) === (h.variant ?? null))
?? list.find((e) => e.p.os === h.os && e.p.arch === h.arch);
if (exact) return { platform: platformString(exact.p), digest: exact.digest, emulated: false };
const other = list.find((e) => e.p.os === h.os);
if (emulation && other) return { platform: platformString(other.p), digest: other.digest, emulated: true };
throw Object.assign(new Error(`no matching manifest for ${platformString(h)} in the
…المخرجات
$ node lab.js
=== الـ machine دي ===
process.platform linux | process.arch x64 | libc glibc
الـ node binary نفسه: {"format":"elf","bits":64,"arch":"amd64"}
الـ prebuild اللي npm هيدوّر عليه هنا: linux-x64-gnu
و binary اتعمل على Mac: {"format":"mach-o","bits":64,"arch":null}
=== docker pull: أنهي manifest؟ ===
linux/amd64 server في الـ cloud ← linux/amd64 sha256:aa11
linux/aarch64 Graviton أو Mac M ← linux/arm64 sha256:bb22
linux/arm/v7 Raspberry Pi قديم ← no matching manifest for linux/arm/v7 in the manifest list entries
linux/arm/v7 ونفس الـ Pi بـ QEMU ← linux/amd64 sha256:aa11 (emulated، أبطأ بكتير)
=== الـ native modules ===
npm install على Mac M، و COPY node_modules:
WRONG-BINARY sharp اتعمل لـ darwin-arm64 وشغّال على linux-x64-gnu: ERR_DLOPEN_FAILED
WRONG-BINARY bcrypt اتعمل لـ darwin-arm64 وشغّال على linux-x64-gnu: ERR_DLOPEN_FAILED
npm ci على BUILDPLATFORM amd64، والـ image arm64:
WRONG-BINARY sharp اتعمل لـ linux-x64-gnu وشغّال على linux-arm64-gnu: ERR_DLOPEN_FAILED
WRONG-BINARY bcrypt اتعمل لـ linux-x64-gnu وشغّال على linux-arm64-gnu: ERR_DLOPEN_FAILED
npm ci على glibc، والـ image alpine:
…الـ machine دي: الـ arch والـ libc اللي طلعوا، والـ node binary نفسه ELF، والـ arch بتاعته من الـ header مطابقة لـ process arch. والـ prebuild اللي npm هيدوّر عليه هنا. والـ binary بتاع Mac مش ELF خالص، mach-o. docker pull: الـ amd64 والـ aarch64 لقوا نسختهم، و aarch64 اتحوّلت لـ arm64. والـ Pi القديم arm v7 ملوش نسخة، إلا بالـ emulation. الـ native modules: من الـ Mac، ومن BUILDPLATFORM، ومن glibc لـ alpine: التلاتة WRONG-BINARY. وعلى الـ target نفسها: sharp تمام، و bcrypt ملوش prebuild لـ arm64، فمحتاج build tools. والـ lint مسك اتنين في كل Dockerfile قديم، والجديد نضيف. ونشغّل test dot js.
المخرجات
$ node test.js ✅ parsePlatform: الأسامي البديلة و lowercase ✅ parsePlatform: arm64/v8 هو arm64، و armv7l ← arm/v7 ✅ platformString و nodeArch ✅ libcOf: alpine ← musl، و slim و distroless ← glibc، و scratch ✅ prebuildKey: linux بالـ libc، و darwin من غيرها ✅ binaryInfo: ELF بالـ machine (x86-64 و aarch64 و arm و big endian) ✅ binaryInfo: Mach-O و PE و غيره، والـ node الحقيقي ✅ selectManifest: exact، و arm64 = arm64/v8، والـ variant ✅ selectManifest: مفيش ← NO_MATCH، و emulation ← أول واحد بنفس الـ os ✅ checkNative: WRONG-BINARY و OK و BUILD-FROM-SOURCE ✅ lint: PLATFORM-HARDCODED بس للقيم الثابتة ✅ lint: COPY-NODE-MODULES من الـ context بس، مش من stage ✅ lint: BUILDPLATFORM-NATIVE و LIBC-MISMATCH، ومن غير native لأ، ومن غير npm ci لأ ✅ الـ Dockerfiles: naive و cross فيهم اتنين اتنين، والجديد نضيف 14/14
كله نجح. دلوقتي عندنا image صح، لأي platform. بس بتوصل الـ production إزاي؟ docker build على الـ server بإيدك؟ الدرس الجاي: الـ CI و CD: pipeline بيعمل test و build و push بالـ digest، و deploy، و rollback في دقيقة، و blue green، و canary.
FROM --platform=linux/amd64 node:22-slim
WORKDIR /app
COPY package.json package-lock.json ./
# node_modules جاهزة من الـ laptop، علشان الـ build يبقى أسرع
COPY node_modules ./node_modules
COPY . .
CMD ["node", "server.js"]# syntax=docker/dockerfile:1
# npm ci على الـ build machine من غير emulation، وبعدين ننقل node_modules لـ alpine صغيرة
FROM --platform=$BUILDPLATFORM node:22 AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
FROM node:22-alpine
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
CMD ["node", "server.js"]# syntax=docker/dockerfile:1
# الـ TypeScript compile بيطلّع JS عادي، فينفع على الـ build machine بسرعة
FROM --platform=$BUILDPLATFORM node:22-slim AS build
WORKDIR /app
COPY package*.json ./
RUN --mount=type=cache,target=/root/.npm npm ci
COPY . .
RUN npm run build
# الـ production dependencies على الـ target platform نفسها، علشان sharp و bcrypt ياخدوا الـ binary الصح
FROM node:22-slim AS deps
WORKDIR /app
COPY package*.json ./
RUN --mount=type=cache,target=/root/.npm,id=npm-$TARGETPLATFORM npm ci --omit=dev
FROM node:22-slim
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist
USER node
CMD ["node", "dist/server.js"]# buildx.sh: image واحدة لأكتر من platform
# مرة واحدة على الـ machine: QEMU للـ emulation، و builder بيدعم multi-platform
docker run --privileged --rm tonistiigi/binfmt --install all
docker buildx create --name multi --use
# build للاتنين و push لـ manifest list واحدة بنفس الـ tag
docker buildx build --platform linux/amd64,linux/arm64 -t registry.example.com/shop-api:1.6.0 --push .
# شوف الـ manifest list: digest لكل platform
docker buildx imagetools inspect registry.example.com/shop-api:1.6.0
# جرّب الـ arm64 على machine تانية (بـ QEMU، أبطأ بكتير)
docker run --rm --platform linux/arm64 registry.example.com/shop-api:1.6.0 node -p "process.arch"
# جُوّه الـ Dockerfile، BuildKit بيدّيك:
# BUILDPLATFORM ← الـ machine اللي بتعمل build (linux/amd64 في الـ CI مثلًا)
# TARGETPLATFORM ← الـ platform اللي الـ stage بتتبني ليها (linux/arm64)
# TARGETOS و TARGETARCH و TARGETVARIANT
# أسرع حل للـ CI: runner لكل arch (arm64 runner + amd64 runner) وبعدين imagetools create يجمعهم// lab.js: إحنا شغّالين على إيه فعلًا، وأنهي image هتتشد، والـ native modules هتشتغل ولا لأ
import { readFileSync } from "node:fs";
import { binaryInfo, prebuildKey, selectManifest, checkNative, lintDockerfile, parsePlatform, platformString } from "./platforms.js";
const head = readFileSync(process.execPath).subarray(0, 64);
const libc = process.report.getReport().header.glibcVersionRuntime ? "glibc" : "musl";
console.log("=== الـ machine دي ===");
console.log(` process.platform ${process.platform} | process.arch ${process.arch} | libc ${libc}`);
console.log(` الـ node binary نفسه: ${JSON.stringify(binaryInfo(head))}`);
console.log(` الـ prebuild اللي npm هيدوّر عليه هنا: ${prebuildKey(`${process.platform}/${process.arch}`, libc)}`);
console.log(` و binary اتعمل على Mac: ${JSON.stringify(binaryInfo(Buffer.from([0xcf, 0xfa, 0xed, 0xfe, 0x0c, 0, 0, 1])))}`);
console.log("\n=== docker pull: أنهي manifest؟ ===");
const list = [{ platform: "linux/amd64", digest: "sha256:aa11" }, { platform: "linux/arm64/v8", digest: "sha256:bb22" }];
for (const [host, opts, what] of [["linux/amd64", {}, "server في الـ cloud"], ["linux/aarch64", {}, "Graviton أو Mac M"], ["linux/arm/v7", {}, "Raspberry Pi قديم"], ["linux/arm/v7", { emulation: true }, "ونفس الـ Pi بـ QEMU"]]) {
try { const r = selectManifest(list, host, opts); console.log(` ${host.padEnd(14)} ${what.padEnd(20)} ← ${r.platform} ${r.digest}${r.emulated ? " (emulated، أبطأ بكتير)" : ""}`); }
catch (e) { console.log(` ${host.padEnd(14)} ${what.padEnd(20)} ← ${e.message}`); }
}
console.log("\n=== الـ native modules ===");
const native = [
{ name: "sharp", prebuilds: ["darwin-arm64", "linux-x64-gnu", "linux-arm64-gnu", "linux-x64-musl", "linux-arm64-musl"] },
{ name: "bcrypt", prebuilds: ["linux-x64-gnu", "darwin-arm64"] },
];
for (const [what, installedOn, runsOn] of [
["npm install على Mac M، و COPY node_modules", "darwin-arm64", prebuildKey("linux/amd64", "glibc")],
["npm ci على BUILDPLATFORM amd64، والـ image arm64", "linux-x64-gnu", prebuildKey("linux/arm64", "glibc")],
["npm ci على glibc، والـ image alpine", "linux-x64-gnu", prebuildKey("linux/amd64", "musl")],
["npm ci على الـ target arm64 نفسها", "linux-arm64-gnu", prebuildKey("linux/arm64", "glibc")],
]) {
console.log(` ${what}:`);
for (const r of checkNative(native, { installedOn, runsOn })) console.log(` ${r.status.padEnd(17)} ${r.msg}`);
}
console.log("\n=== lint ===");
for (const file of ["Dockerfile.naive", "Dockerfile.cross", "Dockerfile"]) {
const found = lintDockerfile(readFileSync(file, "utf8"), { native: ["sharp", "bcrypt"] });
console.log(` ${file}: ${found.length ? "" : "نضيف"}`);
for (const f of found) console.log(` ${f.severity} ${f.rule} (stage ${f.stage}): ${f.msg}`);
}
console.log(`\n platformString(parsePlatform("Linux/x86_64")) ← ${platformString(parsePlatform("Linux/x86_64"))}`);03 / دروس المسار (122)
- 01أهلًا بيك: يعني إيه backend، والكورس ده ماشي إزاي
- 02الملفات والفولدرات والـ terminal: تتحرك على جهازك زي المبرمجين
- 03Node وأول برنامج: تشغّل وتقرا رسالة الخطأ
- 04القيم والمتغيرات والأنواع: const و let و typeof
- 05القرارات والتكرار: if و === والـ truthy والـ loops
- 06الـ functions: parameters و return والـ arrow functions والـ scope
- 07الـ objects والـ arrays: destructuring و spread و map و filter و reduce
- 08JSON والنصوص والتواريخ: اللغة اللي الـ backend بيتكلم بيها
- 09الـ callbacks والـ closures وأول لمسة async: setTimeout
- 10الـ classes والـ errors: throw و try/catch و stack trace
- 11git: تحفَظ كل خطوة وترجعلها، وما تسرّبش أسرارك
- 12ESM و CommonJS و package exports: Node بيلاقي الـ modules إزاي
- 13الـ Promises و async/await: sequential و parallel والأخطاء والإلغاء
- 14الـ event loop والـ microtasks: Node بيعمل كل حاجة بـ thread واحد إزاي
- 15الـ Streams والـ Backpressure: ملفات أكبر من الـ memory
- 16الـ File System والـ paths: قراية وكتابة صح، ومن غير path traversal
- 17الـ Buffers والبيانات الـ binary: الـ bytes من جُوّه
- 18Crypto APIs والأسرار: random و hash و HMAC و AES-GCM
- 19الـ Worker Threads: شغل CPU تقيل من غير ما توقف الـ server
- 20الـ Errors على مستوى الـ process: operational و programmer و crash-only
- 21الـ Node test runner والـ debugging: tests من غير مكتبات
- 22HTTP من جُوّه: الـ methods والـ status codes والـ headers
- 23Express والـ Routing: الـ params والـ query والترتيب والـ Router
- 24Express 5: إيه اللي اتغيّر، وإزاي تنقل مشروع قديم
- 25الـ Middleware ودورة حياة الـ request جُوّه Express
- 26Validation للمدخلات بـ Zod: ما تصدّقش أي حاجة جاية من برة
- 27تصنيف الأخطاء و Problem Details: شكل واحد لكل الـ errors
- 28الـ CORS والـ Cookies: المتصفح بيحمي المستخدم إزاي
- 29رفع الملفات وحدود الحجم: multer من غير ثغرات
- 30الـ Realtime: Server-Sent Events و WebSockets
- 31OpenAPI والـ API Versioning: عقد مكتوب، وتغيير من غير ما تكسر حد
- 32PostgreSQL: الـ DDL وأنواع البيانات الصح لكل عمود
- 33الـ Constraints: PK و FK و UNIQUE و CHECK — الـ database بتحمي نفسها
- 34الـ Normalization والـ ERD: تقسّم البيانات صح من أول يوم
- 35الـ JOINs والتجميع: INNER و LEFT و GROUP BY و HAVING و window functions
- 36JSONB في PostgreSQL: إمتى تستخدمه، وإزاي تسأله وتعمله index
- 37الـ Indexes من جُوّه: B-tree و GIN و BRIN
- 38Partial و Covering indexes: indexes أصغر وأسرع
- 39الـ Pagination بالـ Keyset: ليه OFFSET بيبطّأ وبيكرر
- 40Full Text Search في Postgres: بحث بالكلمات، بالعربي والإنجليزي
- 41EXPLAIN ANALYZE والـ Planner: اقرا الـ plan وصلّح الـ query
- 42الـ Transactions بـ node-postgres: كله أو ولا حاجة
- 43الـ MVCC ومستويات الـ Isolation: transactions كتير في نفس الوقت
- 44الـ Locks والـ Deadlocks: مين مستني مين
- 45SKIP LOCKED و Job Leasing: Postgres كـ job queue
- 46Row Level Security والـ Multi-tenancy: كل عميل يشوف بياناته بس
- 47Migrations من غير downtime: expand و backfill و contract
- 48الـ Replication والـ Read Replicas: نسخ حية من الـ database
- 49الـ Connection Pooling و PgBouncer: connections أقل، requests أكتر
- 50الـ Partitioning والـ VACUUM والمراقبة: Postgres على المدى الطويل
- 51Redis وأنواع البيانات: strings و hashes و lists و sets و sorted sets
- 52Cache-aside والـ TTL: Redis قدام الـ database
- 53الـ Cache invalidation والـ Stampede: لما الـ key الشهير يموت
- 54Lua والـ Atomicity في Redis: كام أمر كأنهم أمر واحد
- 55الـ Rate Limiting في Redis: fixed window و sliding window و token bucket
- 56الـ Sessions في Redis: تسجيل دخول تقدر تلغيه في أي وقت
- 57Redis Streams والـ Consumer Groups: log بيتوزع على workers
- 58Pub/Sub و BullMQ: إشارات بين الـ instances، وطوابير شغل محترمة
- 59Redis لما يقع: الـ persistence (RDB و AOF) والـ replication
- 60Redis في الإنتاج: الـ ACLs والـ Cluster والمراقبة
- 61تخزين الـ Passwords بـ Argon2id: صح من أول مرة
- 62Session Fixation والـ Rotation: id جديد مع كل صلاحية جديدة
- 63الـ Cookie Flags والـ CSRF: المتصفح بيبعت الـ cookie، فلازم تتأكد مين اللي طلب
- 64الـ XSS والـ Content Security Policy: ما تخليش النص يتحوّل لـ code
- 65الـ OAuth و OpenID Connect و PKCE: login بـ Google من غير ما تشوف الـ password
- 66التأكد من الـ JWT صح: التوقيع والـ claims والـ scopes
- 67الـ BOLA و BFLA: الـ token السليم مش معناه إن الطلب مسموح
- 68الـ RBAC و ABAC والملكية: policy واحدة بدل ifs متفرقة
- 69الـ MFA والـ recovery: التاني factor اللي بجد
- 70الـ Passkeys و WebAuthn: login من غير password وضد الـ phishing
- 71الـ Threat Modeling بـ STRIDE: فكّر زي المهاجم قبل ما تكتب code
- 72الـ SQL Injection والـ Parameterization: الـ data ما تبقاش code
- 73الـ SSRF والـ Egress: ما تخليش الـ server بتاعك يزور الشبكة الداخلية
- 74الـ Security Headers والـ TLS: كل response يقول للـ browser يحمي المستخدم إزاي
- 75توقيع الـ Webhooks والـ Replay: الـ webhook ده جاي فعلًا من Stripe؟
- 76تغيير الأسرار والـ HMAC: إزاي تغيّر مفتاح من غير ما كل حاجة تقع
- 77سلسلة التوريد والـ SBOM: إنت واثق في ألف package ما تعرفهمش؟
- 78الـ Audit والـ Privacy Logs: سجّل مين عمل إيه، من غير ما تسجّل الأسرار
- 79اختبار الأمان و OWASP ASVS: الأمن جُوّه الـ CI، مش audit آخر السنة
- 80الـ Prototype Pollution والـ Resource DoS: request واحد يخلّي الكل admin أو يوقّع الـ server
- 81الـ SLI والـ SLO والـ Error Budget: إمتى تصحّي الـ on-call وإمتى تسيبه نايم
- 82الـ Event Loop Delay والـ ELU: لما Node نفسه يتخنق
- 83الـ Worker Threads والـ CPU Profiling: الشغل التقيل بره الـ event loop، والوقت راح فين
- 84الـ Memory والـ GC والـ Leaks: الـ process اللي بيكبر لحد ما يقع
- 85الـ N+1 Queries والـ DataLoader: صفحة واحدة بمِيّتين query
- 86الـ HTTP Caching والـ Compression: أسرع request هو اللي ما بيوصلش
- 87الـ Load Testing والـ Soak Testing: الـ server بيستحمل قد إيه بجد
- 88الـ Concurrency Limits والـ Bulkheads: dependency بطيئة ما توقعش الـ app كله
- 89الـ Timeouts والـ Retries والـ Circuit Breakers: إزاي تتعامل مع dependency بطيئة أو واقعة
- 90OpenTelemetry والـ Distributed Tracing: الـ request راح فين وضاع وقته فين
- 91Docker Layers والـ Build Context: ليه الـ build بياخد دقيقة وفيه الـ .env بتاعك
- 92Multi-stage Builds و Non-root: image صغيرة ومن غير root
- 93Docker Compose والـ Networks: الـ services بتلاقي بعض إزاي
- 94Docker Volumes: الـ data بتتحفَظ فين
- 95Healthcheck و Restart و Resource Limits: running مش معناها شغّال
- 96BuildKit والـ Build Secrets: الـ token ما يدخلش الـ image
- 97Reverse Proxy و TLS: اللي واقف قدام الـ app
- 98Multi-arch Images والـ Native Modules: اشتغلت عنديانت هنا
- 99CI/CD و Rollback و Canary: الـ deploy يبقى ممل
- 100Kubernetes من الأول: Pods و Deployments و Services و Probes
- 101Modular Monolith و DDD: حدود واضحة من غير network
- 102Transactional Outbox و Inbox: الـ event ما يضيعش وما يتنفذش مرتين
- 103Sagas: عملية واحدة على تلات services من غير transaction واحدة
- 104CQRS و Event Sourcing: الـ events هي الحقيقة
- 105الـ Queues والـ Brokers: BullMQ و RabbitMQ و Kafka و SQS
- 106Realtime على أكتر من instance: Redis pub/sub و presence و resume
- 107الـ Object Storage والـ Media: presigned URLs و uploads مباشرة
- 108التكامل مع الـ Email والـ Search: retries و webhooks و indexes
- 109GraphQL و gRPC في الإنتاج: contracts و DataLoader و limits و deadlines
- 110Kafka على أكتر من zone و region: الـ replication والـ ISR والـ acks والـ MirrorMaker والـ failover
- 111TypeScript و runtime boundaries: الـ types بتختفي، والـ schemas لأ
- 112ORM ولا SQL: query builders و repositories و migrations و transactions
- 113الـ Serverless من جُوّه: cold starts و freeze و timeouts و connections
- 114الـ Testing Pyramid: unit و integration و e2e على Postgres حقيقية
- 115Contract Testing و Property-Based Testing بـ fast-check
- 116الـ Payments: idempotency و webhooks و refunds و reconciliation
- 117الـ Timezones والـ Internationalization: UTC و DST والـ locales والـ plurals والفلوس
- 118الـ Privacy والـ Data Retention: consent و export و erasure و crypto shredding
- 119الـ ADRs والـ Feature Flags: القرارات المكتوبة والـ rollout من غير deploy
- 120Multi-region active-active: حل الـ conflicts بـ HLC و CRDTs
- 121Readiness و Liveness و Startup Probes: الـ pod جاهز ولا عايش؟
- 122Incident Runbooks: من الـ alert للـ postmortem