Lecture 01 · Introduction

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

The latency budget τ and the four-step design method

ميزانية التأخير τ وطريقة التصميم ذات الخطوات الأربع

Slides 72–77 الشرائح 72–77 P1 MUST

Without a deadline, "edge or cloud?" is a matter of taste. With a deadline it becomes an inequality you check with a calculator. This page is that inequality, where the deadline comes from, and the method that turns it into a design.

بدون موعد نهائي، يصبح سؤال "الحافة أم السحابة؟" مسألة ذوق. ومع وجود موعد نهائي يتحوّل إلى متباينة تتحقق منها بالآلة الحاسبة. هذه الصفحة هي تلك المتباينة، ومن أين يأتي الموعد النهائي، والطريقة التي تحوّله إلى تصميم.

The definition

التعريف

Every service (pipeline) must answer within a threshold called τ (tau). τ is the maximum acceptable end-to-end response time. The latency budget of the application is the interval [0, τ], and a mapping is feasible only when its response time fits inside it.

كل خدمة (pipeline) يجب أن تُجيب ضمن عتبة تُسمّى τ (تاو). وτ هي أقصى زمن استجابة مقبول من الطرف إلى الطرف (end-to-end). وميزانية التأخير (latency budget) للتطبيق هي الفترة [0, τ]، ولا يكون الـ mapping ممكناً إلا إذا وقع زمن استجابته داخلها.

RT = L1 + PT + L2 ≤ τ

Compare RT with τ, not one latency arrow. Slide 72 draws small, medium and large latency from the client to the edge, fog and cloud, but each arrow is one-way and leaves out processing. The trip out, the processing and the trip back all spend the budget. When the pipeline crosses several layers, every hop and every task's PT join the sum.

قارن RT مع τ، لا سهم تأخير واحداً. ترسم الشريحة 72 تأخيراً صغيراً ومتوسطاً وكبيراً من العميل إلى edge وfog وcloud، لكن كل سهم في اتجاه واحد ولا يشمل المعالجة. رحلة الذهاب والمعالجة ورحلة العودة كلها تستهلك من الميزانية. وعندما تعبر السلسلة عدة طبقات، تنضمّ كل قفزة وكل PT لكل مهمة إلى المجموع.

Same request, three placements, τ = 100 ms 0 40 80 100 120 160 ms EDGE PT 70 80 ✓ FOG L 20 PT 70 L 20 110 ✗ CLOUD L1 70 PT 20 L2 70 160 ✗ τ violet = latency out and back, green = processing time
Illustrative numbers. Edge: 5 + 70 + 5 = 80 ms, inside τ. Fog: 20 + 70 + 20 = 110 ms, over by 10. Cloud: 70 + 20 + 70 = 160 ms; even with PT = 0 it would be 140 ms, so no faster CPU can save it.أرقام توضيحية. Edge: 5 + 70 + 5 = 80 ms، داخل τ. Fog: 20 + 70 + 20 = 110 ms، أي تتجاوز بـ 10. Cloud: 70 + 20 + 70 = 160 ms، وحتى مع PT = 0 ستكون 140 ms، فلا يستطيع أي معالج أسرع إنقاذها.
Worked مثال محلول
budget: τ = 100 ms

fog    RT = 20 + 70 + 20  = 110 ms    110 > 100   FAILS by 10
edge   RT =  5 + 70 +  5  =  80 ms     80 ≤ 100   PASSES
cloud  RT = 70 + 20 + 70  = 160 ms    160 > 100   FAILS
       best case PT = 0:  70 + 0 + 70 = 140 ms   still FAILS
       -> only moving closer helps, not a faster server

caution: edge boxes are small. if edge PT grows to 95 ms:
edge   RT =  5 + 95 +  5  = 105 ms   FAILS

Always write the sum, then the inequality, then a one-word verdict. The marks are on the visible sum.

اكتب دائماً المجموع، ثم المتباينة، ثم حكماً بكلمة واحدة. الدرجات موضوعة على المجموع المكتوب.

Where τ comes from

من أين تأتي τ

τ is set by people and physics, not by the network or the hardware you own. The network and servers only decide how much of the budget you spend. Never invent τ: published studies give defensible numbers spanning four orders of magnitude.

تُحدَّد τ من خلال البشر والفيزياء، لا من خلال الشبكة أو العتاد الذي تملكه. فالشبكة والخوادم تقرّر فقط كم تُنفق من الميزانية. لا تخترع τ أبداً: الدراسات المنشورة تعطي أرقاماً يمكن الدفاع عنها، تمتد عبر أربع مراتب عشرية.

InteractionالتفاعلτSourceالمصدر
XR motion-to-photon≤ 20 ms (7 to 15 ms preferred)≤ 20 ms (والمفضّل 7 إلى 15 ms)RFC 9699
Response feels instantaneousالاستجابة تبدو فورية0.1 sNielsen
One-way conversational delayتأخير المحادثة في اتجاه واحد< 150 ms preferred, 400 ms ceiling< 150 ms مفضّل، وسقف 400 msITU-T G.114
Web interaction rated good (INP)تفاعل ويب مصنّف جيداً (INP)≤ 200 ms at p75≤ 200 ms عند p75web.dev
Wearable face recognitionالتعرّف على الوجوه في الأجهزة القابلة للارتداء370 to 1000 ms370 إلى 1000 msChen et al. 2017
Step-by-step guidanceالإرشاد خطوة بخطوة600 ms tight, 2.7 s loose600 ms ضيق، و2.7 s واسعChen et al. 2017
Flow of thought unbrokenتسلسل التفكير لا ينقطع1 sNielsen
User keeps attention on the taskالمستخدم يبقى منتبهاً للمهمة10 sNielsen

يجمع الجدول قيم τ المنشورة من الأشد إلى الأرخى: نظارات الواقع الممتد (XR) تحتاج زمن motion-to-photon لا يتجاوز 20 ms (والمفضّل من 7 إلى 15 ms، حسب RFC 9699). والمحادثة تحتاج تأخيراً في اتجاه واحد أقل من 150 ms مع سقف 400 ms (ITU-T G.114). وتفاعل الويب يُعدّ جيداً إذا كان INP ≤ 200 ms عند المئين p75. والتعرّف على الوجوه عبر الأجهزة القابلة للارتداء من 370 إلى 1000 ms، والإرشاد خطوة بخطوة 600 ms كحدّ ضيق و2.7 s كحدّ واسع (Chen et al. 2017). ويحافظ المستخدم على انتباهه نحو 10 s (Nielsen).

Check at a percentile, not the mean

افحص عند مئين، لا عند المتوسط

A budget is a promise about what users experience, and users remember the slow requests. So published budgets are stated at a percentile: web.dev rates an interaction good only when 75% of visits are within 200 ms (p75), and Chen et al. judge wearable assistants at the 90th percentile (p90).

الميزانية وعدٌ بما يعيشه المستخدمون، والمستخدمون يتذكرون الطلبات البطيئة. لذلك تُذكر الميزانيات المنشورة عند مئين (percentile): فـ web.dev يعدّ التفاعل جيداً فقط إذا كانت 75% من الزيارات ضمن 200 ms (p75)، وChen et al. يقيّمون المساعدات القابلة للارتداء عند المئين التسعين (p90).

Worked مثال محلول
τ = 200 ms, ten measured response times (sorted, ms):
  80  90  90  100  100  110  120  150  260  300

mean = 1400 / 10            = 140 ms    ≤ 200   looks fine
p75  = value #ceil(0.75x10) = #8 = 150  ≤ 200   passes
p90  = value #ceil(0.90x10) = #9 = 260  > 200   FAILS

two users in ten wait longer than τ. the mean hides them.

The four-step design method

طريقة التصميم ذات الخطوات الأربع

Design questions have no single right answer, but they have a right method, and it is the same four steps every time.

أسئلة التصميم ليس لها إجابة صحيحة واحدة، لكن لها طريقة صحيحة، وهي الخطوات الأربع نفسها في كل مرة.

  1. List the tasks of the service pipeline.

    اسرد المهام في سلسلة الخدمة (pipeline).

  2. Set τ per task, from a published source, not one τ for the whole app.

    حدّد τ لكل مهمة من مصدر منشور، لا τ واحدة للتطبيق كله.

  3. Place each task on device, edge, fog or cloud (the mapping).

    ضع كل مهمة على الجهاز أو edge أو fog أو cloud (أي الـ mapping).

  4. Check RT ≤ τ and the trade-offs: battery, privacy, reach, cost.

    تحقّق من RT ≤ τ ومن المقايضات: البطارية، والخصوصية، والنطاق، والتكلفة.

Design exercise 1: smart glasses (slide 73)

تمرين التصميم 1: النظارات الذكية (الشريحة 73)

TaskالمهمةτLayerالطبقةWhyالسبب
Capture and downscale frameالتقاط الإطار وتصغيرهevery frameكل إطارDevice (glasses)الجهاز (النظارات)shrink raw video before the radioتصغير الفيديو الخام قبل إرساله لاسلكياً
Render the overlayعرض الطبقة المرئية (overlay)≈ 20 ms display loopحلقة عرض ≈ 20 msDevice (glasses)الجهاز (النظارات)must follow head motion, no network trip fitsيجب أن يتبع حركة الرأس، ولا تتسع أي رحلة شبكة
Recognize faces or objectsالتعرّف على الوجوه أو الأجسام370 to 1000 ms370 إلى 1000 msEdge cloudletcloudlet حافةtoo heavy for glasses, too slow via cloudثقيل جداً على النظارات، وبطيء جداً عبر السحابة
Generate guidanceتوليد الإرشاد600 ms to 2.7 s600 ms إلى 2.7 sEdge cloudletcloudlet حافةneeds the recognition result already thereيحتاج نتيجة التعرّف الموجودة هناك أصلاً
Store history, analytics, retrainتخزين السجل، والتحليلات، وإعادة التدريبseconds to hoursمن ثوانٍ إلى ساعاتCloudالسحابةdurable, large datasets, GPU poolsتخزين دائم، ومجموعات بيانات كبيرة، ومجمّعات GPU

في النظارات الذكية: الالتقاط وتصغير الإطار وعرض الطبقة المرئية (overlay) تبقى على النظارات لأن حلقة العرض نحو 20 ms ولا تتسع لرحلة شبكة. والتعرّف على الوجوه والإرشاد يُنقلان (offloading) إلى cloudlet حافة قريب، لأن ميزانيتهما من 370 ms إلى 2.7 s. والتخزين والتحليلات وإعادة التدريب تذهب إلى السحابة لأنها بلا موعد تفاعلي.

Step 4 for the glasses: offloading to the edge saves battery (30 to 40% less energy with cloudlets, Ha et al. via Shi et al.) and keeps raw data private (faces never reach a public cloud). The price is network dependence: the glasses need a working wireless link and an edge site wherever the wearer walks. In Chen et al., cloud offload added roughly 100 to 200 ms compared with a cloudlet.

الخطوة 4 للنظارات: النقل إلى الحافة يوفّر البطارية (طاقة أقل بنسبة 30 إلى 40% مع cloudlets، حسب Ha et al. كما لخّصهم Shi et al.) ويُبقي البيانات الخام خاصة (الوجوه لا تصل إلى سحابة عامة). والثمن هو الاعتماد على الشبكة: تحتاج النظارات اتصالاً لاسلكياً يعمل وموقع حافة أينما ذهب مرتديها. وفي Chen et al.، أضاف النقل إلى السحابة نحو 100 إلى 200 ms مقارنة بـ cloudlet.

Design exercises 2 and 3: AR and VR (slides 74–75)

تمرينا التصميم 2 و3: AR وVR (الشريحتان 74–75)

One app, many deadlines. Motion-to-photon (MTP) is the time from a head or device movement to the matching light leaving the display. RFC 9699 gives at most 20 ms, of which the display takes about 12 to 13 ms, leaving only 7 to 8 ms for sensing, rendering and any round trip. Ideal 4G loopback alone is about 25 ms, so per-frame work cannot depend on a remote round trip.

تطبيق واحد ومواعيد كثيرة. زمن motion-to-photon (MTP) هو الزمن من حركة الرأس أو الجهاز حتى خروج الضوء المطابق من الشاشة. يحدّه RFC 9699 بـ 20 ms على الأكثر، تأخذ الشاشة منها نحو 12 إلى 13 ms، فلا يبقى إلا 7 إلى 8 ms للاستشعار والعرض وأي رحلة ذهاب وإياب. وزمن 4G المثالي وحده نحو 25 ms، فلا يمكن أن يعتمد العمل لكل إطار على رحلة بعيدة.

Warehouse AR

AR في المستودع

Pose tracking and anchoring: device (≤ 20 ms MTP). Shelf-label recognition: edge (a few hundred ms). Pick list, inventory and route optimization shared by all pickers: fog warehouse server (under 1 s to seconds). Fleet analytics and forecasting: cloud (hours).

التتبّع وتثبيت الطبقات: الجهاز (MTP ≤ 20 ms). التعرّف على ملصقات الرفوف: edge (بضع مئات من ms). قائمة الالتقاط والمخزون وتحسين المسارات المشتركة بين كل العمال: خادم fog في المستودع (أقل من ثانية إلى ثوانٍ). تحليلات الأسطول والتنبؤ: cloud (ساعات).

Interactive VR

VR التفاعلي

Head tracking and reprojection (time warp): headset, inside the 15 to 20 ms MTP. Full-quality rendering: edge GPU. Physics and multiplayer state: fog or nearest region (tens of ms up to about 150 ms). Content library and profiles: cloud (seconds).

تتبّع الرأس وإعادة الإسقاط (reprojection أو time warp): على النظارة، داخل MTP البالغ 15 إلى 20 ms. العرض بالجودة الكاملة: GPU في edge. الفيزياء وحالة اللعب الجماعي: fog أو أقرب منطقة سحابية (عشرات ms حتى نحو 150 ms). مكتبة المحتوى وملفات المستخدمين: cloud (ثوانٍ).

Slide 76 gives the lecturer's short answers: smart glasses use the edge for low-latency recognition and the cloud for storage and complex computation; industrial AR uses the edge for real-time sensor interaction and the cloud for large datasets and analytics; VR headsets use the edge for frame rendering and the cloud for large datasets. The captions leave out the device layer, which in reality runs tracking and display.

تعطي الشريحة 76 إجابات المحاضر المختصرة: النظارات الذكية تستخدم edge للتعرّف منخفض التأخير وcloud للتخزين والحسابات المعقدة، والواقع المعزّز الصناعي يستخدم edge للتفاعل اللحظي مع الحساسات وcloud للبيانات الضخمة والتحليلات، ونظارات VR تستخدم edge لعرض الإطارات وcloud للبيانات الضخمة. وتُسقط هذه التعليقات طبقة الجهاز، التي تشغّل في الواقع التتبّع والعرض.

The summary (slide 77)

الخلاصة (الشريحة 77)

Before, you architected an application on one layer only, the server layer. Because we live in the Data, IoT and ML era, the server now has to span the E2C continuum. For every service, each task in the pipeline is individually mapped to a layer. And response time is the main criterion guiding the design: RT = f(Latency, PT), concretely the sum of every hop's latency plus every task's processing time.

في السابق كنت تصمّم التطبيق على طبقة واحدة فقط هي طبقة الخادم. ولأننا نعيش في عصر البيانات وإنترنت الأشياء وتعلّم الآلة (Data/IoT/ML)، صار على الخادم أن يمتد على E2C continuum. ولكل خدمة، تُوضع كل مهمة في السلسلة على حدة على طبقة. وزمن الاستجابة هو المعيار الأساسي الذي يوجّه التصميم: RT = f(Latency, PT)، أي عملياً مجموع تأخير كل قفزة زائد زمن معالجة كل مهمة.

Trap فخ

One τ for the whole app is wrong. "AR needs low latency, so use the edge" loses marks. One AR app mixes 20 ms tracking with analytics that can take hours. Set τ per task, then place per task.

τ واحدة للتطبيق كله خطأ. عبارة "AR يحتاج تأخيراً منخفضاً، إذن استخدم الحافة" تخسر درجات. فتطبيق AR واحد يجمع تتبّعاً بـ 20 ms مع تحليلات قد تستغرق ساعات. حدّد τ لكل مهمة، ثم ضع كل مهمة على حدة.

Mean is not the test. A mean under τ can hide a p90 over τ. Budgets are checked at p75 or p90.

المتوسط ليس هو الاختبار. متوسط أقل من τ قد يخفي p90 أعلى من τ. الميزانيات تُفحص عند p75 أو p90.

Forgetting the return trip. 25 + 75 = 100 is not RT; 25 + 75 + 25 = 125 is. A faster CPU only shrinks PT: if L1 + L2 alone exceeds τ, even PT = 0 fails.

نسيان رحلة العودة. 25 + 75 = 100 ليس RT، بل 25 + 75 + 25 = 125. والمعالج الأسرع يُقلّص PT فقط: إذا تجاوز L1 + L2 وحده قيمة τ، فحتى PT = 0 يفشل.

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

"20, 150, 200, 1000, 10." Headset frame, phone call one way, web click at p75, face recognized, attention span in seconds. Then the matching rule: tight deadline goes to device or edge, shared site state goes to fog, storage, training and analytics go to cloud.

"20, 150, 200, 1000, 10." إطار النظارة، والمكالمة في اتجاه واحد، ونقرة الويب عند p75، والتعرّف على الوجه، ومدة الانتباه بالثواني. ثم قاعدة المطابقة: الموعد الضيق يذهب إلى الجهاز أو edge، والحالة المشتركة للموقع تذهب إلى fog، والتخزين والتدريب والتحليلات تذهب إلى cloud.

Check yourself

اختبر نفسك

τ = 120 ms. One-way latency to the fog is 25 ms and processing takes 75 ms. Is the fog mapping within budget?

τ = 120 ms. التأخير في اتجاه واحد إلى fog هو 25 ms والمعالجة تستغرق 75 ms. هل الـ mapping إلى fog ضمن الميزانية؟

RT = 25 + 75 + 25 = 125 ms, and 125 > 120. Option A forgets the return trip, the most common slip on this question type.

RT = 25 + 75 + 25 = 125 ms، و125 > 120. والخيار A ينسى رحلة العودة، وهو الخطأ الأشيع في هذا النوع من الأسئلة.

Which published figure is the reference for acceptable one-way conversational delay?

ما الرقم المنشور الذي يُعدّ مرجعاً للتأخير المقبول في اتجاه واحد في المحادثة؟

ITU-T G.114: below 150 ms one-way most applications feel transparent, and 400 ms should not be exceeded for planning. 200 ms is the web interaction (INP) threshold at p75, 20 ms is XR motion-to-photon, and 600 ms is the tight bound for step-by-step guidance.

ITU-T G.114: تحت 150 ms في اتجاه واحد تبدو معظم التطبيقات شفافة، ويجب ألا يُتجاوز 400 ms في التخطيط. أما 200 ms فهو حدّ تفاعل الويب (INP) عند p75، و20 ms هو motion-to-photon في XR، و600 ms هو الحدّ الضيق للإرشاد خطوة بخطوة.

A service has τ = 200 ms. Its mean RT is 140 ms but its p90 RT is 260 ms. Is it within budget?

خدمة لها τ = 200 ms. متوسط RT لديها 140 ms لكن RT عند p90 يساوي 260 ms. هل هي ضمن الميزانية؟

Budgets are promises about the slow requests users feel, so they are checked at a percentile (p75 for web.dev, p90 for Chen et al.). One request in ten waiting 260 ms breaks a 200 ms budget even though the mean looks healthy.

الميزانيات وعود حول الطلبات البطيئة التي يشعر بها المستخدمون، لذا تُفحص عند مئين (p75 في web.dev، وp90 عند Chen et al.). وطلب من كل عشرة ينتظر 260 ms يكسر ميزانية 200 ms حتى لو بدا المتوسط سليماً.

In smart glasses, moving face recognition from the glasses to a nearby edge cloudlet mainly trades what for what?

في النظارات الذكية، نقل التعرّف على الوجوه من النظارات إلى cloudlet حافة قريب يقايض أساساً ماذا بماذا؟

Offloading cuts energy use (30 to 40% with cloudlets) and keeps raw faces off the public cloud, but the glasses now need a wireless link and an edge site nearby. Option D is false: Chen et al.'s cloudlet met the loose 1000 ms bound at p90 (435 ms) but missed the tight 370 ms bound.

النقل يقلّل استهلاك الطاقة (30 إلى 40% مع cloudlets) ويُبقي صور الوجوه الخام بعيدة عن السحابة العامة، لكن النظارات صارت تحتاج اتصالاً لاسلكياً وموقع حافة قريباً. والخيار D خاطئ: فـ cloudlet عند Chen et al. حقّق الحدّ الواسع 1000 ms عند p90 (435 ms) لكنه لم يحقق الحدّ الضيق 370 ms.

Match the VR task to its layer: physics and multiplayer state shared by all players in a session.

طابق مهمة VR مع طبقتها: الفيزياء وحالة اللعب الجماعي المشتركة بين كل اللاعبين في الجلسة.

Shared session state is the fog's natural job: it must be common to every player, and its deadline is looser than a frame but still interactive. Tracking and reprojection go on the headset (A), rendering on an edge GPU, content and profiles in the cloud.

الحالة المشتركة للجلسة هي الوظيفة الطبيعية لـ fog: يجب أن تكون مشتركة بين كل اللاعبين، وموعدها أرخى من إطار واحد لكنه ما زال تفاعلياً. أما التتبّع وإعادة الإسقاط فعلى النظارة (A)، والعرض على GPU في edge، والمحتوى وملفات المستخدمين في cloud.