Content Distribution Flashcards
If your browser has a page in the cache and wants to know if the page is still fresh and can be used, or is too old and should be replaced with fresh content from the server, which HTTP method should it use to find out?
The HEAD method in HTTP requests a document just like the GET method except that the server will respond to a HEAD request with only the HTTP response header
What will cause a server to send a response message with the status code 404 Not Found
The requested file does not exist on the server. That is, the file indicated by the path part of the GET method line cannot be found at that path.
What will cause a server to send a response message with the status code 302 Moved Temporarily
The requested file is not at this location (i.e., the path part of the GET method line), but the browser should instead use the URL provided in the Location field of the response to retrieve the file
so the URL in the Location field should be used this once, but not necessarily again in the future.
What will cause a server to send a response message with the status code 200 OK
The operation in the request message succeeded. What that operation is exactly depends on the request method
Consider the HTTP protocol. What would the Last-Modified header field be used for?
This is the date and time that the requested document file was last modified on the server
It can be used to check if a cached copy is fresh (newer than the Last-Modified time) or stale (older than the Last-Modified time, indicating that it’s been changed since the cached copy was retrieved).
Consider the HTTP protocol. What would the Host header field be used for?
This is the domain name of the web request
One way this may be used is if a single web server (with a single IP address) is hosting websites for more than one domain
Consider the HTTP protocol. What would the Cookie header field be used for?
This is included in request messages that are sent to a domain that previously gave the browser a cookie. That cookie would have been provided by the Set-Cookie field in a response message, and after that (until the cookie expires) the browser should include the exact same cookie given by Set-Cookie in any request message it sends to the same domain
Of the various methods to redirect web requests to CDN servers, DNS redirection is the most common. Why would this method be more popular than the alternatives?
DNS-based redirection is much faster than HTTP redirection, as the latter requires a couple extra round trips to servers
It also gives the CDN provider more control over who will be redirected where than a technique like IP anycast would
Finally, it is not too difficult to implement (even if slightly more complex than the other two) and it uses tools that are widely supported (i.e., DNS) and do not need any modifications to support this technique (i.e., DNS works out of-the-box).
How does BitTorrent implement the tit-for-tat algorithm? Be sure to explain in detail, including the roles of both choking and unchoking.
A BitTorrent client sends data only to the top N peers who are sending to it, plus one peer who is optimistically unchoked
It will not send to other peers, and they are said to be choked
Thus it provides tit-for-tat by sending to those who send the most to it, and choking those that are not sending to it, or are sending slowly
The game theoretic result is that clients will end up sending to peers that are able to send back about the same amount – fast peers will get paired up, while slow peers are matched with each other
In a distributed hash table, how many steps (hops) are required to lookup an item if the finger table is a constant size (i.e., its size does not depend on the number of DHT nodes in the system)? Explain why that is the right answer.
A lookup will require O(N) hops in this case. Each node only knows how to find the next one, so it basically forms a ring topology. In the worst case, the requested item is on the last node in the ring before getting back to the node that originated the request.
For a more typical DHT setup where the finger table has O(log N) entries, for N DHT nodes in the system, explain why the number of steps to access an item is O(log N).
O(log N) entries in the finger table means that each node knows about the node halfway around the ring back to it, about the node halfway to that one, the one halfway to that one, and so on until the last entry in the finger table that is just the next node. This means that for any given item that could be on any node, each node knows the address of at least one node that is at least half way around the ring from itself to the item. Since each hop cuts the distance to the item in half, the number of hops required to get to the item from any starting point in the DHT is O(log N). (This should be understood by analogy to binary search, divide-and-conquer, etc.)