Software Engineering and Architecture

Slides:



Advertisements
Similar presentations
Categories of I/O Devices
Advertisements

CS 443 Advanced OS Fabián E. Bustamante, Spring 2005 Resource Containers: A new Facility for Resource Management in Server Systems G. Banga, P. Druschel,
Server Architecture Models Operating Systems Hebrew University Spring 2004.
Client Server Design Alternatives© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid.
1 Thread Pools. 2 What’s A Thread Pool? A programming technique which we will use. A collection of threads that are created once (e.g. when server starts).
SEDA: An Architecture for Well-Conditioned, Scalable Internet Services
SEDA: An Architecture for Well-Conditioned, Scalable Internet Services
LOGO OPERATING SYSTEM Dalia AL-Dabbagh
Operating System Review September 10, 2012Introduction to Computer Security ©2004 Matt Bishop Slide #1-1.
CS 1308 Computer Literacy and the Internet. Introduction  Von Neumann computer  “Naked machine”  Hardware without any helpful user-oriented features.
Today’s topic Other server design alternatives –Preforked servers –Threaded servers –Prethreaded servers.
Introduction to Threads CS240 Programming in C. Introduction to Threads A thread is a path execution By default, a C/C++ program has one thread called.
CHEN Ge CSIS, HKU March 9, Jigsaw W3C’s Java Web Server.
Chapter 2 (PART 1) Light-Weight Process (Threads) Department of Computer Science Southern Illinois University Edwardsville Summer, 2004 Dr. Hiroshi Fujinoki.
Multi-Threaded Application CSNB534 Asma Shakil. Overview Software applications employ a strategy called multi- threaded programming to split tasks into.
1 (Worker Queues) cs What is a Thread Pool? A collection of threads that are created once (e.g. when a server starts) That is, no need to create.
1 Rick Mercer Multi Threaded Chat Server. 2 Client – Server with Socket Connections We've seen how to establish a connection with 1 client Review a simple.
Multithreaded Programing. Outline Overview of threads Threads Multithreaded Models  Many-to-One  One-to-One  Many-to-Many Thread Libraries  Pthread.
Department of Computer Science and Software Engineering
Threads. Readings r Silberschatz et al : Chapter 4.
CSE 434: Computer Networks Project Single vs. Per Connection vs. Pooling Threading Techniques Dominic Hilsbos, Dorothy Johnson, Chris Volpe, Andy Wong,
Introduce Concurrency Threading in Servers. A Recurring Theme Concurrent programming is not for the weak hearted! –Deadlocks, blocked threads, critical.
Threads Overview Benefits, User and Kernel Threads.
Cloud Computing and Architecuture
Node.Js Server Side Javascript
Software Architecture in Practice
Thread Pools (Worker Queues) cs
Threads vs. Events SEDA – An Event Model 5204 – Operating Systems.
Scalability: Load Balancing
Thread Pools (Worker Queues) cs
Processes and Threads Processes and their scheduling
OPERATING SYSTEMS CS3502 Fall 2017
Chapter 2 Processes and Threads Today 2.1 Processes 2.2 Threads
Software Architecture in Practice
Node.Js Server Side Javascript
Distributed Systems - Comp 655
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CS 143A Quiz 1 Solution.
Operating Systems Bina Ramamurthy CSE421 11/27/2018 B.Ramamurthy.
CSE 451: Operating Systems Autumn 2003 Lecture 16 RPC
CPU scheduling decisions may take place when a process:
CSE 451: Operating Systems Winter 2004 Module 19 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Multithreaded Programming
Prof. Leonardo Mostarda University of Camerino
Concurrency: Processes CSE 333 Summer 2018
Realizing Concurrency using Posix Threads (pthreads)
CS703 - Advanced Operating Systems
Chapter 3: Processes Process Concept Process Scheduling
Chapter 4: Threads.
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
CS703 – Advanced Operating Systems
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Light-Weight Process (Threads)
Software Engineering and Architecture
Container technology, Microservices, and DevOps
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
Software Engineering and Architecture
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Software Engineering and Architecture
Software Engineering and Architecture
More concurrency issues
Software Engineering and Architecture
Software Engineering and Architecture
Presentation transcript:

Software Engineering and Architecture Server Threading

Henrik Bærbak Christensen Motivation Servers are reactive Process incoming requests for clients … and if we are successful there are many clients… Accept connection Process request Goto 1 CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Exercise What happens in the single-threaded server if A) A new request arrives before the last was processed? B) One of the requests takes 45 seconds to complete? CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Motivation This is problematic if A new request arrives before the last was processed The request process is slow to compute Accept connection Process request Goto 1 CS@AU Henrik Bærbak Christensen

One Solution The classic solution is the thread-per-request That is, every request creates a new thread Accept connection Spawn new thread Goto 1 The thread then concurrently process the request! CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Exercise What happens in the multi-threaded server if A) A new request arrives before the last was processed? B) One of the requests takes 45 seconds to complete? CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen All Well Then? Classic teaching tells us that Thread creation is expensive slow and require much memory Thread context switching is expensive Slow to switch from thread 1 to thread 87 Thus, if our server is hit by 10.000 requests in 1 second, it will become sluggish… Note: Maybe classic teaching is not true!!! CS@AU Henrik Bærbak Christensen

Availability Teaching Maybe, maybe not; but anyway If the number N of incoming requests is high you get N concurrent threads struggling for CPU time They are all very slow May run out of memory! Meaning the server will simply crash Quite fun experiment to make! Java VM will terminate when 95% CPU time is spent on GC A Low Availability Server  CS@AU Henrik Bærbak Christensen

Another Take The alternative solution is the Thread-Pooled-Server Accept connection Queue request for next idle thread Goto 1 Ten threads then concurrently process the requests! CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Exercise What happens in the thread-pooled server if A) A new request arrives before the last was processed? B) One of the requests takes 45 seconds to complete? CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen Discussion Thread pooled servers have characteristics that are important for high availability server construction More responsive as seen from the client Instead of 10.000 requests at time t1 and then 20.000 at t2, the thread pool will guaranty that at most 2.000 requests are handled That is, (theoretically) 10 times faster processing at time t2 Protection against crashing due to out-of-memory The pool size can be adjusted to the amount of memory available (Give and take, if all requests are of the ‘eat memory’ type…) Queue characteristics means bursts are handled Bursts (sudden steep increase of requests) are handled by graceful degradation Server comes slower but then catches up again; does not crash… CS@AU Henrik Bærbak Christensen

Henrik Bærbak Christensen And… As far as I can read Jetty (= SparkJava engine) is thread pooled But I haven’t read the source code  CS@AU Henrik Bærbak Christensen