What is peer-to-peer (P2P)?

In computer science, a peer-to-peer (P2P) network consists of a group of devices that collectively store and share files. Each participant (node) acts as an individual peer. Typically, all nodes have equal power and perform the same tasks.

In financial technology, the term peer-to-peer usually refers to the exchange of cryptocurrencies or digital assets via a distributed network. A P2P platform allows buyers and sellers to execute trades without the need for intermediaries. In some cases, websites may also provide a P2P environment that connects lenders and borrowers.

P2P architecture can be suitable for various use cases, but it became particularly popular in the 1990s when the first file-sharing programs were created. Today, P2P networks are at the core of most cryptocurrencies, making up a great portion of the blockchain industry. However, they are also leveraged in other distributed computing applications, including web search engines, streaming platforms, online marketplaces, and the InterPlanetary File System (IPFS) web protocol.





How does P2P work?

In essence, a P2P system is maintained by a distributed network of users. Usually, they have no central administrator or server because each node holds a copy of the files - acting both as a client and as a server to other nodes. Thus, each node can download files from other nodes or upload files to them. This is what differentiates P2P networks from the more traditional client-server systems, in which client devices download files from a centralized server.

On P2P networks, the connected devices share files that are stored on their hard drives. Using software applications designed to mediate the sharing of data, users can query other devices on the network to find and download files. Once a user has downloaded a given file, they can then act as a source of that file.

Put in another way, when a node acts as a client, they download files from other network nodes. But when they are working as a server, they are the source from which other nodes can download files. In practice, though, both functions can be executed at the same time (e.g., downloading file A, and uploading file B).

Since every node stores, transmits and receives files, P2P networks tend to be faster and more efficient as their user base grows larger. Also, their distributed architecture makes P2P systems very resistant to cyberattacks. Unlike traditional models, P2P networks don’t have a single point of failure.

We may categorize peer-to-peer systems according to their architecture. The three main types are called unstructured, structured, and hybrid P2P networks.





Unstructured P2P networks

Unstructured P2P networks don’t present any specific organization of the nodes. The participants communicate randomly with one another. These systems are considered robust against high churn activity (i.e., several nodes frequently joining and leaving the network).

Although easier to build, unstructured P2P networks may require higher CPU and memory usage because search queries are sent out to the highest number of peers possible. This tends to flood the network with queries, especially if a small number of nodes is offering the desired content.





Structured P2P networks

In contrast, structured P2P networks present an organized architecture, allowing nodes to efficiently search for files, even if the content is not widely available. In most cases, this is achieved through the use of hash functions that facilitate database lookups.

While structured networks may be more efficient, they tend to present higher levels of centralization, and usually require higher setup and maintenance costs. Other than that, structured networks are less robust when faced with high rates of churn.





Hybrid P2P networks

Hybrid P2P networks combine the conventional client-server model with some aspects of the peer-to-peer architecture. For instance, it may design a central server that facilitates the connection between peers.

When compared to the other two types, hybrid models tend to present improved overall performance. They usually combine some of the main advantages of each approach, achieving significant degrees of efficiency and decentralization simultaneously.





Distributed vs. decentralized

Although the P2P architecture is inherently distributed, it’s important to note that there are varying degrees of decentralization. So, not all P2P networks are decentralized.

In fact, many systems rely on a central authority to guide the network activity, making them somewhat centralized. For instance, some P2P file-sharing systems allow users to search and download files from other users, but they are unable to participate in other processes, like managing search queries.

In addition, small networks controlled by a limited user base with shared goals could also be said to have a higher degree of centralization, despite the lack of a centralized network infrastructure.





The role of P2P in blockchains

In the early stages of Bitcoin, Satoshi Nakamoto defined it as a “Peer-to-Peer Electronic Cash System.” Bitcoin was created as a digital form of money. It can be transferred from one user to another through a P2P network, which manages a distributed ledger called blockchain.

In this context, the P2P architecture that is inherent to blockchain technology is what allows Bitcoin and other cryptocurrencies to be transferred worldwide, without the need for intermediaries nor any central server. Also, anyone can set up a Bitcoin node if they wish to participate in the process of verifying and validating blocks.

So, there are no banks processing or recording transactions in the Bitcoin network. Instead, the blockchain acts as a digital ledger that publicly records all activity. Basically, each node holds a copy of the blockchain and compares it to other nodes to ensure the data is accurate. The network quickly rejects any malicious activity or inaccuracy.

In the context of cryptocurrency blockchains, nodes can take on a variety of different roles. Full nodes, for example, are the ones that provide security to the network by verifying transactions against the system’s consensus rules.

Each full node maintains a complete, updated copy of the blockchain - allowing them to participate in the collective work of verifying the true state of the distributed ledger. It’s worth noting, though, that not all full validating nodes are miners.





Advantages

The peer-to-peer architecture of blockchains provides many benefits. Among the most important is the fact that P2P networks offer greater security than traditional client-server arrangements. The distribution of blockchains over large numbers of nodes renders them virtually immune to the Denial-of-Service (DoS) attacks that plague numerous systems.

Likewise, because a majority of nodes must establish consensus before data is added to a blockchain, it's almost impossible for an attacker to alter the data. This is especially true for big networks like the one of Bitcoin. Smaller blockchains are more susceptible to attacks because one person or group could eventually achieve control over a majority of nodes (this is known as a 51 percent attack).

As a result, the distributed peer-to-peer network, paired with a majority consensus requirement, gives blockchains a relatively high degree of resistance to malicious activity. The P2P model is one of the reasons why Bitcoin (and other blockchains) were able to achieve the so-called Byzantine fault tolerance.

Beyond security, the use of P2P architecture in cryptocurrency blockchains also renders them resistant to censorship by central authorities. Unlike standard bank accounts, cryptocurrency wallets can’t be frozen or drained by governments. This resistance also extends to censorship efforts by private payment processing and content platforms. Some content creators and online merchants adopted cryptocurrency payments as a way to avoid having their payments blocked by third parties.





Limitations

Despite their many advantages, the use of P2P networks on blockchains also has certain limitations.

Because distributed ledgers must be updated on every single node instead of on a central server, adding transactions to a blockchain requires a massive amount of computing power. While this provides increased security, it greatly reduces efficiency and is one of the main obstacles when it comes to scalability and widespread adoption. Nonetheless, cryptographers and blockchain developers are investigating alternatives that may be used as scaling solutions. Prominent examples include the Lightning Network, Ethereum Plasma, and the Mimblewimble protocol.

Another potential limitation relates to attacks that may arise during hard fork events. Since most blockchains are decentralized and open source, groups of nodes are free to copy and modify the code and split away from the main chain to form a new, parallel network. Hard forks are completely normal and not a threat on their own. But if certain security methods are not adopted properly, both chains may become vulnerable to replay attacks.

Moreover, the distributed nature of P2P networks makes them relatively difficult to control and regulate, not only in the blockchain niche. Several P2P applications and companies got involved with illegal activities and copyright infringements.





Closing thoughts

Peer-to-peer architecture can be developed and used in many different ways, and it is at the core of the blockchains that make cryptocurrencies possible. By distributing transaction ledgers across large networks of nodes, P2P architecture offers security, decentralization, and censorship resistance.

In addition to their usefulness in blockchain technology, P2P systems can also serve other distributed computing applications, ranging from file-sharing networks to energy trading platforms.