0% found this document useful (0 votes)
87 views

Chapter 3 Distributed System

Uploaded by

bayisabayesa14
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views

Chapter 3 Distributed System

Uploaded by

bayisabayesa14
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Chapter three

Process
process
• A process refers to a program or application that is running
on a computer and is capable of executing tasks or
operations.
A process in a distributed system is a program that is
currently being executed on a virtual processor of an
operating system.
In a distributed system, a task is broken down into functions
and spread across multiple interconnected processors.
Each processor, or node, operates independently but
collectively solves the task.
• In a distributed system, these processes need to
communicate with each other to share data, coordinate
activities, and perform complex tasks that require
collaboration across multiple systems.
Process Management
 In a system, process management becomes a crucial
part of maintaining & monitoring the overall system.

 Process management in distributed systems involves


coordinating tasks across multiple interconnected nodes.
 While the operating system is essential for managing
processes on individual nodes, managing trade and
processes in a distributed system requires a combination
of technologies, practices, and roles that extend beyond
the OS itself.
 Effective management involves collaboration across
various components and stakeholders to ensure
efficiency, security, and reliability.
Importance of Process
Management:
 Resource Utilization: Effective process
management optimizes resource allocation,
ensuring that computing resources such as CPU,
memory, and storage are utilized efficiently
across distributed nodes.
– This improves system performance and
responsiveness.
 Task Coordination: Process management
coordinates the execution of tasks or processes
across distributed nodes, facilitating concurrent
operations and ensuring that tasks are executed
in a synchronized manner when required.
Cont...
• Scalability: In distributed systems, scalability is
critical for handling increasing workloads and
adapting to changing demands.
• Process management mechanisms enable the system
to scale by efficiently distributing tasks among nodes
and dynamically allocating resources as needed.
• Fault Tolerance: Distributed systems are
susceptible to node failures or network disruptions.
• Process management includes mechanisms for fault
detection, recovery, and resilience, ensuring
uninterrupted operation and maintaining data
integrity despite failures.
Foundation of Process
Management:
1. Process creation and termination
• Creation:
– When the program moves from secondary memory to main
memory, it becomes a process and that’s when the real procedure
starts.
– In the context of Distributed System, the initialization of process
can be done by one of the node in the system, user’s request , or
required as dependency by other system’s component, forked() by
other processes as a part of some bigger functionality.
• Termination:
– A process can be terminated either voluntarily or involuntarily by
one of the node in the run-time environment.
– The voluntary termination is done when the process has completed
its task and the process might be terminated by the OS if its
consuming resources beyond a certain criteria set by the
distributed system.
Threads
 In distributed systems, threads are the smallest
units of execution within a process.
 Is a sequential flow of tasks within a process.
 They share process resources, making them
efficient for handling multiple operations
simultaneously, such as client requests or data
processing.
 There can be multiple threads in a single process
having the same or different functionality.
 Let us take an example of a human body. A
human body has different parts having different
functionalities which are working parallelly
( Eg: Eyes, ears, hands, etc).
Thread Management in
Distributed Systems
• Thread management in distributed systems
is crucial for ensuring efficient execution,
resource utilization, and system stability.
key aspects and strategies for effective
thread management:
• Thread Creation and Destruction:
Overhead associated with creating and
destroying threads can be mitigate using
thread pools, which reuse a fixed number of
threads for executing tasks.
Cont...
• Synchronization Mechanisms: Proper
synchronization is necessary to avoid race
conditions, deadlocks, and other concurrency
issues.
– Techniques include locks, semaphores, barriers,
and condition variables to coordinate thread
actions and access to shared resources.
• Load Balancing: Distributing workloads
evenly across threads and nodes prevents
bottlenecks and ensures optimal resource
utilization.
Cont...
• Resource Allocation: Allocating CPU time,
memory, and other resources effectively to
threads prevents contention and ensures fair
usage.
– Mechanisms like priority scheduling and quotas
help manage resource distribution.
• Communication: Threads in different nodes
need efficient communication mechanisms.
– Using message passing, remote procedure calls
(RPCs), or distributed shared memory can facilitate
interaction between threads across the distributed
system.
Cont...
• Scalability: Ensuring that the system can handle
an increasing number of threads without
degradation in performance is crucial.
• This involves optimizing thread management
algorithms and infrastructure to support scalability.
• Monitoring and Debugging: Tools for monitoring
thread activity and debugging issues are vital.
• Profiling tools, logging, and visualization can help
identify performance bottlenecks and concurrency
issues.
Synchronization
• Synchronization in distributed systems is critical to
ensure that threads coordinate properly and avoid
conflicts, especially when accessing shared resources.
key synchronization techniques used in thread
management for distributed systems:
• Locks and Mutexes:
– Locks: Ensure that only one thread can access a resource
at a time.
– Distributed locks can be implemented using coordination
services like Zookeeper.
– Mutexes: A mutual exclusion object that allows only one
thread to hold the lock at a time, ensuring serialized
access to resources.
Cont...
• Semaphores:
– are synchronization primitives used to manage access
to shared resources by multiple processes or threads.
– They are primarily utilized in concurrent programming
to avoid race conditions, ensure mutual exclusion,
and coordinate tasks.
– Counting semaphores control access to a resource that
supports a limited number of concurrent accesses.
• What is race conditions???
– is a situation in concurrent programming where the
behaviour of a software system depends on the relative
timing of events, such as the order in which threads or
processes execute.
Cont...

• Race conditions typically arise in scenarios where


multiple threads or processes perform operations
that read from and write to shared data.
• If the timing of these operations is not controlled,
the final state of the shared data may be
inconsistent or unexpected.
• Race conditions can lead to unpredictable
behaviour, bugs, and security vulnerabilities,
particularly when multiple threads or processes
access shared resources without proper
synchronization.
Cont....
• Consider a simple banking scenario where two
threads attempt to update the balance of a
shared bank account:
• Initial State:
• Account balance: $100
• Thread A:
• Reads the balance ($100).
• Adds $50.
• Writes the new balance ($150).
• Thread B:
• Reads the balance ($100).
• Subtracts $30.
• Writes the new balance ($70).
Cont...
 If these threads execute concurrently without
synchronization, the final balance may be
incorrect, resulting in a race condition.
 Depending on the timing, the final balance could
end up being either $150 or $70, rather than the
expected $120.

So a race condition is a significant problem in


distributed systems and concurrent
programming.
It occurs when two or more processes or threads
access shared resources simultaneously, and the
outcome of the execution depends on the timing
of their execution.
Communication and Coordination
between threads
• Communication and coordination between threads in
distributed systems are crucial for ensuring that
tasks are performed efficiently and correctly.
Primary methods and techniques used for thread
communication and coordination :
Communication Mechanisms
• Message Passing:
– Synchronous Messaging: Threads send and receive
messages directly.
– The sender waits for the receiver to acknowledge the
receipt of the message.
– This ensures that messages are received in order and
processed correctly.
Cont...
• Remote Procedure Calls (RPCs):
– RPCs allow threads to invoke methods on remote nodes as if
they were local.
– is a software protocol that allows a program to request a service
from another program on a different computer or network.
– RPCs are used to build distributed systems and enable programs
to work with remote procedures as if they were local.
• Shared Memory:
– is a method of inter-process communication (IPC) that allows multiple
processes to access the same segment of memory.
– This technique enables fast data exchange and synchronization between
processes, making it a powerful tool in concurrent programming.
– Distributed Shared Memory (DSM) systems allow threads on different nodes
to access a common memory space.
– DSM abstracts the physical separation of memory, providing a unified view
and ensuring consistency through synchronization protocols.
Challenges with threads in Distributed
Systems....

Threads offer significant benefits in distributed


systems, such as improving performance and
enabling concurrent task execution.
 However, they also present several
challenges:
 Synchronization Issues: Managing access to
shared resources across multiple threads can
lead to race conditions, deadlocks, and other
synchronization problems.
 Ensuring proper coordination and data
consistency is complex.
Challenges with threads in Distributed
Systems...

• Resource Management: Threads require


memory and CPU resources.
– Efficiently managing these resources to prevent
contention and ensure fair usage is challenging,
especially in a distributed environment with
varying loads.
 Communication Overhead: threads on different
nodes need to communicate, which can introduce
latency and increase the complexity of the system.
– Efficiently managing this communication is
critical to maintaining performance.
Challenges with threads in Distributed
Systems...
• Scalability: the ability of a system to handle an
increasing amount of work .
– While threads can improve performance, they can
also lead to scalability issues.
– Too many threads can overwhelm the system,
causing context-switching overhead and reduced
performance.
• Security Concerns:
– Threads sharing the same memory space pose
security risks, as one thread can potentially access
the data of another thread.
– Ensuring secure data handling and access control is
crucial.
Client-Server Model in distributed
system
 The Client-server model is a distributed application
structure that partitions tasks or workloads between
the providers of a resource or service, called
servers, and service requesters called clients.
 In the client-server architecture, when the client
computer sends a request for data to the server
through the internet, the server accepts the
requested process and delivers the data packets
requested back to the client.
 Clients do not share any of their resources.
 Examples of the Client-Server Model are Email,
World Wide Web, etc.
Cont...
 Client:
– In the digital world, a Client is a computer
(Host) i.e. capable of receiving information or
using a particular service from the service
providers (Servers).
 Servers:
– A Server is a remote computer that provides
information (data) or access to particular
services.
– So, the Client requesting something and
the Server serving it as long as it is in the
database.
Cont...
How the Browser Interacts With
the Servers?
 User enters the URL of the website or file.
– The Browser then requests the DNS Server.
– DNS Server lookup for the address of
the WEB Server.
– The DNS Server responds with the IP
address of the WEB Server.
 The Browser sends over an HTTP/HTTPS request
to the WEB Server’s IP (provided by the DNS
server).
– The Server sends over the necessary files for
the website.
– The Browser then render the files and the
website is displayed.
Cont..
Code Migration
• Refers to the process of moving executable code
from one location to another within a distributed
system.
• This can involve transferring code between
different machines, nodes, or environments,
allowing for dynamic execution and resource
optimization.
• The concept is particularly relevant in scenarios
where applications need to adapt to changing
conditions, such as load balancing, fault
tolerance, and resource management.
Code Migration

 In simpler terms, it’s like moving your belongings


from one house to another.
 In distributed systems, where different parts of a
software application run on separate computers or
servers, code migration is vital for managing and
updating the system.
• There are three types of code migration, :
– Moving from one version of a language to
another version.
– Moving from the current language to the target
language.
– Moving from one operating system to another.
Need for Code Migration

Code migration is essential in distributed systems


for several reasons:
 Resource Optimization:
• By migrating code to less loaded nodes, distributed
systems can balance the workload, making efficient use
of available resources and improving throughput.
 System Maintenance and Updates: Facilitates
seamless deployment of updates, ensuring
applications remain functional.
 Scaling: Enables dynamic resource allocation to
handle increased traffic and workload demands.
 Fault Tolerance and Resilience: Aids in quick
recovery from failures by migrating code to
ensure continuity of service.
Cont...
Example of Code Migration
 Imagine you have a large software application spread across
multiple servers.
 Now, let’s say you need to update some parts of this
application or move it to a different server for better
performance.
 This is where code migration comes into play.
• It enables you to transfer the necessary code seamlessly,
ensuring that the application continues to function without
interruptions.
• In essence, code migration allows for the flexible and
efficient management of software in distributed systems,
facilitating tasks such as load balancing, resource
optimization, and system updates.
The End

You might also like