Lecture 01 · Introduction
المحاضرة 01 · مقدمة
Network applications: Internet vs Web, decentralized vs distributed
تطبيقات الشبكة: الإنترنت مقابل الويب، واللامركزي (decentralized) مقابل الموزّع (distributed)
P2 SHOULDP2 مهمThe Internet moves packets, the Web is one passenger on it. Then: how the lecture splits an application into components, and the two separate questions "decentralized" and "distributed" answer.
الإنترنت ينقل الحزم، والويب مجرد راكب واحد عليه. ثم: كيف تقسّم المحاضرة التطبيق إلى مكوّنات، والسؤالان المختلفان اللذان يجيب عنهما مصطلحا decentralized وdistributed.
Network application: the definition
تطبيق الشبكة (network application): التعريف
Slide 31 gives the definition in one sentence: an application that uses the Internet as the transport medium is a network application. The slide's examples are deliberately mixed: Outlook, uTorrent, Instagram, Netflix, Chrome, Skype, Gmail, HungerStation, Teams. Browser or native app, phone or desktop, it does not matter. If the app needs the Internet to do its job, it is a network application.
تعطي الشريحة 31 التعريف في جملة واحدة: التطبيق الذي يستخدم الإنترنت وسيطاً للنقل (uses the Internet as the transport medium) يُسمّى network application. أمثلة الشريحة متنوعة عن قصد: Outlook وuTorrent وInstagram وNetflix وChrome وSkype وGmail وHungerStation وTeams. لا يهم إن كان يعمل في متصفح أو كبرنامج مستقل، على الهاتف أو الحاسوب. إذا احتاج التطبيق إلى الإنترنت ليؤدي عمله فهو network application.
"Transport medium" has a precise meaning from the TCP/IP stack: the application hands its messages to the transport layer through the socket API, and everything below that line is the infrastructure's job. The application decides what the messages mean; the Internet only delivers them.
عبارة "transport medium" لها معنى دقيق من TCP/IP stack: التطبيق يسلّم رسائله إلى transport layer عبر socket API، وكل ما تحت هذا الخط هو مسؤولية البنية التحتية. التطبيق يقرر معنى الرسائل، والإنترنت يوصلها فقط.
The Internet is not the Web
الإنترنت ليس الويب
Slide 32's figure answers the title "The Web is a Network Application!": a big circle labelled Internet with smaller circles inside it for Web, Email, Online gaming and FTP. The Web is a subset of what the Internet carries.
شكل الشريحة 32 يجيب عن عنوانها "The Web is a Network Application!": دائرة كبيرة اسمها Internet بداخلها دوائر أصغر: Web وEmail وOnline gaming وFTP. الويب مجموعة جزئية مما يحمله الإنترنت.
Internet
الإنترنت (Internet)
The infrastructure: a network of networks. Routers, links, providers and the TCP/IP stack that move packets between any two hosts.
البنية التحتية: شبكة من الشبكات. الموجّهات والروابط ومزوّدو الخدمة وTCP/IP stack التي تنقل الحزم بين أي جهازين.
Web (WWW)
الويب (WWW)
One application on that infrastructure. What makes something "the Web" is that it fetches linked resources using HTTP.
تطبيق واحد فوق هذه البنية. ما يجعل الشيء "ويب" هو أنه يجلب موارد مترابطة باستخدام HTTP.
History makes the order obvious. The Internet carried remote logins, email and file transfer for years before the Web existed. Tim Berners-Lee proposed the Web at CERN in March 1989; the first server and browser ran by the end of 1990. So the Web was built on the Internet, not the other way round.
التاريخ يوضّح الترتيب. حمل الإنترنت الدخول عن بُعد والبريد ونقل الملفات سنوات قبل وجود الويب. اقترح Tim Berners-Lee الويب في CERN في March 1989، وعمل أول خادم ومتصفح بنهاية 1990. إذن بُني الويب فوق الإنترنت، وليس العكس.
| Appالتطبيق | Runs inيعمل داخل | Talks toيتحدث مع | Circle / architectureالدائرة / البنية |
|---|---|---|---|
| Chrome opening a siteChrome يفتح موقعاً | Browserالمتصفح | Web servers over HTTPخوادم ويب عبر HTTP | Web, client-serverالويب، client-server |
| Gmail in a tabGmail في تبويب | Browserالمتصفح | Google's servers over HTTPخوادم Google عبر HTTP | Web, client-serverالويب، client-server |
| Outlook desktopOutlook لسطح المكتب | Native programبرنامج أصلي (native) | Mail server over SMTP / IMAPخادم بريد عبر SMTP / IMAP | Email, client-serverالبريد الإلكتروني، client-server |
| Netflix or HungerStation appتطبيق Netflix أو HungerStation | Native phone appتطبيق هاتف أصلي | The company's backendالـ backend الخاص بالشركة | Client-server, HTTP APIsclient-server، وHTTP APIs |
| uTorrent | Native programبرنامج أصلي (native) | Other BitTorrent peers directlyأقران BitTorrent آخرون مباشرة | Peer-to-peerنظير إلى نظير (peer-to-peer) |
يصنّف هذا الجدول خمسة تطبيقات مألوفة: أين تعمل، ومع من تتكلم، وإلى أي دائرة تنتمي. ما يجب ملاحظته: كلها network applications، لكن ليس كلها ويب. Outlook يتكلم SMTP/IMAP فهو في دائرة البريد، وuTorrent هو الشاذ الوحيد لأنه يتبادل الملفات مع مستخدمين آخرين مباشرة (peer-to-peer) لا مع خادم شركة.
Decentralized vs distributed: two different questions
اللامركزي مقابل الموزّع: سؤالان مختلفان
Slide 33 defines both words, and the definitions are the lecture's own, so use them word for word in the exam.
تعرّف الشريحة 33 المصطلحين، والتعريفات خاصة بالمحاضرة، فاستخدمها حرفياً في الامتحان.
Decentralized application
التطبيق اللامركزي (decentralized)
The application is divided into two components, client and server. They are two distinct (standalone) programs, typically on two distinct physical machines. They communicate using a protocol and use sockets to talk. Examples: BitTorrent, Bitcoin.
التطبيق مقسوم إلى مكوّنين: client وserver. هما برنامجان مستقلان (standalone)، عادةً على جهازين فعليين مختلفين. يتواصلان باستخدام protocol وعبر sockets. الأمثلة: BitTorrent، Bitcoin.
The question it answers: how is the application structured into separate programs?
السؤال الذي يجيب عنه: كيف يُبنى التطبيق من برامج منفصلة؟
Distributed application
التطبيق الموزّع (distributed)
Computation does not happen on a single machine; it is distributed between client and server. Also state (memory/data) is distributed. Example: Google Cloud.
الحساب لا يحدث على جهاز واحد، بل يتوزّع بين client وserver. وكذلك الحالة (state: الذاكرة والبيانات) موزّعة. المثال: Google Cloud.
The question it answers: where do the computation and data physically live?
السؤال الذي يجيب عنه: أين يعيش الحساب والبيانات فعلياً؟
"De-centralized cuts the program. Dis-tributed spreads the work."
"Decentralized يقطّع البرنامج، وDistributed ينشر العمل."
Decentralized is about structure (separate programs plus a protocol). Distributed is about resources (where compute and state sit). Two axes, so one system can score on one, both, or neither.
Decentralized يتعلق بـالبنية (برامج منفصلة مع protocol). وDistributed يتعلق بـالموارد (أين يقع الحساب والحالة). محوران مختلفان، فقد يحقق النظام أحدهما أو كليهما أو لا شيء منهما.
One calculator, built three ways, classified with the lecture's definitions:
آلة حاسبة واحدة مبنية بثلاث طرق، ومصنّفة بتعريفات المحاضرة:
Build 1: desktop calculator, one program, one machine
decentralized? no distributed? no
Build 2: browser page sends "2+3" over HTTP to a server program, gets 5
decentralized? yes (two programs, protocol, sockets)
distributed? yes (compute and state shared by client and server)
Build 3: same, but server work and data spread over several machines
decentralized? yes distributed? yes, further
Build 1 is the control case: nothing is split, so neither label applies.
البناء الأول هو حالة المقارنة: لا شيء مقسوم، فلا ينطبق أي من الوصفين.
The server side is a set of components
جانب الـ server مجموعة من المكوّنات
Slide 34 opens up "the server" of a calculator network application. The client talks only to an API Gateway, a single entry point that routes each request to one of four operation services (Add, Sub, Mul, Div), each of which can read and write a Database. The dashed box around everything except the client is the server layer, "typically hosted in the Cloud". Then the slide's question: can we assign the server components to different layers?
تفتح الشريحة 34 "الخادم" في تطبيق آلة حاسبة شبكي. الـclient يتكلم فقط مع API Gateway، وهو نقطة دخول واحدة توجّه كل طلب إلى إحدى أربع خدمات (Add, Sub, Mul, Div)، وكل منها يقرأ ويكتب في Database. الصندوق المتقطع حول كل شيء عدا الـclient هو server layer، "المستضاف عادةً في السحابة". ثم سؤال الشريحة: هل يمكن توزيع مكوّنات الخادم على طبقات مختلفة؟
Yes, because each component is a separate program with its own interface. That is the whole premise of edge computing: separate pieces can live in separate places.
نعم، لأن كل مكوّن برنامج منفصل له واجهته الخاصة. وهذه هي فكرة edge computing كلها: القطع المنفصلة يمكن أن تعيش في أماكن منفصلة.
So the two definitions from slide 33 become the two axes of a two-dimensional design space. A column is a resource type, not one machine: each layer has its own instance of Compute 1 and Compute 2, which is what makes the application distributed in practice.
إذن يصبح التعريفان من الشريحة 33 محورَي two-dimensional design space. العمود يمثّل نوع مورد وليس جهازاً واحداً: لكل طبقة نسختها الخاصة (instance) من Compute 1 وCompute 2، وهذا ما يجعل التطبيق موزّعاً عملياً.
Criteria for assigning components to layers
معايير توزيع المكوّنات على الطبقات
Slide 35's yellow banner asks: what criteria decide which layer a component goes on? There is no single right answer, only trade-offs. Each criterion pushes a component one way:
يسأل الشريط الأصفر في الشريحة 35: ما المعايير التي تحدد طبقة كل مكوّن؟ لا توجد إجابة واحدة صحيحة، بل موازنات. كل معيار يدفع المكوّن في اتجاه:
| Criterionالمعيار | Pushes the component towardيدفع المكوّن نحو | Calculator exampleمثال من الآلة الحاسبة |
|---|---|---|
| Latencyزمن الاستجابة (Latency) | Lower layers, near the clientالطبقات الدنيا، قرب الـ client | A live result preview that updates as you typeمعاينة حية للنتيجة تتحدث أثناء الكتابة |
| Compute demandالطلب على الحوسبة | Higher layers, where capacity existsالطبقات العليا، حيث توجد السعة | A heavy matrix-inversion serviceخدمة ثقيلة لحساب معكوس المصفوفة |
| Storage and stateالتخزين والحالة | A well-provisioned layer with durable storageطبقة مجهّزة جيداً بتخزين دائم | The Database holding every user's historyالـ Database التي تحفظ سجل كل مستخدم |
| Bandwidth costتكلفة عرض النطاق | Lower layers, near where data is producedالطبقات الدنيا، قرب مكان إنتاج البيانات | Summarize raw input locally, send only results upلخّص المدخلات الخام محلياً، وأرسل النتائج فقط إلى الأعلى |
| Privacyالخصوصية | Lower layers, before data leaves the siteالطبقات الدنيا، قبل أن تغادر البيانات الموقع | Strip personal data firstاحذف البيانات الشخصية أولاً |
| Sharingالمشاركة | A layer every client can reachطبقة يصل إليها كل client | The API Gateway, single entry pointالـ API Gateway، نقطة دخول واحدة |
| Availabilityالتوفّر | A nearby fallback below the cloudبديل احتياطي قريب تحت السحابة | Keep basic Add working in a cloud outageإبقاء عملية Add الأساسية تعمل أثناء انقطاع السحابة |
يربط هذا الجدول كل معيار بالاتجاه الذي يدفع إليه المكوّن، مع مثال من الآلة الحاسبة. الخلاصة: latency وbandwidth cost وprivacy وavailability تدفع المكوّن إلى الطبقات القريبة من المستخدم، بينما compute demand وstorage وsharing تدفعه إلى الطبقات الأعلى حيث توجد السعة. معاينة النتيجة أثناء الكتابة تنزل قريباً من الـclient، وخدمة عكس المصفوفات الثقيلة تصعد إلى حيث توجد القدرة الحسابية.
In an exam, give the criterion with its reason: "live preview goes low because it is latency-critical; matrix inversion goes high because it needs compute the lower layers do not have". A bare list of words earns less.
في الامتحان، اذكر المعيار مع سببه: "المعاينة الحية تنزل للأسفل لأنها حساسة للتأخير، وعكس المصفوفات يصعد للأعلى لأنه يحتاج قدرة حسابية لا تملكها الطبقات السفلى". قائمة كلمات مجردة تأخذ درجة أقل.
Front-end, back-end, sockets: logical talk vs physical bytes
الـ front-end والـ back-end والمقابس: حديث منطقي مقابل بايتات فيزيائية
Slide 37 draws the client-server model. The front-end is the client, hosted by the browser; the back-end is the server, hosted by Node.js. They exchange an HTTP request and response. Underneath, each connects to the Internet through a socket, and the bytes follow a path through the network. The slide's definition: a socket is "a communication endpoint that establishes a connection between the client and server".
ترسم الشريحة 37 نموذج client-server. الـfront-end هو الـclient ويستضيفه المتصفح، والـback-end هو الـserver ويستضيفه Node.js. يتبادلان request وresponse عبر HTTP. وتحت ذلك يتصل كل منهما بالإنترنت عبر socket، وتسلك البايتات path عبر الشبكة. تعريف الشريحة: الـsocket هو "نقطة اتصال تُنشئ اتصالاً بين الـclient والـserver".
Slide 38 splits the same picture vertically. The application layer (HTML, CSS, JavaScript in the browser; Node.js on the server) plus HTTP and TCP inside each box is the web application. The transport, network, data link and physical layers (TL, NL, DLL, PL) are infrastructure, the TCP/IP network drawn as a "pipe". The dashed green arrow between the two HTTP boxes is logical: no HTTP byte travels sideways. Real bytes go down the client stack, through the socket, across the pipe, and up the server stack.
تقسم الشريحة 38 الصورة نفسها عمودياً. application layer (HTML, CSS, JavaScript في المتصفح، وNode.js في الخادم) مع HTTP وTCP داخل كل صندوق هي web application. أما طبقات TL, NL, DLL, PL فهي البنية التحتية، أي شبكة TCP/IP المرسومة كأنبوب (pipe). السهم الأخضر المتقطع بين صندوقي HTTP هو اتصال منطقي فقط: لا يسافر أي بايت من HTTP أفقياً. البايتات الحقيقية تنزل في مكدّس الـclient، وتمر عبر الـsocket والأنبوب، ثم تصعد في مكدّس الخادم.
The request-response loop and its cost
حلقة الطلب والاستجابة وتكلفتها
Slide 39 states three facts. The client is the web browser that makes requests and receives responses. The client initiates the communication, not the server. And preparing the response consumes server resources: compute + storage + communication.
تذكر الشريحة 39 ثلاث حقائق. الـclient هو المتصفح الذي يرسل الطلبات ويستقبل الردود. الـclient هو من يبدأ الاتصال، وليس الخادم. وتحضير الرد يستهلك موارد الخادم: compute + storage + communication.
Why the cost matters at scale. Assume, for illustration, each calculator request costs the server 5 ms of CPU, one database write, and a 2 KB response.
لماذا تهم التكلفة عند التوسع. افترض للتوضيح أن كل طلب يكلّف الخادم 5 ms من المعالج، وكتابة واحدة في قاعدة البيانات، ورداً حجمه 2 KB.
1 user, 1 request/s: compute 5 ms of CPU per second = 0.005 of one core 10,000 users, 1 request/s each: compute 10,000 x 5 ms = 50 s of CPU per second = 50 cores busy storage 10,000 database writes per second communication 10,000 x 2 KB = 20,000 KB/s = 20 MB/s = 160 Mbit/s out
Trivial for one user, a sizing problem for ten thousand. These three costs are exactly what decides where each component should sit in the design space.
تافه لمستخدم واحد، ومشكلة تحجيم لعشرة آلاف. هذه التكاليف الثلاث هي بالضبط ما يحدد موقع كل مكوّن في design space.
- Internet and Web are not synonyms. The Internet is the infrastructure; the Web is one application on it that uses HTTP. Email between servers (SMTP) and FTP use the Internet but are not the Web.
الإنترنت والويب ليسا مترادفين. الإنترنت هو البنية التحتية، والويب تطبيق واحد فوقه يستخدم HTTP. البريد بين الخوادم (SMTP) وFTP يستخدمان الإنترنت لكنهما ليسا ويب.
- Decentralized and distributed answer different questions. Decentralized = how the app is cut into separate programs talking through a protocol; distributed = where computation and state live. A system can be one without the other, and "distributed" does not mean "no single owner": Google Cloud is the lecture's distributed example and is run by one company.
Decentralized وdistributed يجيبان عن سؤالين مختلفين. الأول: كيف يُقطَّع التطبيق إلى برامج تتواصل عبر protocol؛ والثاني: أين يقع الحساب والحالة. قد يكون النظام أحدهما دون الآخر، وdistributed لا تعني "بلا مالك واحد": Google Cloud هو مثال المحاضرة للتوزيع وتديره شركة واحدة.
- Match the lecture's examples exactly. BitTorrent and Bitcoin = decentralized. Google Cloud = distributed.
طابق أمثلة المحاضرة حرفياً. BitTorrent وBitcoin = decentralized. وGoogle Cloud = distributed.
- The server never starts the loop. The client initiates; the server only responds.
الخادم لا يبدأ الحلقة أبداً. الـclient يبدأ، والخادم يرد فقط.
Check yourself
اختبر نفسك
Which statement correctly describes how the Internet and the Web relate?
أي عبارة تصف العلاقة بين الإنترنت والويب بشكل صحيح؟
D. The Internet is the infrastructure that moves packets; the Web is one application on it, a sibling of email, FTP and online gaming (slide 32). A reverses the dependency, B is the everyday confusion the slide exists to kill, and C describes the Internet, not the Web.
الجواب D. الإنترنت هو البنية التي تنقل الحزم، والويب تطبيق واحد فوقه، شقيق البريد وFTP والألعاب (الشريحة 32). الخيار A يعكس الاعتماد، وB هو الخلط الشائع الذي وُجدت الشريحة لإزالته، وC يصف الإنترنت لا الويب.
Using the lecture's own definitions, which example is a distributed application?
باستخدام تعريفات المحاضرة نفسها، أي مثال هو تطبيق distributed؟
C. Slide 33 gives Google Cloud as the distributed example: computation and state are spread over many machines. BitTorrent and Bitcoin are the lecture's decentralized examples, and an offline single-program calculator is neither.
الجواب C. تعطي الشريحة 33 Google Cloud مثالاً على distributed: الحساب والحالة موزّعان على أجهزة كثيرة. أما BitTorrent وBitcoin فهما مثالا decentralized في المحاضرة، والآلة الحاسبة غير المتصلة ليست أياً منهما.
In the two-dimensional design space, moving a component up the vertical axis changes what?
في two-dimensional design space، تحريك مكوّن إلى أعلى على المحور العمودي يغيّر ماذا؟
A. The vertical axis is decentralization, measured in layers (Layer 1, 2, 3). Changing between Compute 1 and Compute 2 / Storage is a horizontal move along the distribution axis.
الجواب A. المحور العمودي هو decentralization ويُقاس بالطبقات (Layer 1, 2, 3). أما التبديل بين Compute 1 وCompute 2 / Storage فهو حركة أفقية على محور distribution.
The calculator gets two new components: a live result preview that must update on every keystroke, and a heavy matrix-inversion service. Which placement fits the lecture's reasoning?
أُضيف إلى الآلة الحاسبة مكوّنان: معاينة حية للنتيجة تتحدث مع كل ضغطة مفتاح، وخدمة ثقيلة لعكس المصفوفات. أي توزيع يناسب منطق المحاضرة؟
B. Latency pushes the preview toward the client; compute demand pulls matrix inversion up to where capacity exists. A ignores latency, C inverts both criteria, and D ignores that lower layers have less compute.
الجواب B. معيار latency يدفع المعاينة نحو الـclient، ومعيار الحاجة الحسابية يرفع عكس المصفوفات إلى حيث توجد السعة. الخيار A يتجاهل التأخير، وC يعكس المعيارين، وD يتجاهل أن الطبقات السفلى أقل قدرة حسابية.
In the request-response loop of slide 39, which statement is correct?
في حلقة request-response في الشريحة 39، أي عبارة صحيحة؟
C. Slide 39: the client initiates (not the server), and preparing the response consumes compute + storage + communication. A has the server initiating, B drops two of the three costs, and D confuses the logical HTTP arrow with the physical path down and up the stacks (slide 38).
الجواب C. الشريحة 39: الـclient هو من يبدأ (لا الخادم)، وتحضير الرد يستهلك compute + storage + communication. الخيار A يجعل الخادم يبدأ، وB يُسقط تكلفتين من ثلاث، وD يخلط السهم المنطقي لـHTTP بالمسار الفعلي نزولاً وصعوداً في المكدّسين (الشريحة 38).