Interview prep · questions
Systems and networking interview questions
12 questions, from core to senior. Say your answer out loud first, then open the model answer and check it against the points a strong answer covers.
What is the difference between a process and a thread?
Show the model answer
A process is a running program with its own memory. The operating system keeps processes apart, so one process cannot read another one's memory, and a crash in one does not break the others. A thread is a line of execution inside a process. All threads of a process share the same memory, but each thread has its own stack and registers. So threads are cheaper to create and to switch between, and they can share data directly. The price is safety. Two threads that change the same data at the same time cause race conditions, so shared data needs locks or atomic operations. And a crash in one thread usually ends the whole process. Processes talk through slower channels, such as pipes, sockets or shared memory that they set up on purpose. I choose processes for isolation and threads for cheap sharing.
A strong answer covers
- Says a process has its own memory and threads share the memory of their process
- Says each thread has its own stack and registers
- Says threads are cheaper to create and switch, but shared data needs synchronization
- Says a crash in one thread usually ends the process, while processes are isolated
Likely follow-up
Why do some servers run several processes instead of one process with many threads?
How does Node handle many requests with one thread, and what happens when one request does heavy CPU work?
Show the model answer
Node runs my JavaScript on one thread with an event loop. When a request waits for the database or the network, Node does not block. It starts the operation, moves on to other requests, and runs my callback when the result arrives. The operating system does most network waiting, and libuv has a small thread pool, four threads by default, for file system work, DNS lookups with dns.lookup, compression and some crypto. A classic thread pool server gives each request its own thread, which blocks while it waits. That is simple, but each thread costs memory, so the number of threads limits it. Node's weak point is CPU work. A loop that runs for two seconds blocks the event loop, and every other request waits two seconds too. So I move heavy work to worker threads, to a child process or to a separate service with a queue.
A strong answer covers
- Explains the event loop: one JavaScript thread, non-blocking I/O, callbacks when results arrive
- Knows libuv has a small thread pool for file system, DNS lookup, compression and some crypto
- Compares it with a thread per request server that blocks while waiting
- Says CPU-bound work blocks every other request
- Moves heavy work to worker threads, a child process or a queue
Likely follow-up
How would you detect in production that the event loop is being blocked?
What happens on the network and on the server between typing a URL and getting the first response?
Show the model answer
First the browser needs an IP address, so it resolves the domain name with DNS. It checks its own cache and the operating system cache, and then asks a resolver. Next it opens a connection. With HTTP/1.1 or HTTP/2 that is a TCP handshake and then a TLS handshake. With HTTP/3 it is QUIC, which does both in one step. Then the browser sends the HTTP request. Often the first stop is a CDN edge server near the user. If it has a cached copy, it answers right away. If not, the request goes on to the origin, usually to a load balancer, which picks a healthy application server. The application checks the session, reads from a cache or the database, builds the response and sends it back with a status code and headers. Every step costs at least one round trip, so the distance to the server matters a lot.
A strong answer covers
- Starts with DNS resolution and its caches
- Names the TCP and TLS handshakes, or QUIC for HTTP/3
- Includes a CDN edge that may answer from its cache
- Describes the load balancer, application server and database behind it
- Says round trips add up, so distance matters
Likely follow-up
Which of these steps can be skipped on the second visit, and why?
How does DNS resolution work, and what does the TTL on a DNS record control?
Show the model answer
DNS turns a name such as api.example.com into an IP address. The browser and the operating system check their caches first. If they have no answer, they ask a recursive resolver, usually run by the network provider or a public DNS service. On a cache miss the resolver asks a root server, which points to the servers for the top-level domain, such as com. Those point to the authoritative servers for example.com, and they give the real answer. Each record has a TTL, a time to live in seconds. It tells resolvers how long they may cache the answer. A long TTL means fewer lookups and faster answers, but a change takes longer to reach everyone. So before I move a service to a new IP, I lower the TTL some time ahead, wait for the old TTL to pass, make the change, and raise it again later.
A strong answer covers
- Lists the caches: browser, operating system, recursive resolver
- Describes the chain: root, top-level domain, authoritative server
- Says the TTL is how long a resolver may cache the answer
- Explains the trade-off: long TTL is fast, but changes spread slowly
- Lowers the TTL ahead of a planned change
Likely follow-up
You changed a DNS record and some users still reach the old server. Why?
What is the difference between TCP and UDP, and when do you use each?
Show the model answer
TCP gives me a reliable, ordered stream of bytes. It starts with a three-way handshake. It numbers the data, the receiver acknowledges it, and lost packets are sent again. It also has flow control, so a fast sender does not flood a slow receiver, and congestion control, so it slows down when the network is full. The cost is extra round trips and head-of-line blocking: if one packet is lost, the data after it waits. UDP just sends separate datagrams. There is no handshake, no retransmission and no order. A packet can be lost, duplicated or arrive late, and the application must deal with it. I use TCP for web traffic, APIs and databases, where every byte must arrive in order. UDP fits video calls, live audio and games, where a late packet is useless anyway. DNS mostly uses UDP, and QUIC, which carries HTTP/3, is built on UDP.
A strong answer covers
- Says TCP is connection-based, reliable and ordered, with retransmission
- Mentions flow control and congestion control in TCP
- Says UDP sends datagrams with no delivery or order guarantee
- Names head-of-line blocking as a cost of TCP
- Gives fitting uses: TCP for APIs and databases, UDP for real-time media, DNS and QUIC
Likely follow-up
If UDP is unreliable, how does QUIC give reliable delivery on top of it?
What does TLS do, what happens in the handshake, and why should every site use HTTPS?
Show the model answer
TLS gives three things: encryption, so nobody on the path can read the traffic; integrity, so nobody can change it unnoticed; and authentication, so I know I am talking to the real server. In the handshake the client says which versions and ciphers it supports. The server sends its certificate. Both sides do a key exchange, usually elliptic-curve Diffie-Hellman, and get a shared secret that was never sent over the wire. From it they make symmetric keys for the rest of the connection. With TLS 1.3 this takes one round trip. The certificate links the domain name to a public key, and a certificate authority that the client trusts has signed it. The client checks the signature chain, the name and the dates. Without HTTPS, anyone on the network, such as public Wi-Fi, can read passwords and cookies or inject content into the page. Browsers also limit many features to secure pages.
A strong answer covers
- Names the three goals: encryption, integrity, authentication
- Describes the key exchange that creates symmetric session keys
- Says TLS 1.3 needs one round trip for a full handshake
- Explains the certificate: domain plus public key, signed by a trusted authority
- Says plain HTTP lets anyone on the path read or change traffic
Likely follow-up
What is HSTS, and what attack does it prevent that a redirect to HTTPS does not?
What changed between HTTP/1.1, HTTP/2 and HTTP/3?
Show the model answer
HTTP/1.1 is text, and one connection handles one request at a time. It can keep the connection open between requests, but a slow response blocks the ones behind it. So browsers open several connections per host. HTTP/2 keeps the same methods, headers and status codes, but sends them as binary frames. Many requests share one connection as separate streams, and headers are compressed. That removes the blocking at the HTTP level. But it still runs on TCP, so one lost packet stops every stream on the connection until it is sent again. HTTP/3 runs on QUIC, which is built on UDP. QUIC handles each stream on its own, so a lost packet only delays its own stream. It has TLS 1.3 built in, so setting up a connection takes fewer round trips, and a connection can survive a change of network, such as from Wi-Fi to mobile data.
A strong answer covers
- Says HTTP/1.1 handles one request at a time per connection
- Says HTTP/2 multiplexes streams over one TCP connection with binary frames and header compression
- Explains that TCP head-of-line blocking remains in HTTP/2
- Says HTTP/3 runs on QUIC over UDP, with TLS 1.3 built in
- Mentions faster connection setup and surviving a network change
Likely follow-up
Why can bundling many files into one help on HTTP/1.1 but matter less on HTTP/2?
Roughly how long does it take to read from memory, read from an SSD, and make a network round trip?
Show the model answer
I keep only orders of magnitude in my head, and all of these are approximate. Reading main memory takes about a hundred nanoseconds. A random read from an SSD takes tens of microseconds to around a hundred, so it is hundreds of times slower than memory. A network round trip inside one data center region is somewhere around a millisecond or less. A round trip across continents is around a hundred milliseconds or more, because light in fiber needs time to cover that distance. So an SSD read is roughly a thousand times slower than memory, and a round trip across an ocean is roughly a million times slower. This changes design decisions. A cache in the process memory beats a call to another service. Ten sequential calls across an ocean cost about a second, so I batch them, run them in parallel, or move the data closer to the user. I always measure, because real numbers depend on the hardware and the network.
A strong answer covers
- Gives memory as about a hundred nanoseconds
- Gives an SSD random read as tens to about a hundred microseconds
- Gives a round trip within a region as around a millisecond, across continents around a hundred milliseconds
- Calls the numbers approximate orders of magnitude
- Draws a conclusion: cache close, batch calls, avoid sequential round trips
Likely follow-up
A page makes five sequential API calls to a server on another continent. How would you speed it up?
What does the CAP theorem really say, and what does a system do during a network partition?
The model answer to this senior question opens with a year in the app. What a year includes
What is the difference between an L4 and an L7 load balancer, and what are health checks and sticky sessions for?
The model answer to this senior question opens with a year in the app. What a year includes
What is the difference between vertical and horizontal scaling, and why do stateless services matter?
Show the model answer
Vertical scaling means a bigger machine: more CPU, more memory, a faster disk. It is simple, because the code does not change. But there is a limit to how big one machine gets, the price grows fast near the top, and one machine is still a single point of failure. Horizontal scaling means more machines behind a load balancer. It has no hard limit, and one machine can fail without an outage. But it only works well if the service is stateless. That means a server keeps nothing between requests that another server would need. Sessions, uploads and caches move to shared places, such as a database, Redis or object storage. Then any server can handle any request, and I can add or remove servers at any time. The database is the hard part. I scale it vertically first, then add read replicas, and shard only when I must.
A strong answer covers
- Defines vertical as a bigger machine and horizontal as more machines
- Names the limits of vertical: a ceiling, cost, a single point of failure
- Defines stateless: nothing kept on the server between requests
- Moves sessions and files to shared storage so any server can answer
- Says the database is harder to scale: replicas first, sharding last
Likely follow-up
How do you handle WebSocket connections when servers are stateless?
What are logs, metrics and traces, and which question does each one answer?
The model answer to this senior question opens with a year in the app. What a year includes