Distributed Systems Principles and Paradigms

Similar documents
殷亚凤. Processes. Distributed Systems [3]

Distributed Systems. Edited by. Ghada Ahmed, PhD. Fall (3rd Edition) Maarten van Steen and Tanenbaum

DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S. TANENBAUM MAARTEN VAN STEEN. Chapter 3 Processes

Verteilte Systeme (Distributed Systems)

Types of Virtualization. Types of virtualization

Distributed System: Definition

Distributed Systems Principles and Paradigms

Dr Markus Hagenbuchner CSCI319. Distributed Systems Chapter 3 - Processes

Distributed Information Processing

DISTRIBUTED COMPUTER SYSTEMS

Distributed Systems Principles and Paradigms. Chapter 01: Introduction. Contents. Distributed System: Definition.

Concepts of Distributed Systems 2006/2007

Distributed Systems Principles and Paradigms. Chapter 01: Introduction

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

CA464 Distributed Programming

Sprite (contd) Code and Process Migration

Chapter 4 Threads, SMP, and

Lecture 7: February 10

Chapter 3: Client-Server Paradigm and Middleware

OPERATING SYSTEM. Chapter 4: Threads

Distributed Object-Based Systems The WWW Architecture Web Services Handout 11 Part(a) EECS 591 Farnam Jahanian University of Michigan.

Chapter 4: Threads. Chapter 4: Threads. Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues

Distributed Systems Principles and Paradigms. Chapter 12: Distributed Web-Based Systems

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

Chapter 4: Threads. Chapter 4: Threads

CS533 Concepts of Operating Systems. Jonathan Walpole

OS Virtualization. Linux Containers (LXC)

Communication. Distributed Systems Santa Clara University 2016

Distributed Systems Principles and Paradigms

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4

A Survey on Virtualization Technologies

Threads, SMP, and Microkernels. Chapter 4

Chapter 4: Threads. Operating System Concepts 9 th Edit9on

Chapter 3 Process Description and Control

CHAPTER - 4 REMOTE COMMUNICATION

Threads SPL/2010 SPL/20 1

Operating System Support

Processes and Threads. Processes and Threads. Processes (2) Processes (1)

Middleware. Adapted from Alonso, Casati, Kuno, Machiraju Web Services Springer 2004

Processes in Distributed Systems

For use by students enrolled in #71251 CSE430 Fall 2012 at Arizona State University. Do not use if not enrolled.

Process Characteristics. Threads Chapter 4. Process Characteristics. Multithreading vs. Single threading

Threads Chapter 4. Reading: 4.1,4.4, 4.5

Distributed Systems Principles and Paradigms. Chapter 07: Consistency & Replication

Distributed Systems. Chapter 02

DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S. TANENBAUM MAARTEN VAN STEEN. Chapter 1. Introduction

Lecture 8: February 19

Chapter 4: Threads. Operating System Concepts 9 th Edition

Operating System. Chapter 4. Threads. Lynn Choi School of Electrical Engineering

Applications, services. Middleware. OS2 Processes, threads, Processes, threads, communication,... communication,... Platform

Processes in Distributed Systems

Threads. CS-3013 Operating Systems Hugh C. Lauer. CS-3013, C-Term 2012 Threads 1

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 22: Remote Procedure Call (RPC)

Operating Systems: Internals and Design Principles. Chapter 4 Threads Seventh Edition By William Stallings

PROCESSES AND THREADS THREADING MODELS. CS124 Operating Systems Winter , Lecture 8

Module 1: Virtualization. Types of Interfaces

Distributed Systems Principles and Paradigms

Distributed Systems Principles and Paradigms. Distributed Object-Based Systems. Remote distributed objects. Remote distributed objects

02 - Distributed Systems

Flash: an efficient and portable web server

Chapter 5: Threads. Outline

Chapter 4: Multi-Threaded Programming

CHAPTER 3 - PROCESS CONCEPT

Operating Systems (2INC0) 2018/19. Introduction (01) Dr. Tanir Ozcelebi. Courtesy of Prof. Dr. Johan Lukkien. System Architecture and Networking Group

Threads Chapter 5 1 Chapter 5

Distributed File Systems Issues. NFS (Network File System) AFS: Namespace. The Andrew File System (AFS) Operating Systems 11/19/2012 CSC 256/456 1

Distributed Systems. The main method of distributed object communication is with remote method invocation

Chapter 4: Threads. Operating System Concepts 9 th Edition

MCAP: Multiple Client Access Protocol Ravindra Singh Rathore SML College Jhunjhunu, Rajasthan India

Distributed Systems COMP 212. Lecture 18 Othon Michail

Four Components of a Computer System

Distributed Systems 8. Remote Procedure Calls

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads

Chapter 4: Multithreaded Programming

Cloud Computing CS

Today: Distributed Objects. Distributed Objects

02 - Distributed Systems

How do modules communicate? Enforcing modularity. Modularity: client-server organization. Tradeoffs of enforcing modularity

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

Remote Procedure Call

Lecture 5: Process Description and Control Multithreading Basics in Interprocess communication Introduction to multiprocessors

Operating System Services

CS 550 Operating Systems Spring Introduction to Virtual Machines

Chapter 5: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads

3.1 Introduction. Computers perform operations concurrently

Operating Systems. Operating System Structure. Lecture 2 Michael O Boyle

Distributed Systems Theory 4. Remote Procedure Call. October 17, 2008

Last Class: RPCs. Today:

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Questions answered in this lecture: CS 537 Lecture 19 Threads and Cooperation. What s in a process? Organizing a Process

! How is a thread different from a process? ! Why are threads useful? ! How can POSIX threads be useful?

Last time: introduction. Networks and Operating Systems ( ) Chapter 2: Processes. This time. General OS structure. The kernel is a program!

Operating Systems 2 nd semester 2016/2017. Chapter 4: Threads

Chapter 4 Communication

Advanced Distributed Systems

CS454/654 Midterm Exam Fall 2004

Lightweight Remote Procedure Call

Two Phase Commit Protocol. Distributed Systems. Remote Procedure Calls (RPC) Network & Distributed Operating Systems. Network OS.

Threads and Too Much Milk! CS439: Principles of Computer Systems February 6, 2019

Transcription:

Distributed Systems Principles and Paradigms Chapter 03 (version February 11, 2008) Maarten van Steen Vrije Universiteit Amsterdam, Faculty of Science Dept. Mathematics and Computer Science Room R4.20. Tel: (020) 598 7784 E-mail:steen@cs.vu.nl, URL: www.cs.vu.nl/ steen/ 01 Introduction 02 Architectures 03 Processes 04 Communication 05 Naming 06 Synchronization 07 Consistency and Replication 08 Fault Tolerance 09 Security 10 Distributed Object-Based Systems 11 Distributed File Systems 12 Distributed Web-Based Systems 13 Distributed Coordination-Based Systems 00 1 /

Introduction to Threads Basic idea: we build virtual processors in software, on top of physical processors: Processor: Provides a set of instructions along with the capability of automatically executing a series of those instructions. 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. Process: A software processor in whose context one or more threads may be executed. Executing a thread, means executing a series of instructions in the context of that thread. 03 1 Processes/3.1 Threads

Context Switching (1/2) Processor context: The minimal collection of values stored in the registers of a processor used for the execution of a series of instructions (e.g., stack pointer, addressing registers, program counter). Thread context: The minimal collection of values stored in registers and memory, used for the execution of a series of instructions (i.e., processor context, state). Process context: The minimal collection of values stored in registers and memory, used for the execution of a thread (i.e., thread context, but now also at least MMU register values). 03 2 Processes/3.1 Threads

Context Switching (2/2) Observation 1: Threads share the same address space. Thread context switching can be done entirely independent of the operating system. Observation 2: Process switching is generally more expensive as it involves getting the OS in the loop, i.e., trapping to the kernel. Observation 3: Creating and destroying threads is much cheaper than doing so for processes. 03 3 Processes/3.1 Threads

Threads and Operating Systems (1/2) Main issue: Should an OS kernel provide threads, or should they be implemented as user-level packages? User-space solution: We ll have nothing to do with the kernel, so all operations can be completely handled within a single process implementations can be extremely efficient. All services provided by the kernel are done on behalf of the process in which a thread resides if the kernel decides to block a thread, the entire process will be blocked. Requires messy solutions. In practice we want to use threads when there are lots of external events: threads block on a per-event basis if the kernel can t distinguish threads, how can it support signaling events to them. 03 4 Processes/3.1 Threads

Threads and Operating Systems (2/2) Kernel solution: The whole idea is to have the kernel contain the implementation of a thread package. This does mean that all operations return as system calls Operations that block a thread are no longer a problem: the kernel schedules another available thread within the same process. Handling external events is simple: the kernel (which catches all events) schedules the thread associated with the event. The big problem is the loss of efficiency due to the fact that each thread operation requires a trap to the kernel. Conclusion: Try to mix user-level and kernel-level threads into a single concept. 03 5 Processes/3.1 Threads

Solaris Threads (1/2) Basic idea: Introduce a two-level threading approach: lightweight processes that can execute user-level threads. Thread state User space Thread Kernel space Lightweight process LWP executing a thread 03 6 Processes/3.1 Threads

Solaris Threads (2/2) When a user-level thread does a system call, the LWP that is executing that thread, blocks. The thread remains bound to the LWP. The kernel can simply schedule another LWP having a runnable thread bound to it. Note that this thread can switch to any other runnable thread currently in user space. When a thread calls a blocking user-level operation, we can simply do a context switch to a runnable thread, which is then bound to the same LWP. When there are no threads to schedule, an LWP may remain idle, and may even be removed (destroyed) by the kernel. 03 7 Processes/3.1 Threads

Threads and Distributed Systems (1/2) Multithreaded clients: Main issue is 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 Multiple RPCs: A client does several RPCs at the same time, each one by a different thread It then waits until all results have been returned Note: if RPCs are to different servers, we may have a linear speed-up compared to doing RPCs one after the other 03 8 Processes/3.1 Threads

Threads and Distributed Systems (2/2) Multithreaded servers: Main issue is improved performance and better structure Improve performance: Starting a thread to handle an incoming request is much cheaper than starting a new process Having a single-threaded server prohibits simply scaling the server to a multiprocessor system As with clients: hide network latency by reacting to next request while previous one is being replied Better structure: Most servers have high I/O demands. Using simple, well-understood blocking calls simplifies the overall structure Multithreaded programs tend to be smaller and easier to understand due to simplified flow of control 03 9 Processes/3.1 Threads

Virtualization Observation: Virtualization is becoming increasingly important: Hardware changes faster than software Ease of portability and code migration Isolation of failing or attacked components Program Program Interface A Hardware/software system A Interface A Implementation of mimicking A on B Interface B Hardware/software system B (a) (b) 03 10 Processes/3.2 Virtualizaton

Architecture of VMs (1/2) Observation: Virtualization can take place at very different levels, strongly depending on the interfaces as offered by various systems components: Library functions System calls Privileged instructions Application Library Operating system Hardware General instructions 03 11 Processes/3.2 Virtualizaton

Architecture of VMs (2/2) Note: Make a distinction between (a) process virtual machines and (b) virtual machine monitors: Application Runtime system Runtime system Runtime system Applications Operating system Operating system Operating system Operating system Virtual machine monitor Hardware (a) Hardware (b) Process VM: A program is compiled to intermediate (portable) code, which is then executed by a runtime system (Example: Java VM). VMM: A separate software layer mimics the instruction set of hardware a complete operating system and its applications can be supported (Example: VMware). 03 12 Processes/3.2 Virtualizaton

Clients: User Interfaces Essence: A major part of client-side software is focused on (graphical) user interfaces. Application server Application server User's terminal Window manager Xlib Local OS Application Xlib Local OS Xlib interface X protocol X kernel Device drivers Terminal (includes display keyboard, mouse, etc.) Compound documents: User interface is applicationaware interapplication communication: drag-and-drop: move objects across the screen to invoke interaction with other applications in-place editing: integrate several applications at user-interface level (word processing + drawing facilities) 03 13 Processes/3.3 Clients

Client-Side Software Essence: Often tailored for distribution transparency access transparency: client-side stubs for RPCs location/migration transparency: let client-side software keep track of actual location replication transparency: multiple invocations handled by client stub: Client machine Server 1 Server 2 Server 3 Client appl. Server appl Server appl Server appl Client side handles request replication Replicated request failure transparency: can often be placed only at client (we re trying to mask server and communication failures). 03 14 Processes/3.3 Clients

Servers: General Organization Basic model: A server is a process that waits for incoming service requests at a specific transport address. In practice, there is a one-to-one mapping between a port and a service: ftp-data 20 File Transfer [Default Data] ftp 21 File Transfer [Control] telnet 23 Telnet 24 any private mail system smtp 25 Simple Mail Transfer login 49 Login Host Protocol sunrpc 111 SUN RPC (portmapper) courier 530 Xerox RPC Superservers: Servers that listen to several ports, i.e., provide several independent services. In practice, when a service request comes in, they start a subprocess to handle the request (UNIX inetd) Iterative vs. concurrent servers: Iterative servers can handle only one client at a time, in contrast to concurrent servers 03 15 Processes/3.4 Servers

Out-of-Band Communication Issue: Is it possible to interrupt a server once it has accepted (or is in the process of accepting) a service request? Solution 1: Use a separate port for urgent data (possibly per service request): Server has a separate thread (or process) waiting for incoming urgent messages When urgent message comes in, associated request is put on hold Note: we require OS supports high-priority scheduling of specific threads or processes Solution 2: Use out-of-band communication facilities of the transport layer: Example: TCP allows to send urgent messages in the same connection Urgent messages can be caught using OS signaling techniques 03 16 Processes/3.4 Servers

Servers and State (1/2) Stateless servers: Never keep accurate information about the status of a client after having handled a request: Don t record whether a file has been opened (simply close it again after access) Don t promise to invalidate a client s cache Don t keep track of your clients 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 (think of prefetching file blocks) Question: Does connection-oriented communication fit into a stateless design? 03 17 Processes/3.4 Servers

Servers and State (2/2) 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 Observation: The performance of stateful servers can be extremely high, provided clients are allowed to keep local copies. As it turns out, reliability is not a major problem. 03 18 Processes/3.4 Servers

Server Clusters Observation: Many server clusters are organized along three different tiers: Logical switch (possibly multiple) Application/compute servers Distributed file/database system Client requests Dispatched request First tier Second tier Third tier Crucial element: The first tier is generally responsible for passing requests to an appropriate server. 03 19 Processes/3.4 Servers

Request Handling Observation: Having the first tier handle all communication from/to the cluster may lead to a bottleneck. Solution: Various, but one popular one is TCP-handoff: Logically a single TCP connection Response Server Client Request Switch Request (handed off) Server 03 20 Processes/3.4 Servers

Example: PlanetLab Essence: Different organizations contribute machines, which they subsequently share for various experiments. User-assigned virtual machines Priviliged management virtual machines Process... Process Process... Process Process... Process Process... Process Process... Process Vserver Vserver Vserver Vserver Vserver Linux enhanced operating system Hardware Problem: We need to ensure that different distributed applications do not get into each other s way virtualization: Vserver: Independent and protected environment with its own libraries, server versions, and so on. Distributed applications are assigned a collection of vservers distributed across multiple machines (slice). 03 21 Processes/3.4 Servers

Code Migration Approaches to code migration Migration and local resources Migration in heterogeneous systems 03 22 Processes/3.5 Code Migration

Code Migration: Some Context BEFORE EXECUTION AFTER EXECUTION CLIENT SERVER CLIENT SERVER CS code state resource code state* resource REV code state resource code state* resource CoD state resource code code state* resource MA code state resource resource resource code state* resource CS: Client-Server CoD: Code-on-demand REV: Remote evaluation MA: Mobile agents 03 23 Processes/3.5 Code Migration

Strong and Weak Mobility Object components: Code segment: contains the actual code Data segment: contains the state Execution state: contains context of thread executing the object s code Weak mobility: Move only code and data segment (and start execution from the beginning) after migration: Relatively simple, especially if code is portable Distinguish code shipping (push) from code fetching (pull) Strong mobility: Move component, including execution state Migration: move the entire object from one machine to the other Cloning: simply start a clone, and set it in the same execution state. 03 24 Processes/3.5 Code Migration

Managing Local Resources (1/2) Problem: An object uses local resources that may or may not be available at the target site. Resource types: Fixed: the resource cannot be migrated, such as local hardware Fastened: the resource can, in principle, be migrated but only at high cost Unattached: the resource can easily be moved along with the object (e.g. a cache) Object-to-resource binding: By identifier: the object requires a specific instance of a resource (e.g. a specific database) By value: the object requires the value of a resource (e.g. the set of cache entries) By type: the object requires that only a type of resource is available (e.g. a color monitor) 03 25 Processes/3.5 Code Migration

Managing Local Resources (2/2) Unattached Fastened Fixed ID MV (or GR) GR (or MV) GR Value CP (or MV, GR) GR (or CP) GR Type RB (or MV, GR) RB (or GR, CP) RB (or GR) GR = Establish global systemwide reference MV = Move the resource CP = Copy the value of the resource RB = Re-bind to a locally available resource 03 26 Processes/3.5 Code Migration

Migration in Heterogenous Systems Main problem: 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 Only solution: Make use of an abstract machine that is implemented on different platforms Current solutions: Interpreted languages running on a virtual machine (Java/JVM; scripting languages) Virtual machine monitors, allowing migration of complete OS + apps. 03 27 Processes/3.5 Code Migration