P2P Network Architectures
P2P (peer-to-peer) networks distribute tasks and resources across all participating nodes rather than relying on a central server. This architecture fundamentally changes how systems scale, tolerate faults, and balance load. Each device acts as both client and server, contributing storage, bandwidth, and processing power to the network.
Characteristics of P2P vs Client-Server
In a client-server architecture, dedicated servers handle requests from clients. A web browser (client) sends a request to a web server, which processes it and returns a response. The server is the single provider of the resource.
In a P2P architecture, every node can both request and provide resources. There's no central authority coordinating things. BitTorrent is a classic example: when you download a file, you're simultaneously uploading pieces of that file to other peers.
Key differences:
- Decentralization: P2P eliminates single points of failure. If one node goes down, the rest of the network keeps functioning. Client-server systems are vulnerable to server outages.
- Scalability: In client-server, adding more clients increases load on the server. In P2P, each new node adds capacity to the network because it brings its own resources. Skype originally used this model to scale voice calls without massive server infrastructure.
- Resource utilization: P2P nodes share idle storage, bandwidth, and CPU cycles. Folding@home distributes protein-folding computations across millions of volunteer machines, harnessing processing power that would otherwise sit unused.
- Privacy and anonymity: Direct node-to-node communication (without routing through a central server) makes monitoring harder. Tor leverages this principle, though Tor is technically an overlay network rather than a pure P2P file-sharing system.

Structured vs Unstructured P2P Networks
The distinction here comes down to how the overlay topology is organized and how content is located.
Unstructured P2P networks (e.g., Gnutella) have no predefined topology. Nodes connect to each other in an ad hoc fashion, and any node can join or leave freely.
- Content discovery relies on flooding (broadcasting queries to all neighbors, who forward them to their neighbors) or random walks (forwarding queries to a randomly chosen neighbor at each hop).
- These methods generate significant network overhead and provide no guarantee that content will be found, even if it exists in the network.
- Advantages: Simple to implement and maintain. Naturally resilient to node churn since there's no structure that needs repairing when nodes leave.
- Disadvantages: Search is inefficient, overhead scales poorly, and the network struggles as it grows large.
Structured P2P networks (e.g., Chord, Kademlia) assign each node a specific position in the overlay based on its identifier. The topology follows a well-defined structure such as a ring, tree, or hypercube.
- Content discovery uses distributed hash tables (DHTs) or similar lookup mechanisms, which can guarantee that data will be found if it exists.
- Advantages: Efficient, predictable search performance. Better scalability for large networks.
- Disadvantages: More complex to build and maintain. When nodes join or leave, the structure must be repaired, which adds overhead and can reduce resilience if not handled carefully.

Role of DHTs in P2P
A distributed hash table is a key-value store spread across all nodes in a structured P2P network. It solves a core problem: given a piece of data, how do you find which node is storing it?
Here's how DHTs work at a high level:
- Each data item is associated with a unique key, typically generated by hashing the data's name or content.
- Each node in the network is assigned an identifier (also a hash value) that places it at a specific position in the overlay topology.
- A mapping function determines which node is responsible for storing a given key. In a ring-based DHT like Chord, the node whose identifier is closest to the key (in the hash space) stores that data.
- When a node wants to look up a key, it uses a routing algorithm to forward the query hop-by-hop through the overlay until it reaches the responsible node.
The lookup complexity is typically , where is the number of nodes. This means doubling the network size only adds one extra routing hop on average.
Different DHT designs use different overlay structures. Chord organizes nodes in a ring. Pastry uses a tree-like prefix-based routing table. CAN (Content-Addressable Network) maps nodes onto a multi-dimensional coordinate space. Kademlia uses an XOR-based distance metric and is widely deployed in BitTorrent clients.
Load balancing is built into the DHT design. Consistent hashing distributes keys roughly evenly across all nodes, so no single node gets stuck storing a disproportionate share of the data.
Properties of P2P Architectures
Scalability
- Unstructured networks hit scalability walls because flooding-based search generates traffic that grows faster than the network itself.
- Structured networks with DHTs scale much better. Since lookup cost grows as , a network of 1 million nodes only requires about 20 hops per lookup.
Fault Tolerance
- Unstructured networks handle node failures gracefully by default. There's no structure to break, so a departing node just means fewer connections.
- Structured networks require explicit mechanisms to stay resilient. Replication (storing copies of data on multiple nodes) and redundant routing paths ensure that data remains accessible even when responsible nodes fail. Without these mechanisms, a single node failure could make certain keys unreachable.
Load Balancing
- Unstructured networks can develop hotspots where popular content concentrates on a few nodes, overloading them while others sit idle.
- Structured networks with DHTs distribute keys evenly by design. Consistent hashing ensures each node handles a roughly equal portion of the key space, preventing any single node from becoming a bottleneck.