Lesson 8 - Content Distribution Flashcards
CDN
Content Distribution Network
-An internet-wide tool that allows websites and network operators to deliver data quickly and efficiently
HTTP
Hypertext transfer protocol
- application layer protocol to transfer web content. It’s the protocol that your web browser uses to request web pages, and it’s also the protocol used when objects/pages/etc. are returned to your browser.
- Web browser makes requests. Pages/objects on page come back as responses.
- HTTP is typically layered on top of a byte stream protocol, which is almost always TCP
- The server maintains no information about past client requests. Thus we say the server is stateless.
Contents of an HTTP request
- Request line:
- Indicates a method for the request
- GET: return the content associated with a URL
- Can also be used to send data from the content to the server
- POST: sends data to the server
- HEAD: returns typically only the headers of the GET response, but no the content
- URL:
- It’s relative (something like index.html)
- Version number of the HTTP protocol
- Request also contains additional headers, many of which are optional:
- Referrer: indicates the URL that caused the page to be requested, e.g. if an object is being requested as part of embedded content in another page, the referrer might be the page that’s embedding the content.
- User Agent: client software being used to fetch the page. For example: you might fetch a page using a particular version of Chrome, Firefox, etc. The user agent informs the server which client software is being used.
Which HTTP header indicates client software?
User-agent
HTTP response contains what parts?
- Status line:
- HTTP Version (e.g. “HTTP/1.1”)
- Response Code (e.g. “200 OK”)
- Other headers:
- Location
- Server
- Allow
- Content-encoding
- Content-length
- Expires
- Last-modified
- Other headers, like Set-Cookie
Response code in 100s
Informational
Response code in 200s
Success
Response code 200
Means “OK”. Very common
Response code in 300s
Redirection
Response code 301
Moved permanently
Response code in 400s
Errors
Response code 404
Page Not Found
Response code in 500s
Server errors
HTTP response header - Location
May be used in redirection
HTTP response header - Server
Indicates server software
HTTP response header - Allow
Indicates HTTP methods that are allowed, such as GET, HEAD, and so forth
HTTP response header - Content-encoding
Describes how the content is encoded (for example, if it’s compressed)
HTTP response header - Content-length
Indicates how long the content is in terms of bytes
HTTP response header - Expires
Indicates how long the content can be cached
HTTP response header - Last-modified
Indicates the last time the page was modified
Early HTTP
- v0.9/1.0
- Early versions only had 1 request/response for every TCP connection
- On the plus side, this was simple to implement, but the main drawback is it required a TCP connection for every request, thereby introducing a lot of overhead and slowing transfer. Every request would require a TCP handshake, and TCP must start in slow start every time the connection opens
- This is exacerbated by the fact that short transfers are very bad for TCP because TCP is always stuck in slow start and never gets a chance to actually ramp up to steady-state transfer.
- Also, since TCP connections are terminated after every request is completed, the servers have many connections that are forced to keep TCP connections in TIME_WAIT states until the timers expire, thus resulting in additional resources that the server needs to keep reserved even after the connections have completed
- A solution to increase efficiency and account for many of these drawbacks is to use something called persistent connections
Persistent Connections
Multiple HTTP requests/responses are multiplexed onto a single TCP connection
- Delimiters at the end of an HTTP request indicate the ends of requests
- Content-length allows the receiver to identify how long a response is
- So, the server actually needs to know the size of the transfer in advance.
- Combined with pipelining
Pipelining
client sends the next request as soon as it encounters a referenced object, there is as little as 1 RTT for all referenced objects before they begin to be fetched
-Persistent connections with pipelining is the default behavior in HTTP 1.1
Why cache?
Improve performance
* We know that TCP throughput is inversely proportional to round trip time. So, the further away the web content is, the slower the webpage will load, both because latency is bigger and throughput is lower. * Instead, if the client can fetch content from the local cache, performance can be drastically improved by fetching content from a nearby location. * Caching can also improve the performance when multiple clients are requesting the same content. Not only do the clients benefit, but the ISP also saves costs on transit, because it doesn’t have to pay to keep transferring the same content over the expensive links. Instead, it can simply serve the content to the clients locally.
Where can caching occur?
- Browser (locally on your machine)
- In network: Sometimes your local ISP may have a web cache
- Content distribution networks are a special type of web cache that can be used to improve performance
How to make sure clients get most recent version of web page?
- caches periodically expire content based on the Expires header.
- caches can also check with the origin server (“cache checks”) to see whether the original content has been modified
- If the content hasn’t been modified, the origin server would respond to a cache check request with a “304” (Not Modified) response.