Network Applications: Network App Programming: HTTP/1.1/2; High-performance Server Design Y. Richard Yang 2/15/2016.

Slides:



Advertisements
Similar presentations
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
Advertisements

COEN 445 Communication Networks and Protocols Lab 4
EEC-484/584 Computer Networks Lecture 4 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
HyperText Transfer Protocol (HTTP)
Application Layer  We will learn about protocols by examining popular application-level protocols  HTTP  FTP  SMTP / POP3 / IMAP  Focus on client-server.
Chapter 2: Application Layer
EEC-484/584 Computer Networks Discussion Session for HTTP and DNS Wenbing Zhao
HyperText Transfer Protocol (HTTP) Computer Networks Computer Networks Spring 2012 Spring 2012.
Concurrent Client server L. Grewe. Reveiw: Client/server socket interaction: TCP wait for incoming connection request connectionSocket = welcomeSocket.accept()
Chapter 2 Application Layer Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross Addison-Wesley, July.
Web, HTTP and Web Caching
EEC-484/584 Computer Networks Lecture 4 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
Application Layer  We will learn about protocols by examining popular application-level protocols  HTTP  FTP  SMTP / POP3 / IMAP  Focus on client-server.
An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.
Application Layer  We will learn about protocols by examining popular application-level protocols  HTTP  FTP  SMTP / POP3 / IMAP  Focus on client-server.
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
EEC-484/584 Computer Networks Lecture 4 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
HTTP; The World Wide Web Protocol
Rensselaer Polytechnic Institute Shivkumar Kalvanaraman, Biplab Sikdar 1 The Web: the http protocol http: hypertext transfer protocol Web’s application.
20-1 Last time □ NAT □ Application layer ♦ Intro ♦ Web / HTTP.
2: Application Layer1 Internet apps: their protocols and transport protocols Application remote terminal access Web file transfer streaming multimedia.
Week 11: Application Layer1 Web and HTTP First some jargon r Web page consists of objects r Object can be HTML file, JPEG image, Java applet, audio file,…
Introduction 1 Lecture 6 Application Layer (HTTP) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer Science & Engineering.
2: Application Layer1 Web and HTTP First some jargon Web page consists of base HTML-file which includes several referenced objects Object can be HTML file,
Web application architecture
1 Computer Communication & Networks Lecture 28 Application Layer: HTTP & WWW p Waleed Ejaz
2: Application Layer1 Chapter 2 outline r 2.1 Principles of app layer protocols r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail r 2.5 DNS r 2.6 Socket.
Sockets process sends/receives messages to/from its socket
Hui Zhang, Fall Computer Networking Web, HTTP, Caching.
Network Applications: The Web and High-Performance Web Servers Y. Richard Yang 9/24/2013.
1 HTTP EECS 325/425, Fall 2005 September Chapter 2: Application layer r 2.1 Principles of network applications m app architectures m app requirements.
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 8 Omar Meqdadi Department of Computer Science and Software Engineering University of.
Application Layer 2-1 Chapter 2 Application Layer 2.2 Web and HTTP.
CIS679: Lecture 13 r Review of Last Lecture r More on HTTP.
CSx760 Computer Networks1 HTTP. CSx760 Computer Networks2 The Web: Some Jargon r Web page: m consists of “objects” m addressed by a URL r Most Web pages.
Dr. Philip Cannata 1 The Web and HTTP. Dr. Philip Cannata 2 Application Layer 2-2 Chapter 2 Application Layer Computer Networking: A Top Down Approach.
Application Layer 2-1 Lecture 4: Web and HTTP. Web and HTTP First, a review… web page consists of objects object can be HTML file, JPEG image, Java applet,
Important r There will be NO CLASS on Friday 1/30/2015! r Please mark you calendars 1.
2: Application Layer 1 Chapter 2: Application layer r 2.1 Principles of network applications  app architectures  app requirements r 2.2 Web and HTTP.
Web Technologies Lecture 1 The Internet and HTTP.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)
IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer Networking” – J. Kurose, K. Ross Chapter 2: Application.
1 COMP 431 Internet Services & Protocols HTTP Persistence & Web Caching Jasleen Kaur February 11, 2016.
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 7 Omar Meqdadi Department of Computer Science and Software Engineering University of.
EEC-484/584 Computer Networks Lecture 4 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
HyperText Transfer Protocol (HTTP) Deepti Kulkarni CISC 856: TCP/IP and Upper Layer Protocols Fall 2008 Acknowledgements Professor Amer Richi Gupta.
Application Layer 2-1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012.
Week 11: Application Layer 1 Web and HTTP r Web page consists of objects r Object can be HTML file, JPEG image, Java applet, audio file,… r Web page consists.
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
Network Applications: HTTP; High-Perf HTTP Server 2/2/2012.
Network Applications: HTTP/1.0
2: Application Layer 1 Chapter 2 Application Layer These ppt slides are originally from the Kurose and Ross’s book. But some slides are deleted and added.
Block 5: An application layer protocol: HTTP
How HTTP Works Made by Manish Kushwaha.
WWW and HTTP King Fahd University of Petroleum & Minerals
Lecture 2 Dr. Richard Spillman Fall 2009
Internet transport protocols services
Network Applications: HTTP/1
Web Caching? Web Caching:.
Computer Communication & Networks
EEC-484/584 Computer Networks
CSE 461 HTTP and the Web.
EEC-484/584 Computer Networks
EE 122: HyperText Transfer Protocol (HTTP)
Hypertext Transfer Protocol (HTTP)
EEC-484/584 Computer Networks
Network Applications: HyperText Transfer Protocol
Presentation transcript:

Network Applications: Network App Programming: HTTP/1.1/2; High-performance Server Design Y. Richard Yang 2/15/2016

2 Outline r Admin and recap r HTTP “acceleration” r Network server design

3 Recap: HTTP r C-S app serving Web pages m message format request/response line, header lines, entity body simple methods, rich headers m message flow stateless server, thus states such as cookie and authentication are needed in each message

4 Recap: HTTP r Wide use of HTTP for Web applications r Example: RESTful API m RESTful design g/pubs/dissertation/rest_arch _style.htm /6/tutorial/doc/giepu.html HTTP EthernetCable/DSLWireless TCP UDP WebMail WebApp…

Recap: Basic HTTP/1.0 Server connSocket = accept() Read from file/ write to connSocket close connSocket Create ServerSocket(6789) Map URL to file read request from connSocket It does not have to be a static file

6 Recap: Protocol Flow of Basic HTTP/1.0 r >= 2 RTTs per object: m TCP handshake RTT m client request and server responds --- at least 1 RTT (if object can be contained in one packet) TCP SYN TCP/ACK; HTTP GET TCP ACK base page TCP SYN TCP/ACK; HTTP GET TCP ACK image 1

7 Outline r Admin and recap r HTTP “acceleration”

8 Substantial Efforts to Speedup Basic HTTP/1.0 r Reduce the number of objects fetched [Browser cache] r Reduce data volume [Compression of data] r Reduce the latency to the server to fetch the content [Proxy cache] r Increase concurrency [Multiple TCP connections] r Remove the extra RTTs to fetch an object [Persistent HTTP, aka HTTP/1.1] r Asynchronous fetch (multiple streams) using a single TCP [HTTP/2] r Server push [HTTP/2] r Header compression [HTTP/2]

9 Browser Cache and Conditional GET r Goal: don’t send object if client has up-to-date stored (cached) version r client: specify date of cached copy in http request If-modified-since: r server: response contains no object if cached copy up- to-date: HTTP/ Not Modified client server http request msg If-modified-since: http response HTTP/ Not Modified object not modified http request msg If-modified-since: http response HTTP/ OK … object modified

10 Web Caches (Proxy) r Two types of proxies m Forward proxy Typically in the same network as the client m Reverse proxy Typically in the same network as the server Goal: satisfy client request without involving origin server client Proxy server client http request http response http request http response http request http response origin server origin server

11 Two Types of Proxies

12 Benefits of Forward Proxy Assume: cache is “close” to client (e.g., in same network) r smaller response time: cache “closer” to client r decrease traffic to distant servers m link out of institutional/local ISP network often bottleneck origin servers public Internet institutional network 10 Mbps LAN 1.5 Mbps access link institutional cache

13 No Free Lunch: Problems of Web Caching r The major issue of web caching is how to maintain consistency r Two ways m pull Web caches periodically pull the web server to see if a document is modified m push whenever a server gives a copy of a web page to a web cache, they sign a lease with an expiration time; if the web page is modified before the lease, the server notifies the cache

14 HTTP/1.1: Persistent (keepalive/pipelining) HTTP r On same TCP connection: server parses request, responds, parses new request, … r Client sends requests for all referenced objects as soon as it receives base HTML r Fewer RTTs See Joshua Graessley WWDC 2012 talk: 3x within iTunes

15 Example r Visit cs home page using Chrome

16 HTTP/1.0, Keep-Alive, Pipelining Source:

17 Remaining Problem of Pipelining Head-of-line blocking Source:

18 HTTP/2 Multi-Streams Multiplexing HTTP/2 Binary Framing

19 HTTP/2 Server Push

20 HTTP/2 Stream Dependency and Weights

21 HTTP/2 Header Compression

22 Example r Visit HTTP/2 pages, such as r See chrome://net-internals/#http2

23 Outline r Admin and recap r HTTP “acceleration” r Network server design

WebServer Implementation TCP socket space state: listening address: {*.6789, *.*} completed connection queue: sendbuf: recvbuf: state: listening address: {*.25, *.*} completed connection queue: sendbuf: recvbuf: state: established address: { :6789, } sendbuf: recvbuf: connSocket = accept() Create ServerSocket(6789) write file to connSocket close connSocket Discussion: what does each step do and how long does it take? read request from connSocket read local file

Server Processing Steps Accept Client Connection Read Request Find File Send Response Header Read File Send Data may block waiting on disk I/O may block waiting on network

Writing High Performance Servers: Major Issues r Many socket and IO operations can cause a process to block, e.g.,  accept : waiting for new connection;  read a socket waiting for data or close;  write a socket waiting for buffer space;  I/O read/write for disk to finish

Goal: Limited Only by the Bottleneck CPU DISK Before NET CPU DISK NET After

28 Outline r Admin and recap r HTTP “acceleration” r Network server design m Overview m Multi-thread network servers

Multi-Threaded Servers r Motivation: r Avoid blocking the whole program (so that we can reach bottleneck throughput) r Idea: introduce threads m A thread is a sequence of instructions which may execute in parallel with other threads m When a blocking operation happens, only the flow (thread) performing the operation is blocked

Background: Java Thread Model r Every Java application has at least one thread m The “main” thread, started by the JVM to run the application’s main() method m Most JVM’s use POSIX threads to implement Java threads r main() can create other threads m Explicitly, using the Thread class m Implicitly, by calling libraries that create threads as a consequence (RMI, AWT/Swing, Applets, etc.) 30

Thread vs Process 31

Background: Java Thread Class r Threads are organized into thread groups  A thread group represents a set of threads activeGroupCount(); m A thread group can also include other thread groups to form a tree m Why thread group? 32

Creating Java Thread r Two ways to implement Java thread 1. Extend the Thread class Overwrite the run() method of the Thread class 2. Create a class C implementing the Runnable interface, and create an object of type C, then use a Thread object to wrap up C  A thread starts execution after its start() method is called, which will start executing the thread’s (or the Runnable object’s) run() method  A thread terminates when the run() method returns 33

Option 1: Extending Java Thread 34 class PrimeThread extends Thread { long minPrime; PrimeThread(long minPrime) { this.minPrime = minPrime; } public void run() { // compute primes larger than minPrime... } } PrimeThread p = new PrimeThread(143); p.start();

Option 1: Extending Java Thread 35 class RequestHandler extends Thread { RequestHandler(Socket connSocket) { // … } public void run() { // process request } … } Thread t = new RequestHandler(connSocket); t.start();

Option 2: Implement the Runnable Interface 36 class PrimeRun implements Runnable { long minPrime; PrimeRun(long minPrime) { this.minPrime = minPrime; } public void run() { // compute primes larger than minPrime... } } PrimeRun p = new PrimeRun(143); new Thread(p).start();

Option 2: Implement the Runnable Interface 37 class RequestHandler implements Runnable { RequestHandler(Socket connSocket) { … } public void run() { // } … } RequestHandler rh = new RequestHandler(connSocket); Thread t = new Thread(rh); t.start();

Summary: Implementing Threads 38 class RequestHandler extends Thread { RequestHandler(Socket connSocket) { … } public void run() { // process request } … } Thread t = new RequestHandler(connSocket); t.start(); class RequestHandler implements Runnable { RequestHandler(Socket connSocket) { … } public void run() { // process request } … } RequestHandler rh = new RequestHandler(connSocket); Thread t = new Thread(rh); t.start();

Example: a Multi-threaded TCPServer 39 r Turn TCPServer into a multithreaded server by creating a thread for each accepted request

Per-Request Thread Server 40 main() { ServerSocket s = new ServerSocket(port); while (true) { Socket conSocket = s.accept(); RequestHandler rh = new RequestHandler(conSocket); Thread t = new Thread (rh); t.start(); } Try the per-request-thread TCP server: TCPServerMT.java main thread thread starts thread ends thread ends

Modeling Per-Request Thread Server: Theory 41 01kN p0p0 p1p1 pkpk k+1 p k+1 pNpN Welcome Socket Queue (k+1) 

Problem of Per-Request Thread: Reality r High thread creation/deletion overhead r Too many threads  resource overuse  throughput meltdown  response time explosion m Q: given avg response time and connection arrival rate, how many threads active on avg?

43 Background: Little’s Law (1961) r For any system with no or (low) loss. r Assume m mean arrival rate, mean time R at system, and mean number Q of requests at system r Then relationship between Q,, and R: R, Q Example: Yale College admits 1500 students each year, and mean time a student stays is 4 years, how many students are enrolled?

Little’s Law 44 time arrival A t

Discussion: How to Address the Issue