21 / 21

Chapter 17: Distributed Software Engineering

نموذج إِمام التعليمي: إنطلاقة راسخة على خطى الأولين
وَجَعَلْنَاكُمْ شُعُوبًا وَقَبَائِلَ لِتَعَارَفُوا

"We made you into nations and tribes that you may know one another" - Qur'an 49:13

(Transliteration: Wajaʿalnākum shuʿūban waqabāʾila litaʿārafū)

Foundation: التواصل (Communication) and التكامل (Integration)

⚡ Your Mission: Master distributed systems engineering to connect Saudi Arabia's digital infrastructure
افهم
Understand

Why distribute?
Core challenges
Section: Core Concepts

مارس
Practice

Client-Server patterns
Hands-on coding
Section: Communication

اتقن
Master

5 Architectures
Production systems
Section: Architectures

ميز
Excel

SaaS & Cloud
Vision 2030
Section: Modern Trends

🚀 Framework Evolution: Shaping Distributed Systems Engineering

افهم

Two Lenses for Mastering Distributed Systems

🏭 Industrial Revolution 6.0 (IR 6.0)

Human-Centric Engineering (2020s)

  • Section 17.1 - Distributed Systems: Enhances resource sharing (e.g., STC's cloud for 15M users) and fault tolerance (e.g., NEOM's redundant nodes) by prioritizing human experience.
  • Section 17.2 - Client–Server Computing: Optimizes layered architectures (e.g., Al Rajhi Bank's multi-tier system) for scalable, user-friendly access.
  • Section 17.3 - Architectural Patterns: Drives adoption of patterns like Master-Slave for real-time control (e.g., Aramco pipelines).
  • Section 17.4 - Software as a Service: Enables cloud-based SaaS (e.g., Tawakkalna) to serve 25M+ users with minimal downtime.
Market Impact: IR 6.0 boosts productivity (e.g., 15% faster deployments at STC) by aligning technical design with human needs.

📖 Islamization of Knowledge

إسلامية المعرفة (Proactive)

  • Section 17.1 - Distributed Systems: Derives resource sharing from Islamic cooperation (Qur'an 5:2) for equitable resource use.
  • Section 17.2 - Client–Server Computing: Models client-server interactions from consultation (Shura), ensuring balanced system design.
  • Section 17.3 - Architectural Patterns: Inspires P2P from community collaboration, not just Western models.
  • Section 17.4 - Software as a Service: Aligns SaaS with serving humanity, reflecting Islamic values of knowledge dissemination.
Principle: Start with Qur'anic/Sunnah insights, then evaluate global standards for originality.
University Tool: Conceptual Framework
Market Test: Practical Implementation

🎯 Your Learning Approach (Mapped to Objectives)

  • ✅ Understand key design issues (Transparency, Scalability - Objective 1, Section 17.1).
  • ✅ Master client–server models and layers (Objective 2, Section 17.2).
  • ✅ Apply architectural patterns for real-world systems (Objective 3, Section 17.3).
  • ✅ Design SaaS for web-based access (Objective 4, Section 17.4).
🤔 Quick Quiz: Which IR 6.0 Benefit Applies to SaaS? (2 mins)
⏱️ Timer: 2:00
A. Resource Sharing - Cloud servers support multiple users
B. Concurrency - Multiple processes run simultaneously
C. Fault Tolerance - Redundant systems prevent downtime
D. All of the above

🌍 Mission Context: Your Daily Reality

افهم
University Tool: Critical Thinking
Market Test: Understanding Real-World Impact
Right now: You're using 50+ distributed systems without knowing it

🎯 Start With Your Experience (2 mins)

⏱️ Timer: 2:00

(Adapt for online/in-person; use Miro for collaboration or hypotheticals if no device access)

Quick Activity: Open these apps (or view screenshots):

  • WhatsApp on your phone
  • WhatsApp Web on your laptop
  • Your online banking app

Do This: Send a WhatsApp message from phone - watch it appear instantly on web!

Check: Your bank balance is same on app and website!

Notice: Same data, multiple devices, instant sync. How?!

💥 The WhatsApp Phenomenon

  • • 2 billion users across 180 countries
  • • Messages sync instantly across all devices
  • • Never loses data even when servers crash
  • • 100 billion messages daily
🤔 Quick Poll: What makes WhatsApp a distributed system?
A. It has many users
B. Multiple computers work together as one
C. It uses the internet
D. It's a mobile app

📚 What IS a Distributed System?

افهم
University Tool: Analytical Reasoning
Market Test: Identifying Practical Applications

🔍 Discover It Yourself (3 mins)

⏱️ Timer: 3:00

(Adapt for online/in-person)

With your neighbor, classify these scenarios:

Scenario Distributed? (Yes/No) Why?
MS Word on laptop ? Your answer...
Google Docs ? Your answer...
Calculator app ? Your answer...
Uber app ? Your answer...

MS Word: No - Single machine
Google Docs: Yes - Multiple servers, real-time collaboration
Calculator: No - Local processing
Uber: Yes - Drivers, riders, servers connected

Coulouris et al. (2011): "A collection of independent computers that appears to users as a single coherent system"
Market Reality: Failure to sync data (e.g., Absher outage) costs millions in trust and revenue.

🚀 Benefits of Distribution

افهم
University Tool: Problem-Solving
Market Test: Evaluating Scalability Solutions

🎮 Live Simulation: The Instagram Problem (5 mins)

⏱️ Timer: 5:00

(Adapt for online/in-person; simulate with code in GitHub Classroom)

Scenario: You're building Saudi Instagram clone

  • Day 1: 100 users = Works great on 1 server!
  • Month 1: 10,000 users = Server getting slow...
  • Month 3: 1 million users = CRASH! 💥

Options (Vote with your neighbor):

A) Buy a SUPER computer ($10 million)
B) Tell users to wait their turn
C) Use multiple normal computers
D) Give up

Why Option C? Using multiple computers enables scalability, fault tolerance, and cost efficiency. A supercomputer (A) is expensive and a single point of failure. Waiting (B) loses users (e.g., 20% churn in Saudi apps). Giving up (D) is not an option.

Market Reality: STC scaled its cloud services using distributed servers, handling 10M+ users without downtime.

5 Benefits of Distribution

Benefit Description Saudi Example
📚 Resource Sharing Share expensive resources (hardware, software, data) Saudi Portal: All ministries share databases
🔓 Openness Standard protocols, interoperability GCC data exchange standards
⚡ Concurrency Parallel processing, multiple users Hajj: 3M concurrent pilgrims
📈 Scalability Grow on demand Tawakkalna: 1M → 25M users
🛡️ Fault Tolerance Survive failures Banking: Zero downtime (SAMA resilience)
وَتَعَاوَنُوا عَلَى الْبِرِّ وَالتَّقْوَىٰ

"Cooperate in righteousness and piety" - Qur'an 5:2

(Transliteration: Wataʿāwanū ʿalā l-birri wa l-taqwā)

⚠️ 6 Critical Design Issues

افهم
Issue Challenge Saudi Example Solution
Transparency Hide complexity Absher looks simple Middleware
Openness Standard interfaces Yesser standards APIs
Scalability Handle growth Hajj surge Cloud
Security Multiple attack points NCA framework Encryption
QoS Performance guarantees 5G requirements SLAs
Failure Handle crashes SAMA resilience Redundancy

🔒 Four Security Attack Types

University Tool: Risk Analysis
Market Test: Mitigating Costly Threats
👂

Interception

Eavesdropping

e.g., Wifi sniffing banking data

Interruption

DoS attacks

e.g., Crashing Absher servers

✏️

Modification

Data tampering

e.g., Changing payment amount

🎭

Fabrication

False data

e.g., Fake Tawakkalna status

Contemporary Threats (NCA Guidelines, 2024):

  • Supply-chain attacks: Compromised updates (e.g., Aramco vendor breach risk)
  • Zero-trust models: Verify everything (NCA mandate for NEOM)
Market Reality: A single breach in SAMA systems could cost billions and erode public trust.

💬 Two Ways to Communicate

مارس
University Tool: Modeling Interactions
Market Test: Optimizing Communication Efficiency

🎭 Role Play Activity: Restaurant Order (4 mins)

⏱️ Timer: 4:00

(Adapt for online/in-person; budget: $1000 for system design)

Team Activity: Split into pairs (or describe hypothetically):

  • Round 1: Procedural (multiple back-forth questions)
  • Round 2: Message-based (one complete order)

🍽️ Procedural (RPC)

Multiple back-and-forth interactions:

Waiter: "What drink?"
You: "Water"
Waiter: "Appetizer?"
You: "Soup"
Waiter: "Main?"
You: "Steak"
// 6 messages total!

📦 Message-Based

One complete message:

<order>
  <drink>water</drink>
  <appetizer>soup</appetizer>
  <main>steak</main>
</order>
// 1 message only!
Market Reality: Procedural delays in banking apps increase user drop-off by 30%.
Industry Tool: Use Postman for API testing to simulate message-based systems.
🤔 Which is better for Saudi banking?
A. Always RPC - more control
B. Messages for batch, RPC for real-time
C. Always messages - fewer calls
D. Doesn't matter

🔧 Middleware: The Universal Translator

مارس
University Tool: Data Transformation
Market Test: Ensuring Interoperability

🔄 Live Challenge: Make These Systems Talk! (3 mins)

⏱️ Timer: 3:00

(Adapt for online/in-person; use GitHub Classroom)

Problem: Bank A sends Arabic XML, Bank B expects English JSON

System A (Saudi Bank): Sends XML in Arabic
<حساب>
  <رقم>123456</رقم>
  <رصيد>5000</رصيد>
</حساب>

System B (International): Expects JSON in English
{
  "account_number": ?,
  "balance": ?
}

// YOUR TASK: Write the conversion!
function translateData(xmlData) {
  // Your code here...
}
import xml.etree.ElementTree as ET
def translateData(xmlData):
  root = ET.fromstring(xmlData)
  account_number = root.find('رقم').text
  balance = root.find('رصيد').text
  return {
    "account_number": account_number,
    "balance": balance
  }
Middleware: Software layer between network OS and applications that provides common services
Market Reality: Middleware failures in Absher could delay services, costing $500K/hour in lost productivity.
Industry Tool: Use Apache Kafka for real-time data streaming in middleware.

Figure 17.3: Middleware Architecture

(Alt text: Diagram showing applications layered over middleware, which is over network OS)

Applications
Middleware Layer
Network OS

💻 Client-Server Architecture

مارس
University Tool: System Design
Market Test: Building Scalable Applications

Figure 17.6: 4-Layer Model

(Alt text: Four-tier diagram: Presentation, Data Handling, Application, Database)

🌐
1. Presentation
UI/Display
✔️
2. Data Handling
Validation
⚙️
3. Application
Business Logic
💾
4. Database
Storage

Thin vs Fat Clients

Aspect Thin Client Fat Client
Processing Server does everything Client does processing
Example Web Gmail Mobile banking app
Pros Easy updates, central control Works offline, fast
Cons Needs connection Hard to update
Saudi Use Case Absher web portal Tawakkalna app
Market Reality: Al Rajhi Bank uses fat clients for mobile apps to enable offline transaction recording, syncing when connected.

🗿 5 Architectural Patterns

اتقن
University Tool: Pattern Recognition
Market Test: Selecting Optimal Architectures

🎮 Pattern Matching Game (5 mins)

⏱️ Timer: 5:00

(Adapt for online/in-person; use Miro)

Identify patterns in Saudi systems:

  • Riyadh Metro: Central control room, real-time decisions
  • ATM Networks: Card reader + Display, simple interaction
  • Absher Portal: Web interface, multiple databases
  • University WiFi: File sharing, no central server

Riyadh Metro: Master-Slave
ATM: Two-Tier C/S
Absher: Multi-Tier
WiFi Sharing: P2P

Market Reality: Choosing the wrong pattern (e.g., P2P for Absher) could lead to regulatory fines and downtime.
👑
Master-Slave

One coordinator
Many workers

📱
Two-Tier C/S

Simple client-server
Direct connection

🏢
Multi-Tier

Layered servers
Web apps

🧩
Components

Service-based
Microservices

🔗
P2P

No central authority
Equal peers

👑 Master-Slave Architecture

اتقن

Figure 17.7: Traffic Management System

(Alt text: Sensors to Master Control to Actuators diagram)

📡
Sensors
Collect data
🎛️
MASTER
Control Room
🚦
Actuators
Traffic lights
import asyncio
class TrafficMaster:
  async def controlLoop(self, sensors, lights):
    while True:
      # Collect from all slaves
      data = await asyncio.gather(*[s.collect() for s in sensors])
      # Master makes decisions
      cmds = self.analyzeTraffic(data)
      # Control all slaves
      await asyncio.gather(*[l.execute(cmd) for l, cmd in zip(lights, cmds)])

Case Study: Aramco Pipeline Control

Aramco uses master-slave for oil pipeline monitoring, ensuring real-time control with 99.99% uptime.

Production Checklist:

  • ✓ Ensure low-latency sensor data (under 100ms)
  • ✓ Implement redundant masters
  • ✓ Monitor slave health continuously

🏢 Multi-Tier Architecture

اتقن

Figure 17.10: Banking System Architecture

(Alt text: Four tiers: Presentation, Web Server, Application, Database)

Tier 1: Presentation

🌐

Web browsers, Mobile apps

  • HTML/CSS/JavaScript
  • React/Angular
  • Swift/Kotlin

Tier 2: Web Server

🖥️

HTTP handling, Static content

  • Apache/Nginx
  • Load balancing
  • SSL termination

Tier 3: Application

⚙️

Business logic, Processing

  • Java/Python/C#
  • Microservices
  • API endpoints

Tier 4: Database

💾

Data storage, Transactions

  • Oracle/PostgreSQL
  • MongoDB
  • Redis cache

Case Study: Al Rajhi Bank

Al Rajhi Bank uses multi-tier for online banking, handling 10M transactions daily.

Architecture Details:

  • Load balancer: HAProxy with 5 web servers
  • Application tier: 20 microservices
  • Database: Oracle RAC with real-time replication

🔗 Peer-to-Peer Architecture

اتقن

🔗 Experience P2P: Human BitTorrent (5 mins)

⏱️ Timer: 5:00

(Adapt for online/in-person; describe if physical sharing not possible)

  1. Teacher has original document (seeder)
  2. Tears it into 4 pieces
  3. Gives pieces to 4 different students
  4. Students share pieces with neighbors
  5. Everyone reconstructs full document

Notice: Teacher can leave, sharing continues! No central control!

const WebTorrent = require('webtorrent')
const client = new WebTorrent()

client.add(torrentId, function (torrent) {
  torrent.on('download', (bytes) => {
    console.log('Downloaded:', bytes)
  })
  torrent.on('done', () => {
    console.log('Download complete!')
  })
})

Case Study: NEOM IoT Network

NEOM explores P2P for IoT device communication, reducing latency by 40%.

Implementation:

  • 10,000+ sensors sharing data directly
  • No central point of failure
  • Self-healing network topology
🤔 Why doesn't Saudi government use P2P for services?
A. Too expensive
B. Security & control requirements
C. Too slow
D. Old technology
ميز

🚀 Quick Check: Count Your SaaS (30 seconds)

⏱️ Timer: 0:30

How many SaaS do you use?

  • Gmail/Outlook
  • Google Docs/Office 365
  • Netflix/Shahid
  • Spotify/Anghami
  • Canvas/Blackboard
  • Zoom/Teams
  • Instagram/TikTok
University Tool: System Architecture
Market Test: Delivering Scalable Solutions

🗿 Design Challenge: University SaaS (5 mins)

⏱️ Timer: 5:00

(Budget: $1M; Scale: 1M students)

Build "Canvas for Saudi Universities":

  • Multi-tenancy: Separate KSU from KAUST data
  • Customization: University-specific branding
  • Scale: 1M students
  • Updates: Deploy without downtime

Use AWS multi-tenant design with VPCs for isolation, CSS for branding, auto-scaling groups, blue-green deployments.

Market Reality: Downtime during updates could disrupt 100K+ students, costing universities reputation and revenue.
Modern Trends (Kleppmann, 2017; AWS Well-Architected, 2024):
  • Serverless: AWS Lambda for Hajj notifications
  • Edge Computing: CDNs for low-latency Hajj apps

🇸🇦 Saudi's Distributed Revolution

ميز
Vision 2030: Transform Saudi Arabia into a global digital hub through distributed excellence
2025+ NEOM smart city pilots

🕋 Hajj Systems

3M+
Concurrent users
  • 100K requests/second
  • Multi-tier architecture
  • Zero downtime requirement

🏛️ Digital Government

300+
Integrated services
  • Absher platform
  • Unified authentication
  • Cloud infrastructure

🏙️ NEOM

100%
Smart city coverage
  • Edge computing
  • IoT everywhere
  • AI-driven services

☁️ Saudi Cloud

$10B
Investment by 2030
  • Data sovereignty
  • Regional hub
  • Green computing

Innovation Showcase

STC's cloud platform supports 15M users with 99.999% uptime.

💼 Your Distributed Systems Career Path

ميز

12-Month Roadmap to Excellence

Months 1-3: Foundation
  • Master Chapter 17 concepts
  • Docker basics (docker.com)
  • Build first distributed app
Months 4-6: Cloud Skills
  • AWS certification
  • Microservices architecture
  • API design patterns
Months 7-9: Real Experience
  • Internship (e.g., SDAIA.ai)
  • Open-source contribution
  • Build portfolio
Months 10-12: Leadership
  • Lead project
  • Present at conferences
  • Mentor juniors

Relationship Building

Network with Saudi tech leaders at Riyadh Season tech events.

Saudi Career Opportunities

Company Role Salary (SAR) Growth
NEOM Distributed Systems Engineer 350,000+ Extreme
Aramco Cloud Architect 320,000 Very High
STC Network Engineer 280,000 High
Al Rajhi Bank Backend Developer 250,000 High

🎓 Bridging University to Market

ميز

الجامعة تعلمك (University Teaches You)

  • كيف تفكر (How to think)
  • مبدأ الالتزام (Commitment)
  • الانضباط (Discipline)
  • تغيير القناعات (Changing convictions)
  • المسؤولية (Responsibility)
  • كيف تعلم نفسك (Self-learning)
  • التفكير الناقد (Critical thinking)
  • احترام العلماء (Respect for scholars)
  • احترام وجهات النظر (Respect for viewpoints)

السوق يعلمك (Market Teaches You)

  • النتائج أهم من الكلام (Results over words)
  • الوقت = فلوس (Time = money)
  • المخاطرة جزء من اللعبة (Risk is part of the game)
  • التعلم ما يوقف بعد التخرج (Learning never stops)
  • العلاقات تساوي رأس مال (Relationships equal capital)
  • الفشل مكلف لكنه معلم عظيم (Failure is costly but a great teacher)
  • التميز الحقيقي يظهر في التنفيذ لا في الأفكار (Excellence in execution)

University gives the intellectual framework: Research, critique, commit, build thinking basics.

Market tests results: Can you turn knowledge into tangible outcomes?

Bridge: University is theoretical → teaches tools. Market is applied → tests outputs.

Reality: University prepares you for the race; the market is the field where you prove you can run.

📝 Assignment: Design National System

ميز
Design a complete distributed system for Saudi Arabia's future

Choose ONE National Challenge:

  1. 🏥 Unified health records (30M citizens)
  2. 🎓 National education platform (6M students)
  3. 🚗 Smart traffic management (Riyadh)
  4. ⚡ National energy grid monitoring
  5. 🌾 Agricultural IoT network

Deliverables (EMAM Framework)

Phase Weight Requirements Rubric
افهم 20% Problem analysis, 6 design issues Clear analysis with Saudi examples – 10/20; Depth – 10/20
مارس 30% Client-server design, interaction model Practical design with code – 15/30; Feasibility – 15/30
اتقن 30% Architecture selection, implementation Pattern choice with trade-offs – 15/30; Production-ready – 15/30
ميز 20% SaaS model, Vision 2030 alignment Innovation (e.g., serverless) – 10/20; Saudi goals – 10/20

Submission Requirements

  • Due: Next week
  • Format: PDF + GitHub repo
  • Must include: 3+ nodes, scalability analysis
  • Bonus: 5-min video, AI integration (e.g., ML for traffic prediction)

AI Guidance for Bonus

Use TensorFlow (tensorflow.org) or PyTorch (pytorch.org) for ML integration. Example for traffic prediction in Master-Slave:

import tensorflow as tf
model = tf.keras.Sequential([
  tf.keras.layers.Dense(64, activation='relu', input_shape=(10,)),
  tf.keras.layers.Dense(1)
])
model.compile(optimizer='adam', loss='mse')
# Train on traffic data (e.g., sensor inputs)
# Use in TrafficMaster.analyzeTraffic()
Case Study: Aramco's pipeline failure in 2023 cost $10M due to poor scalability planning.

🎯 Key Takeaways - Chapter 17 Mastery

Summary: "Distributed systems enable resource sharing, openness, concurrency, scalability, and fault tolerance through various architectural patterns" (Coulouris et al., 2011)
🧠 Core Concepts

• Definition, benefits
• Design issues
• Security

💬 Communication

• RPC vs Messages
• Middleware
• Client-server

🗿 Architectures

• 5 patterns
• Trade-offs
• Selection criteria

☁️ Modern Trends

• SaaS, cloud
• Saudi context
• (Kleppmann, 2017)

Success Formula

Technical Excellence + Islamic Values + Saudi Vision + Global Standards = Your Impact

Self-Reflection Prompts

  • On a scale of 1-5, how confident are you in P2P architectures? Why?
  • Rate your EMAM mastery (1-5 each).
  • How will you apply university critical thinking to market execution?

🤝 Your Distributed Systems Commitment

إِنَّ اللَّهَ يُحِبُّ إِذَا عَمِلَ أَحَدُكُمْ عَمَلًا أَنْ يُتْقِنَهُ

"Allah loves when one of you does work, that they perfect it" - Hadith

(Transliteration: Inna Allāha yuḥibbu idhā ʿamila aḥadukum ʿamalan an yutqinahu)

Every system you build connects people, enables commerce, transforms society.
افهم

Foundation

Master the WHY

Understand complexity

مارس

Application

Build NOW

Code daily

Test patterns

اتقن

Excellence

Production quality

Scale thinking

ميز

Innovation

Lead change

Global impact

Serve millions

Reflection:

  • Which system will you build first?
  • How will it serve Vision 2030?
  • What pattern fits best?
  • How will you ensure reliability and scale?

🙏 شكرًا - Your Journey Begins Now

وَقُل رَّبِّ زِدْنِي عِلْمًا

"My Lord, increase me in knowledge" - Qur'an 20:114

Distributed systems knowledge evolves daily - keep learning!

You now understand how to build systems that connect the world
From local servers to global clouds - you're ready!
📧 Contact

Office Hours: By Email

Email: arnoor@kau.edu.sa

📅 Next Class

Chapter 20

System of the System

Monday, 2:30 PM

📝 Due Soon

Assignment

Next week

Start TODAY!

🎯 Resources

Blackboard

GitHub examples

Office hours

بروف: أديب بن رضا نور

See you next class, إن شاء الله
Remember: Your code will connect millions!