Peer‑to‑Peer Architecture Deck
Click a question to reveal the answer.
This deck distills the key ideas, mechanisms, and pitfalls of large‑scale peer‑to‑peer systems.
1. What core problem do peer‑to‑peer (P2P) networks solve compared with classic client‑server?
They remove the single point of failure and performance bottleneck by letting every node act as both client and server, so capacity and resilience grow with the number of participants.
2. Define an overlay network in the context of P2P.
A logical topology built on top of the Internet’s IP layer, connecting peers by the rules of the P2P protocol rather than physical links.
3. Structured vs. unstructured overlays—what is the main trade‑off?
• Structured (DHT‑based): Guaranteed look‑ups in O(log N) hops but more maintenance under churn.
• Unstructured (random mesh): Cheap to maintain and tolerant of high churn, but searches are best‑effort (flooding/random walk).
4. Give two well‑known structured‑overlay algorithms.
Chord (ring with finger table) and Kademlia (XOR metric with buckets).
5. What is the typical lookup complexity for a DHT such as Chord or Kademlia?
O(log N) hops where N is the number of peers.
6. Explain 'swarming' in BitTorrent‑style protocols.
A file is split into pieces; a downloader fetches different pieces concurrently from many peers and, in turn, uploads the pieces it already has to others.
7. Why does BitTorrent use a 'tit‑for‑tat' algorithm?
To incentivize fairness—peers that upload more get higher download priority, discouraging free‑riders.
8. What does an epidemic (gossip) protocol achieve in P2P?
Robust, probabilistic dissemination and anti‑entropy: peers randomly exchange state so updates eventually reach everyone without central coordination.
9. How do P2P systems keep data durable when nodes can vanish at any time?
Replication—store each piece on multiple peers; if one leaves, others still serve the data.
10. Define 'eventual consistency' in a distributed store.
All replicas may be temporarily divergent but will converge to the same state once updates stop and anti‑entropy completes.
11. How do Merkle trees help anti‑entropy synchronization?
Peers compare hash trees; mismatched branches pinpoint divergent keys so only missing or newer data is exchanged, saving bandwidth and verifying integrity.
12. Why is NAT traversal vital for consumer‑grade P2P apps?
Most users sit behind routers/firewalls; without traversal, peers couldn’t form direct connections and the network would fragment.
13. STUN vs. TURN—what’s the difference?
• STUN: Discover a peer’s public address and attempt UDP hole‑punching for a direct path.
• TURN: Fall‑back relay service that forwards traffic when direct traversal fails.
14. What role does ICE (Interactive Connectivity Establishment) play?
It orchestrates all candidate paths (host, STUN, TURN) and picks the first that succeeds, maximizing direct connectivity.
15. What is a Sybil attack and one common mitigation?
An attacker floods the network with fake identities to gain undue influence; mitigation: make identity creation expensive (proof‑of‑work, proof‑of‑stake, or stake‑weighted reputation).
16. Why are reputation systems (e.g., EigenTrust) useful in P2P?
They crowd‑source past behavior to prefer trustworthy peers and throttle or avoid malicious ones.
17. Describe the 'free‑rider problem' and a classic cure.
Peers download but never upload; BitTorrent’s choking algorithm (tit‑for‑tat) reduces their download speed, nudging them to contribute.
18. Name three real‑world P2P systems and their primary focus.
• BitTorrent – high‑throughput file distribution.
• IPFS/Filecoin – content‑addressable storage + tokenized incentives.
• Ethereum/Bitcoin – decentralized consensus & smart contracts.
19. What network‑health metric signals excessive churn?
Rising lookup latency or failure rate—routing tables can’t stabilize fast enough.
20. How does parallelism improve DHT lookup latency?
Query k (e.g., 3) nodes in parallel each hop; slow or failed peers no longer block progress, reducing tail latency.
21. Explain locality‑aware routing.
When multiple candidate neighbors exist, choose the one with lowest RTT / network proximity to reduce path latency and cross‑ISP traffic.
22. What is an eclipse attack?
A victim’s neighbor set is taken over by attacker nodes, isolating it and controlling all information it sees.
23. Name a common pitfall when many peers are behind symmetric NATs.
Connectivity collapses onto a few relay nodes, creating bottlenecks and higher latency.
24. What is protocol ossification and why is it harmful?
Middleboxes or legacy clients hard‑code assumptions about packet patterns, making it difficult to upgrade or secure the protocol later.
25. How can a network handle a flash‑crowd on a newly released file?
Seed with multiple high‑bandwidth sources initially or pre‑replicate pieces so early downloaders quickly multiply upload capacity.
26. When should you choose an unstructured overlay over a DHT?
In highly dynamic or small networks where churn is extreme and deterministic lookup isn’t worth the maintenance overhead.
27. How does BitTorrent combine structured and unstructured approaches?
Uses a structured DHT (Kademlia) for peer discovery, then an unstructured swarm mesh for actual data transfer.
28. Why must every P2P connection be encrypted and authenticated?
No central gatekeeper exists; peers must protect confidentiality, integrity, and prevent impersonation on hostile networks.
29. List three performance 'knobs' a P2P application can tune.
- Number of parallel piece requests or lookup queries.
- Cache / replicate popular content along query paths.
- Timeouts, retry back‑off, and adaptive congestion control (e.g. LEDBAT).