⚠️ This is not the current iteration of the course! Head here for the current offering.

Exercises: Distributed Systems

These exercises will help you prepare for quiz questions you may see for Block 4: Distributed Systems.

Acknowledgements: Some of these exercises were originally developed for Harvard's CS 61 course and were kindly shared by Eddie Kohler.

DIST-1. Networking

QUESTION DIST-1A. Which of the following system calls should a programmer expect to sometimes block (i.e., to return after significant delay)? Circle all that apply.

  1. socket
  2. read
  3. accept
  4. listen
  5. connect
  6. write
  7. usleep
  8. None of these

QUESTION DIST-1B. Below are seven message sequence diagrams demonstrating the operation of a client–server RPC protocol. A request such as “get(X)” means “fetch the value of the object named X”; the response contains that value. Match each network property or programming strategy below with the diagram with which it best corresponds. You will use every diagram once.

  1. Loss
  2. Delay
  3. Reordering
  4. Duplication
Example A
Example B
Example C
Example D

QUESTION DIST-1C. List some resources that a DoS attack on a network server might exhaust.

QUESTION DIST-1D. A server sets up a socket to listen on a connection. When a client wants to establish a connection, how does the server manage the multiple clients? In your answer indicate what system call or calls are used and what they do.

QUESTION DIST-1E: How are sockets different from pipes?

DIST-2. Scalability in Distributed Systems

QUESTION DIST-2A: Brett Bro is an engineer at a Silicon Valley startup that develops a new social network for pets. Anticipating exponential growth, Brett argues that the team should build their storage backend "for scale" from the outset.

Which of the following quotes from Brett in the team discussion are correct statements?

  1. "Going distributed immediately won't delay our launch date. Building a distributed system isn't any more complex than writing a concurrent program for one server."
  2. "We can increase resilience to failures by sending each SET request to two randomly-chosen servers. Because of sharding, this will scale well, and because of replication, users will always see the latest data."
  3. "Sharding profile information by pet ID is a good idea, as it will increase our scalability for reads of the profile data."
  4. "Transactions that take locks for reading (GET requests) can release them after reading the necessary values, as having read the values under a lock guarantees atomicity."
  5. "We can use weak consistency to store and replicate friend requests because they are idempotent, so seeing and approving the request twice will have no detrimental effect other than user confusion."

QUESTION DIST-2B: True or false: sharding works best if a single server can independently handle each request.

QUESTION DIST-2C: True or false: RPCs are as fast as function calls.

QUESTION DIST-2D: True or false: developers of distributed systems need to ensure they only write packet-sized data into sockets.

QUESTION DIST-2E: True or false: strong consistency typically reduces scalability of a replicated storage system.