What does peer-to-peer (P2P) mean?

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

In technology focused on finance, the term peer-to-peer usually refers to the exchange of cryptocurrencies or digital assets through a distributed network. P2P platforms allow buyers and sellers to execute transactions without the need for intermediaries. In some cases, websites can also provide a P2P environment that connects lenders and borrowers.

The P2P architecture may be suitable for various use cases, but it became especially popular in the 1990s, when the first file-sharing programs were created. Today, P2P networks serve as the basis for most cryptocurrencies, and make up a large part of the blockchain industry. However, they are also used in other distributed computing applications, including web search engines, streaming platforms, online marketplaces, and the InterPlanetary File System (IPFS) web protocol.


How does a P2P system work?

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

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

In other words, when a node acts as a client, it will download files from other nodes on the network. While when it works as a server, it will become the source from which other nodes can download the files. In practice, however, both functions can be carried out simultaneously (for example, downloading file A and uploading file B).

Since each node stores, transmits, and receives files, P2P networks tend to become faster and more efficient as their user base grows. Furthermore, their distributed architecture makes P2P systems highly resistant to cyberattacks. Unlike traditional models, P2P networks do not have a single point of failure.

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


Unstructured P2P networks

Unstructured P2P networks do not present any specific organization of the nodes. Participants communicate with each other randomly. These systems are considered robust to high churn activity (i.e., when multiple nodes frequently join or leave the network).

Although they are easier to build, unstructured P2P networks can require more CPU and memory usage because search queries are sent to as many peers as possible. This tends to flood the network with queries, especially if only a small number of nodes offer the desired content.


Structured P2P networks

In contrast, structured P2P networks present an organized architecture, which allows nodes to search for files efficiently, even when the content is not widely disseminated. In most cases, this is achieved by employing hash functions that facilitate database searching.

Although structured networks can be more efficient, they tend to have higher levels of centralization and, usually, higher installation and maintenance costs. Aside from that, structured networks are less robust to high churn rates.


Hybrid P2P networks

Hybrid P2P networks combine the conventional client-server model with some aspects of peer-to-peer architecture. For example, they can designate a central server that facilitates connection between peers.

Compared to the other two types, hybrid models tend to feature improved overall performance. They typically combine some of the key advantages of each approach, allowing them to achieve significant degrees of efficiency and decentralization simultaneously.


Distributed vs. decentralized

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

In fact, many depend on a central authority that guides network activity, making them, to some extent, centralized systems. For example, some P2P file sharing systems allow users to search for and download files from other peers, but are unable to participate in other processes, such as managing search queries.

Furthermore, the degree of centralization of small networks, controlled by a limited user base and with shared objectives, can be considered higher, despite lacking 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 a blockchain.

In this context, the P2P architecture that is inherent to blockchain technology is what allows Bitcoin and other cryptocurrencies to be transferred around the world, without the need for intermediaries or any central servers. Additionally, anyone can set up a Bitcoin node if they want to participate in the block verification and validation process.

Therefore, there are no banks that process or record transactions on the Bitcoin network. Instead, the blockchain acts as a digital ledger that publicly records all activity. Basically, each node contains a copy of the blockchain and compares it with other nodes to ensure that 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 those that provide security to the network by verifying transactions against the system's consensus rules.

Each full node maintains a complete and up-to-date copy of the blockchain, allowing them to participate in the collective work of verifying the true state of the distributed ledger. However, it is worth noting that not all full validation nodes are miners.


Advantages

The peer-to-peer architecture of blockchains offers 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 a large number of nodes makes them virtually immune to Denial of Service (DoS) attacks that affect numerous systems.

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

As a result, the distributed peer-to-peer network coupled 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 so-called Byzantine Fault Tolerance.

Beyond security, the use of P2P architecture in cryptocurrency blockchains also makes them resistant to censorship by central authorities. Unlike standard bank accounts, governments cannot freeze or drain cryptocurrency wallets. 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 prevent third parties from blocking their payments.


Limitations

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

Because distributed ledgers must be updated on each node rather than on a central server, adding transactions to a blockchain requires a large amount of computing power. While this provides greater security, it greatly reduces efficiency and is one of the main obstacles when it comes to scalability and widespread adoption. However, cryptographers and blockchain developers are investigating alternatives that can be used as scaling solutions. Notable examples include the Lightning Network, Ethereum Plasma, and the Mimblewimble protocol.

Another potential limitation relates to attacks that may arise during hard fork events. As most blockchains are decentralized and open source, groups of nodes can copy and modify the code and separate from the main chain to form a new parallel network. Hard forks are completely normal and do not pose a threat in and of themselves. But if certain security methods are not adopted properly, both chains can become vulnerable to replay attacks.

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


In conclusion

Peer-to-peer architecture can be developed and used in many different ways, and is the core of the blockchains that make cryptocurrencies possible. By distributing transaction ledgers across large networks of nodes, the 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.