Presentation is loading. Please wait.

Presentation is loading. Please wait.

EEC-681/781 Distributed Computing Systems Lecture 8 Wenbing Zhao Cleveland State University.

Similar presentations


Presentation on theme: "EEC-681/781 Distributed Computing Systems Lecture 8 Wenbing Zhao Cleveland State University."— Presentation transcript:

1 EEC-681/781 Distributed Computing Systems Lecture 8 Wenbing Zhao wenbing@ieee.org Cleveland State University

2 2 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Outline Midterm#1 results Processes and threads Clients and Servers

3 3 Midterm #1 Result Score distribution: 96, 92, 92, 88, 88 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao

4 4 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Process Communication takes place between processes Process is a program in execution For an OS, process management and scheduling are most important For distributed systems, other issues are equally or more important –Multithreading –Client-Server organization –Code migration –Software agent

5 5 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Process An operating system creates a number of virtual processors, each one for running a different program To keep track of these virtual processors, OS maintains a process table –CPU register values, memory maps, open files, accounting info, privileges, etc.

6 6 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Process OS ensures concurrency transparency for different processes that share the same CPU and other hardware resources Each process has its own address space Switch CPU between two processes is expensive –CPU context, modify registers for memory management unit (MMU), invalidate address translation caches such as in the translation lookaside buffer (TLB)

7 7 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Motivation to Use a Finer Granularity It is hard to program a single threaded process for efficient distributed computing –Difficult to use non-blocking system calls Could have used a pool of processes, but –Creation/deletion of a process is expensive –Inter-process communication (IPC) is expensive

8 8 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Introduction to Threads Thread: A minimal software processor in whose context a series of instructions can be executed Saving a thread context implies stopping the current execution and saving all the data needed to continue the execution at a later stage A process can have one or more threads Threads share the same address space. => Thread context switching can be done entirely independent of the operating system

9 9 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Context Switching Creating and destroying threads is much cheaper than doing so for processes Process switching is generally more expensive as it involves getting the OS in the loop, i.e., trapping to the kernel

10 10 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Threads and Distributed Systems Multithreaded clients: –Hiding network latency Multithreaded servers: –Improved performance and –Better structure

11 11 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Multithreaded Clients Multithreaded clients: hiding network latency Multithreaded Web client: –Web browser scans an incoming HTML page, and finds that more files need to be fetched –Each file is fetched by a separate thread, each doing a (blocking) HTTP request –As files come in, the browser displays them

12 12 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Multithreaded Servers Improve performance: –Starting a thread to handle an incoming request is much cheaper than starting a new process –Multi-threaded server can scale well to a multiprocessor system –Hide network latency by reacting to next request while previous one is being replied

13 13 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Multithreaded Servers Better server structure: –Using simple, well-understood blocking calls simplifies the overall structure –Multithreaded programs can be smaller and easier to understand due to simplified flow of control

14 14 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Multithreaded Servers Dispatcher/worker model –Thread-per-object –Thread-per-request –Thread-per-client –Thread pool

15 15 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Multithreaded Servers Three ways to construct a server: ModelCharacteristics ThreadsParallelism, blocking system calls Single-threaded processNo parallelism, blocking system calls Finite-state machineParallelism, nonblocking system calls

16 16 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Client-Side Software User interface –X-window system –Model-View-Controller Pattern Providing distribution transparency

17 17 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao The X-Window System

18 18 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao The X-Window System X distinguishes two types of applications –Normal application Can request creation of a window Mouse and keystroke events are captured when a window is active –X windows manager Given special permission to manipulate the entire screen Determines the look and feel X applications and X kernel interacts through an X protocol –Supports Unix and TCP/IP sockets –X terminals

19 19 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Model-View-Controller Pattern Invented in a Smalltalk context for decoupling the graphical interface of an application from the code that actually does the work MVC was originally developed to map the traditional input, processing, output roles into the GUI realm: Input --> Processing --> Output Controller --> Model --> View

20 20 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Model-View-Controller Model - manages one or more data elements, responds to queries about its state, and responds to instructions to change state View - responsible for mapping graphics onto a device. Multiple views might be attached to the same model Controller - responsible for mapping end-user action to application response

21 21 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Model-View-Controller

22 22 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Client-Side Software: Providing Distribution Transparency Access transparency: client-side stubs for RPCs and RMIs Location/migration transparency: let client-side software keep track of actual location Replication transparency: multiple invocations handled by client stub Failure transparency: mask server and communication failures

23 23 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Server-Side Software Basic model: A server is a process that waits for incoming service requests at a specific transport address A server typically listens on a well-known port: ftp-data 20 File Transfer [Default Data] ftp 21 File Transfer [Control] ssh 22 Secure Shell telnet 23 Telnet smtp 25 Simple Mail Transfer

24 24 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Server-Side Software Superservers: Servers that listen to several ports, i.e., provide several independent services –When a service request comes in, they start a subprocess to handle the request

25 25 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Server-Side Software Iterative vs. concurrent servers: –Iterative servers can handle only one client at a time –Concurrent servers can handle multiple clients at the same time

26 26 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Servers and State Stateless servers: Never keep accurate information about the status of a client after having handled a request Consequences: –Clients and servers are completely independent –State inconsistencies due to client or server crashes are reduced –Possible loss of performance because, e.g., a server cannot anticipate client behavior Question: Does connection-oriented communication fit into a stateless design?

27 27 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Servers and State Stateful servers: Keeps track of the status of its clients –Record that a file has been opened, so that prefetching can be done –Knows which data a client has cached, and allows clients to keep local copies of shared data The performance of stateful servers can be extremely high (from a particular client’s point of view) Drawback –Crash recovery a lot more challenging –Less scalable

28 28 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Practical Implementation of Servers Servers need to maintain clients state Where to store such state? Database systems Solution – three-tier architecture –Application servers interface directly to clients and execute according to business logic –Data (state) is stored in the data access tier so that the application servers can be made stateless –E.g., Web-page personalization using cookies

29 29 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Reasons for Migrating Code Load balancing –Migrate processes from heavy loaded machine to light loaded machines Minimize communication –Move code from client to server –Move code from server to client Parallel execution –Web crawlers Flexibility –Dynamically configure distributed systems

30 30 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Strong and Weak Mobility Process components: –Code segment: set of instructions that make up the program –Resource/data segment: contains references to external resources needed by the process, such as files, devices, other processes –Execution segment: contains the current execution state of a process such as private data, stack, program counter

31 31 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Strong and Weak Mobility Weak mobility: Move only code and data segment (and start execution from the beginning) after migration Strong mobility: Move component, including execution state –Migration: move entire process from one machine to another –Cloning: start a clone, and set it in the same execution state

32 32 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Process-to-Resource Binding By identifier: the process requires a specific instance of a resource –A specific web page or a remote file –local communication endpoint By value: the process requires the value of a resource –Shared library –Memory By type: the process requires that only a type of resource is available –A color monitor –A printer

33 33 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Resource-to-Machine Binding Fixed: the resource cannot be migrated –Local devices –local communication endpoints Fastened: the resource can, in principle, be migrated but only at high cost –Local databases –complete web site Unattached: the resource can easily be moved along with the process –A cache –Files

34 34 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Migration in Heterogeneous Systems Challenges: –The target machine may not be suitable to execute the migrated code –The definition of process/thread/processor context is highly dependent on local hardware, operating system and runtime system Solution: Make use of an abstract machine that is implemented on different platforms –Interpreted languages running on a virtual machine (Java/JVM; scripting languages) –Virtual machine

35 35 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao What’s an Agent? An agent is an autonomous process capable of reacting to, and initiating changes in its environment, possibly in collaboration with users and other agents –collaborative agent: collaborate with others in a multiagent system –mobile agent: can move between machines –interface agent: assist users at user-interface level –information agent: manage information from physically different sources

36 36 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Agent Technology The general model of an agent platform Management: Keeps track of where the agents on this platform are (mapping agent ID to port) Directory: Mapping of agent names & attributes to agent IDs ACC: Agent Communication Channel, used to communicate with other platforms Intra-platform communication


Download ppt "EEC-681/781 Distributed Computing Systems Lecture 8 Wenbing Zhao Cleveland State University."

Similar presentations


Ads by Google