New version!

A new version of this website is available at architectural-patterns.net.

Peer-to-peer (or P2P) networks, are used to share a large set of resources where each node (peer) contains only a subset of the resources. All nodes are responsible for both the upload and download of the resources.

Multiple nodes will contain the same resources and when one node requests a resource, it may be downloaded (seeded) from multiple nodes at the same time.

Examples

  • USENET
  • Filesharing services like Napster, Kazaa, and many others

Where does it come from?

Though the concept was much older, the architecture became popular with the advent of Napster (in 1999), the filesharing service that got into trouble because it was used for sharing illegal music and video copies.

When should you use it?

  • Use it when there is a large set of resources to be maintained and shared by a large group of people.
  • Use it for its lack of a single-point-of-failure. Any node may fail temporarily or permanently and the system will not suffer.

    How does it work?

    There are two aspects to be considered. The first is: how do the nodes know that the others exist?
    A new node is added when a person adds the address of this node to the address table of some other node already in the network.
    The nodes themselves forward the addresses to the nodes with which they are directly linked.

    The other aspect is resource discovery: how does one node know where to find a resource?
    The simple solution is to send a request to all peers and wait for the response.
    The advanced solution is the use of some sort of a data structure that tells each node where to find a resource.

    Problems

  • When the system is open, there is a chance that it will be misused.
  • Resource detection in a network with much churn (many nodes leaving and joining) is a hard problem.

    Common implementation techniques

    Links

  •