Carnegie Mellon 1 Proxy Web & Concurrency Ian Hartwig 15/18-213 - Section E Recitation 13 April 15 th, 2013.

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

HTTP HyperText Transfer Protocol. HTTP Uses TCP as its underlying transport protocol Uses port 80 Stateless protocol (i.e. HTTP Server maintains no information.
1 Carnegie Mellon Networking Basics and Concurrent Programming Shiva (sshankar) Section M.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
Chapter 2: Application Layer
The Internet Useful Definitions and Concepts About the Internet.
Master’s course Bioinformatics Data Analysis and Tools Lecture 6: Internet Basics Centre for Integrative Bioinformatics.
How the web works: HTTP and CGI explained
Chapter 2 Application Layer Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross Addison-Wesley, July.
Definitions, Definitions, Definitions Lead to Understanding.
Application Layer  We will learn about protocols by examining popular application-level protocols  HTTP  FTP  SMTP / POP3 / IMAP  Focus on client-server.
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
Carnegie Mellon 1 Proxy Web & Concurrency Rohith Jagannathan April 13 th, /18-213: Introduction to Computer Systems Recitation 13.
 Proxy Servers are software that act as intermediaries between client and servers on the Internet.  They help users on private networks get information.
Web server and web browser It’s a take and give policy in between client and server through HTTP(Hyper Text Transport Protocol) Server takes a request.
INTRODUCTION TO WEB DATABASE PROGRAMMING
IT 210 The Internet & World Wide Web introduction.
Web Servers Web server software is a product that works with the operating system The server computer can run more than one software product such as .
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
FTP (File Transfer Protocol) & Telnet
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
TCP/IP Protocol Suite 1 Chapter 22 Upon completion you will be able to: World Wide Web: HTTP Understand the components of a browser and a server Understand.
Rensselaer Polytechnic Institute Shivkumar Kalvanaraman, Biplab Sikdar 1 The Web: the http protocol http: hypertext transfer protocol Web’s application.
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
Web application architecture
1 Computer Communication & Networks Lecture 28 Application Layer: HTTP & WWW p Waleed Ejaz
How Web Servers and the Internet Work by by: Marshall Brainby: Marshall Brain
XHTML Introductory1 Linking and Publishing Basic Web Pages Chapter 3.
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
HOW WEB SERVER WORKS? By- PUSHPENDU MONDAL RAJAT CHAUHAN RAHUL YADAV RANJIT MEENA RAHUL TYAGI.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming.
1 Welcome to CSC 301 Web Programming Charles Frank.
Proxy Lab Recitation I Monday Nov 20, 2006.
CIS679: Lecture 13 r Review of Last Lecture r More on HTTP.
WWW: an Internet application Bill Chu. © Bei-Tseng Chu Aug 2000 WWW Web and HTTP WWW web is an interconnected information servers each server maintains.
Carnegie Mellon 1 Proxy: Web & Concurrency : Introduction to Computer Systems Recitation 13: Monday, Nov. 18 th, 2013 Marjorie Carlson Section A.
2007cs Servers on the Web. The World-Wide Web 2007 cs CSS JS HTML Server Browser JS CSS HTML Transfer of resources using HTTP.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
Carnegie Mellon 1 Proxy Recitation Jeffrey Liu Recitation 13: November 23, 2015.
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.
CITA 310 Section 2 HTTP (Selected Topics from Textbook Chapter 6)
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.
PHP and Sessions. Session – a general definition The GENERAL definition of a session in the “COMPUTER WORLD” is: The interactions (requests and responses)
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 7 Omar Meqdadi Department of Computer Science and Software Engineering University of.
Data Communication EDA344, DIT420 Description of Lab 1 and Optional Programming HTTP Assignment Bapi Chatterjee Prajith R G.
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/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
REST API Design. Application API API = Application Programming Interface APIs expose functionality of an application or service that exists independently.
© Janice Regan, CMPT 128, Jan 2007 CMPT 371 Data Communications and Networking HTTP 0.
Computer Basics Introduction CIS 109 Columbia College.
Carnegie Mellon Recitation 11: ProxyLab Fall 2009 November 16, 2009 Including Material from Previous Semesters' Recitations.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Block 5: An application layer protocol: HTTP
WWW and HTTP King Fahd University of Petroleum & Minerals
CISC103 Web Development Basics: Web site:
Web Development Web Servers.
Data Virtualization Tutorial… CORS and CIS
E-commerce | WWW World Wide Web - Concepts
Extending echo server HTTP Broken pipe error Feedback and evaluation
E-commerce | WWW World Wide Web - Concepts
Web Caching? Web Caching:.
CISC103 Web Development Basics: Web site:
Computer Communication & Networks
Recitation 12: ProxyLab Part 1
Recitation 12: ProxyLab Part 1
CSCI 380: Operating Systems Lecture #14 Instructor: William Killian
Presentation transcript:

Carnegie Mellon 1 Proxy Web & Concurrency Ian Hartwig 15/ Section E Recitation 13 April 15 th, 2013

Carnegie Mellon 2 Outline Getting content on the web: Telnet/cURL Demo How the web really works Proxy  Due Tuesday, Dec. 3rd  You can use your late days this year  No partners this year Threading Semiphores & Mutexes Readers-Writer Lock

Carnegie Mellon 3 The Web in a Textbook Client request page, server provides, transaction done. A sequential server can handle this. We just need to serve one page at a time. This works great for simple text pages with embedded styles. Web server Web client (browser)

Carnegie Mellon 4 Telnet/Curl Demo Telnet  Interactive remote shell – like ssh without security  Must build HTTP request manually  This can be useful if you want to test response to malformed headers [03:30] telnet 80 Trying Connected to WWW-CMU-PROD-VIP.ANDREW.cmu.edu ( ). Escape character is '^]'. GET HTTP/1.0 HTTP/ Moved Permanently Date: Sun, 17 Nov :31:10 GMT Server: Apache/ (Unix) mod_gzip/ a mod_pubcookie/3.3.4a mod_ssl/ OpenSSL/0.9.8e-fips- rhel5 Location: Connection: close Content-Type: text/html; charset=iso Moved Permanently Moved Permanently The document has moved here. Apache/ Server at Port 80 Connection closed by foreign host.

Carnegie Mellon 5 Telnet/cURL Demo cURL  “URL transfer library” with a command line program  Builds valid HTTP requests for you!  Can also be used to generate HTTP proxy requests: [03:28] curl Moved Permanently Moved Permanently The document has moved here. Apache/ Server at Port 80 [03:40] curl --proxy lemonshark.ics.cs.cmu.edu: Moved Permanently Moved Permanently The document has moved here. Apache/ Server at Port 80

Carnegie Mellon 6 How the Web Really Works In reality, a single HTML page today may depend on 10s or 100s of support files (images, stylesheets, scripts, etc.) Builds a good argument for concurrent servers  Just to load a single modern webpage, the client would have to wait for 10s of back-to-back request  I/O is likely slower than processing, so back Caching is simpler if done in pieces rather than whole page  If only part of the page changes, no need to fetch old parts again  Each object (image, stylesheet, script) already has a unique URL that can be used as a key

Carnegie Mellon 7 How the Web Really Works Excerpt from Carnegie Mellon University | CMU...

Carnegie Mellon 8 Aside: Setting up Firefox to use a proxy You may use any browser, but we’ll be grading with Firefox Preferences > Advanced > Network > Settings… (under Connection) Check “Use this proxy for all protocols” or your proxy will appear to work for HTTPS traffic.

Carnegie Mellon 9 Sequential Proxy

Carnegie Mellon 10 Sequential Proxy Note the sloped shape of when requests finish  Although many requests are made at once, the proxy does not accept a new job until it finishes the current one  Requests are made in batches. This results from how HTML is structured as files that reference other files. Compared to the concurrent example (next), this page takes a long time to load with just static content

Carnegie Mellon 11 Concurrent Proxy

Carnegie Mellon 12 Concurrent Proxy Now, we see much less purple (waiting), and less time spent overall. Notice how multiple green (receiving) blocks overlap in time  Our proxy has multiple connections open to the browser to handle several tasks at once

Carnegie Mellon 13 How the Web Really Works A note on AJAX (and XMLHttpRequests)  Normally, a browser will make the initial page request then request any supporting files  And XMLHttpRequest is simply a request from the page once it has been loaded & the scripts are running  The distinction does not matter on the server side – everything is an HTTP Request

Carnegie Mellon 14 Proxy - Functionality Should work on vast majority of sites  Reddit, Vimeo, CNN, YouTube, NY Times, etc.  Some features of sites which require the POST operation (sending data to the website), will not work  Logging in to websites, sending Facebook message  HTTPS is not expected to work  Google (and some other popular websites) now try to push users to HTTPs by default; watch out for that Cache previous requests  Use LRU eviction policy  Must allow for concurrent reads while maintaining consistency  Details in write up

Carnegie Mellon 15 Proxy - Functionality Why a multi-threaded cache? Sequential cache would bottleneck parallel proxy Multiple threads can read cached content safely Search cache for the right data and return it Two threads can read from the same cache block But what about writing content? Overwrite block while another thread reading? Two threads writing to same cache block?

Carnegie Mellon 16 Proxy - How Client / Server Session ClientServer socket bind listen rio_readlineb rio_writenrio_readlineb rio_writen Connection request rio_readlineb close EOF open_listenfd open_clientfd acceptconnect

Carnegie Mellon 17 Proxy - How Remember that picture?  Proxies are a bit special; they are a server and a client at the same time.  They take a request from one computer (acting as the server), and make it on their behalf (as the client).  Ultimately, the control flow of your program will look like a server, but will have to act as a client to complete the request Start small  Grab yourself a copy of the echo server (pg. 910) and client (pg. 909) in the book  Also review the tiny.c basic web server code to see how to deal with HTTP headers  Note that tiny.c ignores these; you may not

Carnegie Mellon 18 Proxy - How What you end up with will resemble: Server (port 80) Client Client socket address :51213 Server socket address :80 Proxy Proxy server socket address :15213 Proxy client socket address :52943

Carnegie Mellon 19 Proxy – Testing & Grading New: Autograder ./driver.sh will run the same tests as autolab:  Ability to pull basic web pages from a server  Handle a (concurrent) request while another request is still pending  Fetch a web page again from your cache after the server has been stopped  This should help answer the question “is this what my proxy is supposed to do?”  Please don’t use this grader to definitively test your proxy; there are many things not tested here

Carnegie Mellon 20 Proxy – Testing & Grading Test your proxy liberally  The web is full of special cases that want to break your proxy  Generate a port for yourself with./port-for-user.pl [andrewid]  Generate more ports for web servers and such with./free-port.sh  Consider using your andrew web space (~/www) to host test files  You have to visit to publish your folder to the public server Create a handin file with make handin  Will create a tar file for you with the contents of your proxylab- handin folder

Carnegie Mellon 21 Tips: Version Control What is Git?  Version control software  Easily roll back to previous version if needed  Already installed on Andrew machines  Set up a repo on GitHub, BitBucket, or AFS  Make sure only can access it! Using Git  git pull  git add.  git commit -m “I changed something”  git push

Carnegie Mellon 22 Mutexes & Semaphores Mutexes Allow only one thread to run code section at a time If other threads are trying to run the code, they will wait Semaphores Allows a fixed number of threads to run the code Mutexes are a special case of semaphores, where the number of threads=1 Examples will be done with semaphores to illustrate

Carnegie Mellon 23 Read-Write Lock Also called a Readers-Writer lock in the notes Cache can be read in parallel safely If thread is writing, no other thread can read or write If thread is reading, no other thread can write Potential issues Writing starvation If threads always reading, no thread can write Fix: if a thread is waiting to write, it gets priority over any new threads trying to read How can we lock out threads?

Carnegie Mellon 24 Read-Write Locks Cont. How would you make a read-write lock with semaphores? Luckily, you don't have to! pthread_rwlock_* handles that for you pthread_rwlock_t lock; pthread_rwlock_init(&lock,NULL); pthread_rwlock_rdlock(&lock); pthread_rwlock_wrlock(&lock); pthread_rwlock_unlock(&lock);

Carnegie Mellon 25 Questions?