Lecture 01 · Introduction

المحاضرة 01 · مقدمة

Mapping tasks: all-edge, fog split, edge plus cloud

توزيع المهام: كل شيء في edge، والتقسيم مع fog، وedge مع cloud

Slides 67–71 الشرائح 67–71 P2 SHOULD

Mappings 1 and 2 were the extremes: a strong server far away, or a weak processor with no network. Mappings 3 and 4 live in the middle, and slide 71 tells you what architects actually build. Every answer here is one formula plus one trade-off.

كان Mapping 1 وMapping 2 هما الطرفين: خادم قوي بعيد، أو معالج ضعيف بلا شبكة. أما Mapping 3 وMapping 4 فيقعان في المنتصف، والشريحة 71 تخبرك بما يبنيه المعماريون فعلاً. كل إجابة هنا هي معادلة واحدة ومقايضة واحدة.

The running pipeline

الـ pipeline المستخدم في كل الأمثلة

The lecture uses one three-task pipeline for every mapping: T1 resizes the image (light preprocessing), T2 runs object detection (the heavy task), and T3 draws the bounding boxes and renders the output (light). A mapping is the design decision that places each task on a layer of the continuum.

تستخدم المحاضرة سلسلة معالجة (pipeline) واحدة من ثلاث مهام لكل الحالات: T1 يغيّر حجم الصورة (معالجة أولية خفيفة)، وT2 يشغّل كشف الأجسام (object detection، وهي المهمة الثقيلة)، وT3 يرسم مربعات الإحاطة ويعرض النتيجة (خفيفة). وmapping هو قرار التصميم الذي يضع كل مهمة على طبقة من طبقات continuum.

RT = L1 + PT + L2

L1 is the latency of the request on its way to the server, PT is the processing time of all the tasks, and L2 is the latency of the reply. Moving a task closer shrinks the L terms. Moving it onto smaller hardware grows PT. Every mapping on this page is a different bet on which of the two effects wins.

L1 هو زمن انتقال الطلب إلى الخادم، وPT هو زمن معالجة كل المهام، وL2 هو زمن عودة الرد. نقل المهمة إلى مكان أقرب يُقلّص حدود L، ونقلها إلى عتاد أصغر يُكبّر PT. وكل mapping في هذه الصفحة هو رهان مختلف على أي الأثرين سيغلب.

MAPPING 3 · all at the edge Client EDGE LAYER T1 T2 T3 small L1, L2 PT grows: T2 on a small box MAPPING 4 · edge + fog, pipeline distributed Client EDGE LAYER T1 T3 FOG LAYER T2 extra hop extra hop shared T2 model more compute +2 crossings IN PRACTICE · edge + cloud (slide 71) Client EDGE LAYER T1 T3 CLOUD LAYER T2 no separate fog tier cloud: storage, training
Top: Mapping 3 runs the whole pipeline on one nearby edge server. Middle: Mapping 4 keeps the light tasks at the edge and sends T2 to the fog, adding two crossings. Bottom: the common real design swaps the fog for the cloud.الأعلى: Mapping 3 يشغّل الـ pipeline كاملاً على خادم حافة قريب واحد. الأوسط: Mapping 4 يُبقي المهام الخفيفة في الحافة ويرسل T2 إلى fog، فيضيف عبورين. الأسفل: التصميم الواقعي الشائع يضع السحابة مكان fog.

Mapping 3: everything at the edge

Mapping 3: كل شيء في الحافة (edge)

The server hosts the whole pipeline, and the server sits in the edge layer: servers or computational resources located closer to the client, such as edge data centers or on-premises servers. Edge sites are geographically distributed (many small sites) and serve nearby users with reduced latency compared with the cloud.

الخادم يستضيف السلسلة كاملة، والخادم موجود في edge layer: أي خوادم أو موارد حوسبة أقرب إلى العميل، مثل مراكز بيانات الحافة أو الخوادم داخل المنشأة (on-premises). مواقع الحافة موزّعة جغرافياً (مواقع صغيرة كثيرة) وتخدم المستخدمين القريبين بزمن تأخير أقل مقارنة بالسحابة.

What it buys

ماذا يكسب

Small L1 and L2, because the server is in the same building or at a nearby telecom site. A real server, so PT is moderate rather than the long PT of a phone. Data stays local.

L1 وL2 صغيران لأن الخادم في نفس المبنى أو في موقع اتصالات قريب. وهو خادم حقيقي، فيكون PT متوسطاً لا طويلاً كما في الهاتف. والبيانات تبقى محلية.

What it costs (slide 67)

ماذا يكلّف (الشريحة 67)

1. Limited geographic reach: only users in the area covered by that edge site can use the service. 2. Limited scalability: the edge layer cannot handle a large number of workloads.

1. نطاق جغرافي محدود (limited geographic reach): لا يستفيد من الخدمة إلا المستخدمون داخل المنطقة التي يغطيها موقع الحافة. 2. قابلية توسّع محدودة (limited scalability): طبقة الحافة لا تستطيع تحمّل عدد كبير من أحمال العمل.

Slide 68's example is retail store analytics: an edge server in the store processes customer footfall, product preferences and inventory levels in real time, without sending data to the cloud, but it can only serve the store and nearby devices. It fits precisely because neither weakness matters: the users and the data are both local.

مثال الشريحة 68 هو تحليلات متجر التجزئة (retail store analytics): خادم حافة داخل المتجر يعالج حركة الزبائن وتفضيلات المنتجات ومستويات المخزون لحظياً، دون إرسال البيانات إلى السحابة، لكنه لا يخدم إلا المتجر والأجهزة القريبة. وهو مناسب تماماً لأن أياً من نقطتي الضعف لا يهم هنا: المستخدمون والبيانات كلاهما محليان.

Mapping 4: split across edge and fog

Mapping 4: تقسيم بين edge وfog

The server now spans two layers and the pipeline is distributed. T1 (preprocessing, such as resizing) and T3 (final steps, such as rendering output) stay in the edge layer. T2, the computationally intensive object detection, runs in the fog layer. With more layers, the formula grows: every boundary crossing is a latency term, and every task is a processing term.

أصبح الخادم الآن ممتداً على طبقتين والسلسلة موزّعة (distributed). يبقى T1 (المعالجة الأولية مثل تغيير الحجم) وT3 (الخطوات الأخيرة مثل عرض النتيجة) في طبقة الحافة، بينما يعمل T2، وهو كشف الأجسام كثيف الحوسبة، في طبقة fog. ومع زيادة الطبقات تكبر المعادلة: كل عبور لحدّ بين طبقتين حدٌّ للتأخير، وكل مهمة حدٌّ للمعالجة.

RT = Lc→e + PT1 + Le→f + PT2 + Lf→e + PT3 + Le→c

أربعة حدود للتأخير بدلاً من اثنين، وثلاثة حدود للمعالجة. الحدّان المظلّلان (Le→f وLf→e) هما الثمن الجديد الذي يدفعه Mapping 4.

The impact of Mapping 4 (slide 70)

أثر Mapping 4 (الشريحة 70)

  1. Sharing. The object detection model in the fog can be accessed by users in multiple edge nodes. Smart city: traffic cameras at many intersections (edge) send data to one nearby fog server for real-time vehicle detection.

    المشاركة (sharing). نموذج كشف الأجسام في fog يمكن أن يصل إليه مستخدمو عدة عُقد حافة. في المدينة الذكية: كاميرات المرور عند تقاطعات كثيرة (edge) ترسل بياناتها إلى خادم fog قريب واحد لكشف المركبات لحظياً.

  2. Latency up, capacity up. The fog layer introduces latency, but offers better processing power and storage than any single edge site.

    تأخير أكبر وقدرة أكبر. طبقة fog تضيف تأخيراً، لكنها تقدّم قدرة معالجة وتخزين أفضل من أي موقع حافة منفرد.

  3. Learning. The fog collects data from the edge nodes to keep the machine learning model up to date.

    التعلّم. تجمع fog البيانات من عُقد الحافة لتُبقي نموذج تعلّم الآلة (ML model) محدّثاً.

Put simply, the fog's job is state that many edges share: one model, one aggregated dataset, one coordination point. It does not replace the cloud. It partly restores the centralization that Mapping 3 gave up, without going all the way to a distant data center.

ببساطة، وظيفة fog هي الحالة المشتركة بين حواف كثيرة (shared state): نموذج واحد، ومجموعة بيانات مُجمَّعة واحدة، ونقطة تنسيق واحدة. وهي لا تحلّ محل السحابة، بل تعيد جزءاً من المركزية التي تخلّى عنها Mapping 3، دون الذهاب حتى مركز بيانات بعيد.

Worked: when does the edge win, and when does it lose?

مثال محلول: متى تربح الحافة، ومتى تخسر؟

The numbers below are the site simulator's presets for the same three-task pipeline. They are teaching values, but the pattern is exactly what the exam wants you to argue.

الأرقام أدناه هي القيم المُعدّة مسبقاً في محاكي الموقع لنفس السلسلة ذات المهام الثلاث. إنها قيم تعليمية، لكن النمط هو بالضبط ما يريد الامتحان أن تجادل به.

Mappingالـ mappingWhere T1, T2, T3 runأين تعمل T1, T2, T3Network (ms)الشبكة (ms)Processing (ms)المعالجة (ms)RT (ms)
1all in the cloudكلها في السحابة14019159
2all on the deviceكلها على الجهاز0440440
3all at the edgeكلها في الحافة10136146
4T1 edge, T2 fog, T3 edgeT1 في edge، وT2 في fog، وT3 في edge405696

يقارن الجدول أربع حالات: السحابة كلها بزمن استجابة 159 ms، والجهاز كله بـ 440 ms، والحافة كلها بـ 146 ms، وتقسيم الحافة مع fog بـ 96 ms. لاحظ أن الحافة وحدها خفّضت الشبكة من 140 إلى 10 ms، لكن المعالجة قفزت من 19 إلى 136 ms.

Worked مثال محلول
all cloud   RT = 140 + 19           = 159 ms
all edge    RT =  10 + 136          = 146 ms
            saved 130 ms of network, paid 117 ms more PT
            net win: only 13 ms

edge + fog  RT =  40 + 56           =  96 ms
            vs all edge: +30 ms network, -80 ms PT
            net win: 50 ms, the fastest preset

now make the edge box weaker, so PT at the edge = 160 ms
all edge    RT =  10 + 160          = 170 ms   > 159
            the edge now LOSES to the cloud

The edge is not automatically faster. It wins only when the latency you save is larger than the processing time you add. Splitting into the fog wins only when the processing you save is larger than the two extra hops you add.

الحافة ليست أسرع تلقائياً. إنها تربح فقط عندما يكون التأخير الذي توفّره أكبر من زمن المعالجة الذي تضيفه. والتقسيم نحو fog يربح فقط عندما تكون المعالجة التي توفّرها أكبر من القفزتين الإضافيتين اللتين تضيفهما.

In practice: edge plus cloud, task by task

في الواقع: edge مع cloud، مهمةً مهمة

Slide 71: a dedicated fog tier is not always explicitly deployed or identified as a separate architectural layer. In most cases, application architects choose two layers: edge and cloud. The shape is Mapping 4 with the cloud in place of the fog: latency-critical work near the user, and storage, training and analytics in the cloud. NIST SP 500-325 agrees that fog is an optional layer.

الشريحة 71: طبقة fog المخصّصة لا تُنشر دائماً ولا تُعرَّف دائماً كطبقة معمارية مستقلة. وفي أغلب الحالات يختار معماريو التطبيقات طبقتين: edge وcloud. الشكل هو Mapping 4 نفسه مع وضع السحابة مكان fog: العمل الحساس للتأخير قرب المستخدم، والتخزين والتدريب والتحليلات في السحابة. ويتفق معيار NIST SP 500-325 على أن fog طبقة اختيارية.

Back to the retail store: the back-office edge server makes the live decisions (restock now, open a checkout), and the cloud trains new models and computes trends across the whole chain. Each task gets the layer that suits it. The board pictured under the edge layer on slide 71 is labeled "Microcontroller Boards", but it is a Raspberry Pi 4, a single-board computer. The point stands: small, cheap boards can serve as edge nodes.

نعود إلى المتجر: خادم الحافة في المكتب الخلفي يتخذ القرارات اللحظية (أعد تعبئة الرف الآن، افتح صندوق دفع إضافياً)، والسحابة تدرّب النماذج الجديدة وتحسب الاتجاهات عبر السلسلة كلها. كل مهمة تأخذ الطبقة المناسبة لها. واللوحة المصوّرة تحت طبقة الحافة في الشريحة 71 مكتوب عليها "Microcontroller Boards"، لكنها Raspberry Pi 4، أي حاسوب أحادي اللوحة. والفكرة تبقى صحيحة: لوحات صغيرة ورخيصة يمكن أن تعمل كعُقد حافة.

Mappingالـ mappingStrengthsنقاط القوةWeaknessesنقاط الضعفExampleمثال
3 all edge3: كلها في الحافةlow latency, data stays localتأخير منخفض، والبيانات تبقى محليةlimited reach, limited scalabilityنطاق محدود، وقابلية توسّع محدودةretail store analyticsتحليلات متجر التجزئة
4 edge + fog4: edge + fogshared model, more compute and storage, model kept up to dateنموذج مشترك، وحوسبة وتخزين أكبر، ونموذج يبقى محدّثاًextra inter-layer hops, data transfer costقفزات إضافية بين الطبقات، وتكلفة نقل البياناتsmart-city traffic camerasكاميرات المرور في المدينة الذكية
edge + cloudeach task on the layer that suits itكل مهمة على الطبقة المناسبة لهاcloud tasks still pay the long tripمهام السحابة ما زالت تدفع ثمن الرحلة الطويلةsmart glasses, store chain trendsالنظارات الذكية، واتجاهات سلسلة المتاجر

ملخّص الجدول: Mapping 3 يعطي تأخيراً منخفضاً وبيانات محلية مقابل نطاق وتوسّع محدودين (مثال المتجر). وMapping 4 يعطي نموذجاً مشتركاً وقدرة أكبر مقابل قفزات إضافية وتكلفة نقل بيانات (كاميرات المرور). وedge + cloud يضع كل مهمة على الطبقة المناسبة لها، لكن مهام السحابة ما زالت تدفع ثمن الرحلة الطويلة.

Trap فخ

"Edge is always faster" is false. RT = L1 + PT + L2. The edge shrinks L1 and L2 but runs on weaker hardware, so PT can grow enough to cancel the saving, as the 170 ms case shows.

عبارة "الحافة أسرع دائماً" خاطئة. RT = L1 + PT + L2. الحافة تُقلّص L1 وL2 لكنها تعمل على عتاد أضعف، فقد يكبر PT بما يكفي لإلغاء التوفير، كما تُظهر حالة 170 ms.

The fog does not replace the cloud. Its role is state shared across many edges (one model, aggregated data). Storage, training and global analytics still belong in the cloud, and in most real systems there is no separate fog tier at all.

fog لا تحلّ محل السحابة. دورها هو الحالة المشتركة بين حواف كثيرة (نموذج واحد، وبيانات مُجمَّعة). أما التخزين والتدريب والتحليلات الشاملة فمكانها السحابة، وفي معظم الأنظمة الحقيقية لا توجد طبقة fog مستقلة أصلاً.

Mapping 4's new cost relative to Mapping 3 is the extra edge-to-fog and fog-to-edge hops (latency and data transfer), not weaker processing. The fog has more compute.

التكلفة الجديدة في Mapping 4 مقارنة بـ Mapping 3 هي القفزتان الإضافيتان من الحافة إلى fog ومن fog إلى الحافة (تأخير ونقل بيانات)، وليست ضعف المعالجة. فـ fog لديها قدرة حوسبة أكبر.

Memory trick حيلة للتذكر

"Clinic, hospital, ministry." The edge is the neighborhood clinic: fast, few rooms, your district only. The fog is the regional hospital that many clinics refer to and share. The cloud is the ministry that keeps every record and trains the doctors.

"Clinic, hospital, ministry." الحافة هي العيادة في الحي: سريعة، وغرفها قليلة، وتخدم حيّك فقط. وfog هي المستشفى الإقليمي الذي تحيل إليه عيادات كثيرة وتتشاركه. والسحابة هي الوزارة التي تحفظ كل السجلات وتدرّب الأطباء.

Check yourself

اختبر نفسك

Compared with Mapping 3 (all at the edge), what new cost does Mapping 4 (T1 edge, T2 fog, T3 edge) introduce?

مقارنة بـ Mapping 3 (كل شيء في الحافة)، ما التكلفة الجديدة التي يضيفها Mapping 4 (T1 في الحافة، وT2 في fog، وT3 في الحافة)؟

Splitting adds an edge to fog hop and a fog to edge hop, so four network crossings instead of two. The client to edge trip is unchanged (A). The fog has more compute, not less (C), and sharing the model across edge nodes is the main benefit, not a loss (D).

التقسيم يضيف قفزة من الحافة إلى fog وقفزة من fog إلى الحافة، أي أربعة عبورات للشبكة بدلاً من اثنين. رحلة العميل إلى الحافة لم تتغيّر (A). وfog لديها قدرة حوسبة أكبر لا أقل (C)، ومشاركة النموذج بين عُقد الحافة هي الفائدة الرئيسية لا خسارة (D).

All-cloud: L1 = L2 = 70 ms, PT = 19 ms. All-edge: L1 = L2 = 5 ms, but T2 on the small edge box makes PT = 160 ms. Which is faster?

السحابة كلها: L1 = L2 = 70 ms وPT = 19 ms. الحافة كلها: L1 = L2 = 5 ms، لكن تشغيل T2 على جهاز الحافة الصغير يجعل PT = 160 ms. أيهما أسرع؟

Cloud: 70 + 19 + 70 = 159 ms. Edge: 5 + 160 + 5 = 170 ms. The edge saved 130 ms of latency but added 141 ms of processing, so it loses. Option D compares only the network terms and forgets PT, which is the exact trap.

السحابة: 70 + 19 + 70 = 159 ms. الحافة: 5 + 160 + 5 = 170 ms. وفّرت الحافة 130 ms من التأخير لكنها أضافت 141 ms من المعالجة، فخسرت. والخيار D يقارن حدود الشبكة فقط وينسى PT، وهذا هو الفخ بعينه.

According to slide 71, which two layers do most application architects choose?

وفقاً للشريحة 71، ما الطبقتان اللتان يختارهما معظم معماريي التطبيقات؟

A dedicated fog tier is not always explicitly deployed or identified as a separate layer, so in most cases architects choose edge and cloud. Latency-critical tasks go to the edge; storage, training and analytics go to the cloud.

طبقة fog المخصّصة لا تُنشر ولا تُعرَّف دائماً كطبقة مستقلة، لذا يختار المعماريون في أغلب الحالات edge وcloud. المهام الحساسة للتأخير تذهب إلى الحافة، والتخزين والتدريب والتحليلات تذهب إلى السحابة.

Ten intersection cameras each resize frames locally, then all send them to one nearby server running a large vehicle-detection model that is retrained on their combined data. Which mapping is this?

عشر كاميرات عند تقاطعات، كلٌّ منها يغيّر حجم الإطارات محلياً، ثم ترسلها جميعاً إلى خادم قريب واحد يشغّل نموذجاً كبيراً لكشف المركبات ويُعاد تدريبه على بياناتها المجمّعة. ما هذا الـ mapping؟

This is slide 70's smart-city example. The shared model and the aggregation of data from many edge nodes are the fog's signature. Mapping 3 would put a detector in each camera's own edge site with no sharing.

هذا مثال المدينة الذكية في الشريحة 70. النموذج المشترك وتجميع البيانات من عُقد حافة كثيرة هما بصمة fog. أما Mapping 3 فيضع كاشفاً في موقع حافة خاص بكل كاميرا دون أي مشاركة.