Today’s topic Other server design alternatives –Preforked servers –Threaded servers –Prethreaded servers.

Slides:



Advertisements
Similar presentations
Nonblocking I/O Blocking vs. non-blocking I/O
Advertisements

Socket Programming. Basics Socket is an interface between application and network – Application creates a socket – Socket type dictates the style of communication.
Flash: An efficient and portable Web server Authors: Vivek S. Pai, Peter Druschel, Willy Zwaenepoel Presented at the Usenix Technical Conference, June.
Today’s topic Issues about sending structures with TCP. Server design alternatives: concurrent server and multiplexed server. I/O multiplexing.
Threads Section 2.2. Introduction to threads A thread (of execution) is a light-weight process –Threads reside within processes. –They share one address.
Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write) Receive.
1 Processes Professor Jennifer Rexford
1 Processes and Pipes COS 217 Professor Jennifer Rexford.
1 Processes and Pipes. 2 "He was below me. I saw his markings, manoeuvred myself behind him and shot him down. If I had known it was Saint-Exupery, I.
Precept 3 COS 461. Concurrency is Useful Multi Processor/Core Multiple Inputs Don’t wait on slow devices.
1 Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write)
Server Architecture Models Operating Systems Hebrew University Spring 2004.
1 Data Communications and Networking Socket Programming Part II: Design of Server Software Reference: Internetworking with TCP/IP, Volume III Client-Server.
CS 311 – Lecture 18 Outline IPC via Sockets – Server side socket() bind() accept() listen() – Client side connect() Lecture 181CS Operating Systems.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
Concurrent vs. iterative servers
Real-Time Kernels and Operating Systems. Operating System: Software that coordinates multiple tasks in processor, including peripheral interfacing Types.
Client Server Design Alternatives© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L22 (Chapter 25) Networking.
1 CSE544 Database Architecture Tuesday, February 1 st, 2011 Slides courtesy of Magda Balazinska.
CS252: Systems Programming Ninghui Li Final Exam Review.
Programming Network Servers Topic 6, Chapters 21, 22 Network Programming Kansas State University at Salina.
Elementary TCP Sockets
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Threads and Processes.
Server Sockets: A server socket listens on a given port Many different clients may be connecting to that port Ideally, you would like a separate file descriptor.
Chapter 2 (PART 1) Light-Weight Process (Threads) Department of Computer Science Southern Illinois University Edwardsville Summer, 2004 Dr. Hiroshi Fujinoki.
Operating Systems Recitation 9, May 19-20, Iterative server Handle one connection request at a time. Connection requests stored in queue associated.
Processes and Threads CS550 Operating Systems. Processes and Threads These exist only at execution time They have fast state changes -> in memory and.
Rapid Development of High Performance Servers Khaled ElMeleegy Alan Cox Willy Zwaenepoel.
Today’s topic Pthread Some materials and figures are obtained from the POSIX threads Programming tutorial at
Background: I/O Concurrency Brad Karp UCL Computer Science CS GZ03 / M030 2 nd October, 2008.
Review: How to create a TCP end point? What is the right format for sin_port and sin_addr in the sockaddr_in data structure? How many different ways we.
Background: Operating Systems Brad Karp UCL Computer Science CS GZ03 / M th November, 2008.
1 COMP/ELEC 429/556 Introduction to Computer Networks Creating a Network Application Some slides used with permissions from Edward W. Knightly, T. S. Eugene.
Laboratory - 4.  Threading Concept  Threading in.NET  Multi-Threaded Socket  Example.
Distributed Computing A Programmer’s Perspective.
CE Operating Systems Lecture 13 Linux/Unix interprocess communication.
Processes CSCI 4534 Chapter 4. Introduction Early computer systems allowed one program to be executed at a time –The program had complete control of the.
Threads Chapter 26. Threads Light-weight processes Each process can have multiple threads of concurrent control. What’s wrong with processes? fork() is.
Project 2: Socket Programming. Overview Sockets Working with sockets Client-Server example Project 1 Hints.
Lecture 5: Threads process as a unit of scheduling and a unit of resource allocation processes vs. threads what to program with threads why use threads.
Concurrency & Context Switching Process Control Block What's in it and why? How is it used? Who sees it? 5 State Process Model State Labels. Causes of.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
The Client-Server Model And the Socket API. Client-Server (1) The datagram service does not require cooperation between the peer applications but such.
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl1 1 Chapter 15 Application Layer and Client-Server.
Single Process, Concurrent, Connection-Oriented Servers (TCP) (Chapter 12)
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Processes & Threads Introduction to Operating Systems: Module 5.
Review: –Concurrent server and multiplexed server How they work? Which one is better?
Threads. Readings r Silberschatz et al : Chapter 4.
Goals for Today How do we provide multiprogramming? What are Processes? How are they related to Threads and Address Spaces? Note: Some slides and/or pictures.
Code Development for High Performance Servers Topics Multithreaded Servers Event Driven Servers Example - Game Server code (Quake) A parallelization exercise.
Inter-Process Communication 9.1 Unix Sockets You may regard a socket as being a communication endpoint. –For two processes to communicate, both must create.
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl1 1 Chapter 16 Socket Interface.
Netprog: Client/Server Issues1 Issues in Client/Server Programming Refs: Chapter 27.
Major OS Components CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
Multithreading vs. Event Driven in Code Development of High Performance Servers.
ECE 297 Concurrent Servers Process, fork & threads ECE 297.
1 Issues in Client/Server Refs: Chapter 27 Case Studies RFCs.
Concurrent vs. iterative servers
Advanced Network Programming spring 2007
Issues in Client/Server Programming
Advanced UNIX programming
CSE 333 – Section 10 Final Review.
Concurrency: Processes CSE 333 Summer 2018
Concurrency and Processes CSE 333 Spring 2018
Concurrency: Processes CSE 333 Autumn 2018
Process Management -Compiled for CSIT
Concurrency: Processes CSE 333 Winter 2019
Presentation transcript:

Today’s topic Other server design alternatives –Preforked servers –Threaded servers –Prethreaded servers

Sequential server socket() bind() listen() accept() read() write() read()close() Handle one connection at a time

socket() bind() listen() accept() read() write() read()close() socket() bind() listen() Loop forever accept() fork Close accepted socket Close listen socket read() write() read()close() Sequential server Concurrent server (example2.c)

socket() bind() listen() Loop forever select If listen socket is active  accept, book keeping If data socket is active: read/write If read returns 0, close the socket, book keeping If standard input is active: act accordingly Multiplexed server

Multiplexed server (example4.c): –Multiplexed server/concurrent server: which one is more efficient? –Can we have the best of both worlds?

Preforked server: –Main limitation with the concurrent server fork overheads. Is context switching a big problem? Removing the fork overheads –Pre-fork N processes and use them forever.

socket() bind() listen() accept() read() write() close() Sequential server Prefork server (example5.c) socket() bind() listen() N Fork()’s accept() write() close() read() accept() write() close() read()

Preforked Servers Accept: It extracts the first connection request on the queue of pending connections, creates a new connected socket, and returns a new file descriptor referring to that socket. The newly created socket is not in the listening state. The original socket sockfd is unaffected by this call. Only one will return!!

Preforked server: –Disadvantages Not easy to guess the “right” number of child processes. –Comparison to other server implementation techniques: Single CPU, multiple CPU’s –Concurrent, multiplex, and prefork are building blocks for server implementation. One can use a combination of techniques. E.g. pre-fork N multiplexed servers.

IO multiplexing with threads –IO mutiplexing at the process level requires the select call. –Multi-threading can achieve the same effect Idea: use one thread to process one input stream Multiplexing is implicit at the systems level –See echo_client_thread.cpp getaddrinfo – a network address and service translation method.

Threaded Server Limitations with process-based concurrent servers Fork is expensive Inter-process communications are hard –Threads Lightweight process Crashing one thread will kill all program –See echo_server_thread.cpp Not robust implemented like concurrent server. Can share data structures

Prethreaded Servers A number of threads are precreated to handle clients –Only one thread can be blocked on accept() –Access to accept () controlled by a mutex –See echo_server_prethread.cpp