Apache Architecture. How do we measure performance? Benchmarks –Requests per Second –Bandwidth –Latency –Concurrency (Scalability)

Slides:



Advertisements
Similar presentations
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,
Advertisements

WHAT IS AN OPERATING SYSTEM? An interface between users and hardware - an environment "architecture ” Allows convenient usage; hides the tedious stuff.
1 Chapter 5 Threads 2 Contents  Overview  Benefits  User and Kernel Threads  Multithreading Models  Solaris 2 Threads  Java Threads.
Flash: An efficient and portable Web server Authors: Vivek S. Pai, Peter Druschel, Willy Zwaenepoel Presented at the Usenix Technical Conference, June.
Chapter 5 Threads os5.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
Precept 3 COS 461. Concurrency is Useful Multi Processor/Core Multiple Inputs Don’t wait on slow devices.
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
Server Architecture Models Operating Systems Hebrew University Spring 2004.
Threads 1 CS502 Spring 2006 Threads CS-502 Spring 2006.
3.5 Interprocess Communication
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 4: Threads Dr. Mohamed Hefeeda.
Client Server Design Alternatives© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid.
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for Threads.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives Thread definitions and relationship to process Multithreading.
A. Frank - P. Weisberg Operating Systems Introduction to Tasks/Threads.
APACHE WEBSERVER.
1 Web Servers Web Protocols and Practice Chapter 4.
Fronting Tomcat with Apache Httpd Mladen Turk Red Hat, Inc.
Processes Part I Processes & Threads* *Referred to slides by Dr. Sanjeev Setia at George Mason University Chapter 3.
Computer System Architectures Computer System Software
Flash An efficient and portable Web server. Today’s paper, FLASH Quite old (1999) Reading old papers gives us lessons We can see which solution among.
Scalable Apache for Beginners Aaron Bannert /
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
Multithreading Allows application to split itself into multiple “threads” of execution (“threads of execution”). OS support for creating threads, terminating.
APACHE 2.0 A Look Under the Hood CHUUG, June 2002 by Cliff Woolley
Today’s topic Other server design alternatives –Preforked servers –Threaded servers –Prethreaded servers.
ICOM 6115©Manuel Rodriguez-Martinez ICOM 6115 – Computer Networks and the WWW Manuel Rodriguez-Martinez, Ph.D. Lecture 6.
CHEN Ge CSIS, HKU March 9, Jigsaw W3C’s Java Web Server.
 2004 Deitel & Associates, Inc. All rights reserved. 1 Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 13 Threads Read Ch 5.1.
Threads G.Anuradha (Reference : William Stallings)
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.
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.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Multithreaded Programing. Outline Overview of threads Threads Multithreaded Models  Many-to-One  One-to-One  Many-to-Many Thread Libraries  Pthread.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
Department of Computer Science and Software Engineering
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
COMMON INTERFACE FOR EMBEDDED SOFTWARE CONFIGURATION by Yatiraj Bhumkar Advisor Dr. Chung-E Wang Department of Computer Science CALIFORNIA STATE UNIVERSITY,
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
Distributed (Operating) Systems -Processes and Threads-
6.894: Distributed Operating System Engineering Lecturers: Frans Kaashoek Robert Morris
CSC 360, Instructor: Kui Wu Thread & PThread. CSC 360, Instructor: Kui Wu Agenda 1.What is thread? 2.User vs kernel threads 3.Thread models 4.Thread issues.
SEDA An architecture for Well-Conditioned, scalable Internet Services Matt Welsh, David Culler, and Eric Brewer University of California, Berkeley Symposium.
Threads versus Events CSE451 Andrew Whitaker. This Class Threads vs. events is an ongoing debate  So, neat-and-tidy answers aren’t necessarily available.
Threads. Readings r Silberschatz et al : Chapter 4.
An Efficient Threading Model to Boost Server Performance Anupam Chanda.
IBM Http Server Basic Administration. CONTENTS Web server IHS How does IHS differ from Apache Basic configurations Advanced Configurations Performance.
Operating System Concepts
Threads, SMP, and Microkernels Chapter 4. Processes and Threads Operating systems use processes for two purposes - Resource allocation and resource ownership.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Threads by Dr. Amin Danial Asham. References Operating System Concepts ABRAHAM SILBERSCHATZ, PETER BAER GALVIN, and GREG GAGNE.
1 Chapter 5: Threads Overview Multithreading Models & Issues Read Chapter 5 pages
NWCLUG 04/06/2010 Jared Moore L A M P.
Chapter 4 – Thread Concepts
Chapter 4: Threads.
Node.Js Server Side Javascript
Processes and threads.
Web Protocols and Practice
Process Management Process Concept Why only the global variables?
Processes and Threads Processes and their scheduling
Chapter 4 – Thread Concepts
Operating System (013022) Dr. H. Iwidat
Chapter 4: Multithreaded Programming
Process Management Presented By Aditya Gupta Assistant Professor
Node.Js Server Side Javascript
Chapter 4: Threads.
Threads Chapter 4.
Chapter 4: Threads.
Presentation transcript:

Apache Architecture

How do we measure performance? Benchmarks –Requests per Second –Bandwidth –Latency –Concurrency (Scalability)

Building a scalable web server handling an HTTP request –map the URL to a resource –check whether client has permission to access the resource –choose a handler and generate a response –transmit the response to the client –log the request must handle many clients simultaneously must do this as fast as possible

Resource Pools one bottleneck to server performance is the operating system –system calls to allocate memory, access a file, or create a child process take significant amounts of time –as with many scaling problems in computer systems, caching is one solution resource pool: application-level data structure to allocate and cache resources –allocate and free memory in the application instead of using a system call –cache files, URL mappings, recent responses –limits critical functions to a small, well-tested part of code

Multi-Processor Architectures a critical factor in web server performance is how each new connection is handled –common optimization strategy: identify the most commonly- executed code and make this run as fast as possible –common case: accept a client and return several static objects –make this run fast: pre-allocate a process or thread, cache commonly-used files and the HTTP message for the response

Connections must multiplex handling many connections simultaneously –select(), poll(): event-driven, singly-threaded –fork(): create a new process for a connection –pthread create(): create a new thread for a connection synchronization among processes/threads –shared memory: semaphores –message passing

Select select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); Allows a process to block until data is available on any one of a set of file descriptors. One web server process can service hundreds of socket connections

Event Driven Architecture one process handles all events must multiplex handling of many clients and their messages –use select() or poll() to multiplex socket I/O events –provide a list of sockets waiting for I/O events –sleeps until an event occurs on one or more sockets –can provide a timeout to limit waiting time must use non-blocking system calls some evidence that it can be more efficient than process or thread architectures

Process Driven Architecture devote a separate process/thread to each event –master process listens for connections –master creates a separate process/thread for each new connection performance considerations –creating a new process involves significant overhead –threads are less expensive, but still involve overhead may create too many processes/threads on a busy server

Process/Thread Pool Architecture master thread –creates a pool of threads –listens for incoming connections –places connections on a shared queue processes/threads –take connections from shared queue –handle one I/O event for the connection –return connection to the queue –live for a certain number of events (prevents long- lived memory leaks) need memory synchronization

Hybrid Architectures each process can handle multiple requests –each process is an event-driven server –must coordinate switching among events/requests each process controls several threads –threads can share resources easily –requires some synchronization primitives event driven server that handles fast tasks but spawns helper processes for time- consuming requests

What makes a good Web Server? Correctness Reliability Scalability Stability Speed

Correctness Does it conform to the HTTP specification? Does it work with every browser? Does it handle erroneous input gracefully?

Reliability Can you sleep at night? Are you being paged during dinner? It is an appliance?

Scalability Does it handle nominal load? Have you been Slashdotted? –And did you survive? What is your peak load?

Speed (Latency) Does it feel fast? Do pages snap in quickly? Do users often reload pages?

Apache the General Purpose Webserver Apache developers strive for correctness first, and speed second.

Apache HTTP Server Architecture Overview

Classic “Prefork” Model Apache 1.3, and Apache 2.0 Prefork Many Children Each child handles one connection at a time. Child Parent Child … (100s)

Multithreaded “Worker” Model Apache 2.0 Worker Few Children Each child handles many concurrent connections. Child Parent Child … (10s) 10s of threads

Dynamic Content: Modules Extensive API Pluggable Interface Dynamic or Static Linkage

In-process Modules Run from inside the httpd process –CGI (mod_cgi) –mod_perl –mod_php –mod_python –mod_tcl

Out-of-process Modules Processing happens outside of httpd (eg. Application Server) Tomcat –mod_jk/jk2, mod_jserv mod_proxy mod_jrun Parent Tomcat Child

Performance transactions per second ArchitectureHelloBigDB Apache-Mod_perl Apache-CGI59256

Architecture: The Big Picture Child Parent Child … (10s) 10s of threads Tomcat DB 100s of threads mod_jk mod_rewrite mod_php mod_perl

“MPM” Multi-Processing Module An MPM defines how the server will receive and manage incoming requests. Allows OS-specific optimizations. Allows vastly different server models (eg. threaded vs. multiprocess).

“Child Process” aka “Server” Called a “Server” in httpd.conf A single httpd process. May handle one or more concurrent requests (depending on the MPM). Child Parent Child … (100s) Servers

“Parent Process” The main httpd process. Does not handle connections itself. Only creates and destroys children. Shared memory scoreboard to determine who handles connections Child Parent Child … (100s) Only one Parent

“Thread” In multi-threaded MPMs (eg. Worker). Each thread handles a single connection. Allows Children to handle many connections at once.

Prefork MPM Apache 1.3 and Apache 2.0 Prefork Each child handles one connection at a time Many children High memory requirements “You’ll run out of memory before CPU”

Prefork Directives (Apache 2.0) StartServers MinSpareServers MaxSpareServers MaxClients MaxRequestsPerChild

Worker MPM Apache 2.0 and later Multithreaded within each child Dramatically reduced memory footprint Only a few children (fewer than prefork)

Worker Directives MinSpareThreads MaxSpareThreads ThreadsPerChild MaxClients MaxRequestsPerChild

Apache 1.3 and 2.0 Performance Characteristics Multi-process, Multi-threaded, or Both?

Prefork High memory usage Highly tolerant of faulty modules Highly tolerant of crashing children Fast Well-suited for 1 and 2-CPU systems Tried-and-tested model from Apache 1.3 “You’ll run out of memory before CPU.”

Worker Low to moderate memory usage Moderately tolerant to faulty modules Faulty threads can affect all threads in child Highly-scalable Well-suited for multiple processors Requires a mature threading library (Solaris, AIX, Linux 2.6 and others work well) Memory is no longer the bottleneck.

Important Performance Considerations sendfile() support DNS considerations

sendfile() Support No more double-copy Zero-copy* Dramatic improvement for static files Available on –Linux 2.4.x –Solaris 8+ –FreeBSD/NetBSD/OpenBSD –... * Zero-copy requires both OS support and NIC driver support.

aio Process does not block on –Socket –Disk read or write –semaphores

Sendfile backendthroughput% disk util User+sys writev17.59MB50%25% sendfile33.13MB70%30% aio50MB98%60% aio- sendfile 44.15MB90%40%

DNS RoundRobin