Title: 544
Tags: lec13

Q: What is the relationship between domain names in a URL and IP addresses?
Example:
https://tyler.caraza-harter.com:443/cs544/s23/schedule.html
A: When you enter a domain name into a browser, it gets translated to an IP address automatically for you.

Q: If you are using HTTP over TCP/IP, what functionality does TCP/IP provide, and what does HTTP provide?
A: TCP/IP gives you IP addresses and port numbers, letting you communicate with a specific process (a server on a specific machine.
HTTP additionally lets you specify what resource you want to access via that server.
For example, consider this URL:
https://tyler.caraza-harter.com:443/cs544/s23/schedule.html
The resource is "/cs544/s23/schedule.html"

Q: What does RPC stand for?
A: Remote Procedure Call
Procedure: another name for a function/method
Remote: we want it to run on a different process/container/computer

Q: What are the RPC implementations created by Meta and Google called, respectively?
A: Thrift and gRPC

Q: What is gRPC layered on top of?
A: HTTP
Every method call is an HTTP POST request.  The arguments go in the request body, the return value goes in the response body.

Q: What is it called when we convert various data types into bytes to send over the wire?  What about the reverse conversion?
A: serialization/deserialization

Q: What does gRPC use for serialization?
A: Protocol Buffers (protobufs for short)

Q: What is variable-length encoding, and what are the pros/cons of using it?
A: Use more space for bigger numbers.  E.g., if an int32 value is small enough, we could use 1, 2, or 3 bytes (instead of the usual 4).
Pros: save space.  Very important for sending data over the network, so protobufs do this.
Cons: CPUs cannot directly operate on int32's unless they are 4 bytes, so conversion is necessary before sending and after receiving this data.

Q: Port forwarding: if we want to forward port 300 of the loopback device on a VM to port 80 inside a container, how do we run the container?
A: docker run -p 127.0.0.1:300:80 myimg

Q: What does this do?
ssh USER@VM -L localhost:1234:localhost:5678
A: This is executed on a machine (say your laptop) to create an SSH tunnel to the VM.  While the tunnel is in use, any requests to localhost:1234 on the laptop will be forwarded to localhost:5678 on the VM ("localhost" is not redundant here because it is referring to two different loopback devices, the one on the laptop and the one on the VM).

Q: Consider this:
docker run -d -p 300:80 myimg
We specify the port on the VM (300) and container (80), but we don't specify which NIC.  What will be used?
A: By default, the command is equivalent to this:
docker run -d -p 0.0.0.0:300:80 myimg
This means traffic on all of the VM's NICs will forward to the container (possibly a security risk, depending on your firewall settings).
Inside the container, it will forward to whatever the main NIC is (e.g., eth0), NOT the loopback device (so anything inside the container should listen on 0.0.0.0, not localhost).

Q: What is container orchestration, and what is currently a very popular orchestrator?
A: Orchestration lets you deploy cooperating containers across many different machines.
Kubernetes is probably the most well known.

Q: What does "docker compose" do?
A: Lets you start a bunch of cooperating containers on the same machine.

Q: protobuf files (.proto) can support two different syntaxes, v2 and v3.  If you want v3, what should the first line of your .proto be?
A: syntax = "proto3";

Q: What are the two main things a .proto file contains?
A: messages
services
Example:
message MyMessage {
  ...
}
service MyService {
  ...
}

Q: In a .proto file, what does a message contain?
A: Fields, each with a type and a number, like this:
message MyMessage {
  int32 x = 1;
  int32 y = 2;
}

Q: In a .proto file, what does a service contain?
A: RPCs, like this:
service MyService {
  rpc MyRPC(Message1) returns (Message2);
}
Each RPC has one message containing arguments and another containing return values.

Q: When you generate code for a .proto file, you get two files:
????_pb2
????_pb2_grpc
What are they each for?
A: ????_pb2: code for serializing/deserializing the messages
????_pb2_grpc: servicer (class to be inherited from) and stubs for making remote procedure calls

Q: Consider this:
python3 -u server.py &> log.txt
What does "-u" do?
A: "force the stdout and stderr streams to be unbuffered"
Otherwise, if its buffered, any prints from server.py might not immediately appear in log.txt (that can be confusing if you're using log.txt to debug).

Q: If you have a docker-compose.yml in the current directory, and you want to start running the services defined, what can you do?
A: docker compose up

Q: If you want to see the compose containers currently running, what do you do?
A: docker compose ps

Q: If you want to stop running containers for a compose cluster, what can you do?
A: docker compose down

Q: If you want to delete all containers for a docker compose cluster, what can you do?
A: docker compose rm
(add -f to force it; for example, might be necessary if they're currently running)