Open In App

How P2P can scale by itself

Last Updated : 22 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will discuss the overview of client-server and peer to peer and will understand both with the help of example and will discuss how P2P can scale by itself in both cases. Let’s discuss it one by one.

Overview :
To understand how peer-to-peer can scale and to know why it is better than client-server architecture in some ways let’s first understand what is client-server.

  • Peer-to-peer networks are often created by collections of 12 or fewer machines. All of these computers use unique security to keep their data, but they also share data with every other node.
  • In peer-to-peer networks, the nodes both consume and produce resources. Therefore, as the number of nodes grows, so does the peer-to-peer network’s capability for resource sharing. This is distinct from client-server networks where an increase in nodes causes the server to become overloaded.
  • It is challenging to give nodes in peer-to-peer networks proper security because they function as both clients and servers. A denial of service attack may result from this.
  • The majority of contemporary operating systems, including Windows and Mac OS, come with software to implement peer

Client-Server :
Think of servers as a source and client as a receiver. Whatever receiver wants it can ask source and source in most of the cases will reply. But this receiver can’t reply to the same query if asked by any other receiver (client). So the source (server) here deals with all these queries from different clients alone. Now, this stuff asked by the client need not be just some text, but can be large size files may be of GBs. Now things are going to get a little interesting. Let’s try to understand with help of some graphics.                                   

This will help a little-bit

Example –                     

  • Assume there is n number of clients who each wants a file of size F bits (for simplicity) simultaneously which is sitting there on the server. The speed at which the server can upload files is let’s say Uₛ bits/sec (U subscript s). So, the server will be uploading n × F bits as it will be uploaded to every connected link simultaneously. 
So, under ideal condition time taken = (n × F / Uₛ) sec...... equation-1
  • Above we have discussed the time it will take for the server to upload on every link connected. But what if the upload speed of the server is not a concern, but the download speed of the client. Let’s again use some graphics.

Same as above with download speeds of clients added

  • Now suppose the server’s upload speed is more than enough required. Now time taken will be decided by client-side download speeds (denoted as d₁, d₂, d₃, ….dₙ in our diagram) to be precise the minimum of download speed.
i.e. Dₘᵢₙ = min (d₁, d₂, d₃, ….dₙ)
  • To download F bits size file the slowest download speed client(slowest) will
Take time = (F/Dₘᵢₙ) sec……………...equation-2
  • Now, these 2 observation will help us take out the time it will take from server to client to distribute the file.
Distribution time for client-server 
(D ꜀₋ₛ) ≥ max {n × F / Uₛ, F/Dₘᵢₙ}sec.
This means max 
{n × F / Uₛ, F/Dₘᵢₙ} 
will give the lower bound.
  • Or in another word we can say the minimum time for file distribution to all the clients won’t be less than the maximum of {n × F / Uₛ, F/Dₘᵢₙ}.
  • From here we can a conclusion that the time required to distribute the file will increase linearly with the number of clients downloading files simultaneously given by (n × F/ Uₛ). So, if say one day there are 100 people downloading the same file at once it is taking t time, and if on some other day there are 1000 people it will take 10 × t time (or more).

Peer to Peer :
If you understood client-server architecture then this is not any harder. We do have a server here too, which initiates a new connection. Now again, let’s use a graphic to get things clearer.

A peer to peer architecture

Example –

  • From above, we can see that in peer to peer every client is connected with some other clients too, which obviously shows that they can share among themselves too, the converse of what stated in client-server where every client was asking file from the server. Clients, here are what we also call peers (peers and clients can be used interchangeably) look they will also work as a server by sending data that they received to other peers resolving some traffic which otherwise server side alone had to handle. Also, U₁, U₂, … Uₙ show the upload speeds of these peers.
  • Starting with file which is again resting on server here server only sends each bit once into link(under ideal condition). So, we can say that minimum distribution time from this end will be (F/ Uₛ) (not less than this at least)… (3)
  • Now again peer with the slowest download speed can’t obtain all F bits of file in less than (F/Dₘᵢₙ) ….(4)
  • At last observe total upload speed which will be upload speed of server along with upload speed of every connected individual peer.
  • i.e. Uₜₒₜₐₗ = Uₛ + U₁ + U₂+…. + Uₙ also the combine file size to be uploaded by entire system would be n × F bits again so, each peer receives one copy of that file. This distribution time won’t be less than (n × F / Uₜₒₜₐₗ)….(5)
  • Now, putting observation 3,4 and 5 together
Distribution time(Dₚ₂ₚ) ≥ max {F/ Uₛ, F/Dₘᵢₙ, n × F / Uₜₒₜₐₗ}.
  • Further to compare both architectures let’s take the minimum distribution time of each architecture equal to their lower bound
i.e. D ꜀₋ₛ = max {n x F / Uₛ , F/Dₘᵢₙ} - for client server
Dₚ₂ₚ = max {F/ Uₛ, F/Dₘᵢₙ, n x F / Uₜₒₜₐₗ} - for peer to peer
  • Let’s start making some assumption again for simplicity — Dₘᵢₙ is not an issue if it is large enough and in peer to peer case Uₛ is enough to upload entire file into link very fast. Now if we plot a graph between number of peers (clients) and minimum distribution time we will get something like

Client-server vs peer to peer

  • Now from above diagram we can observe that as number of peers increases the minimum distribution time in client server is increasing linearly whereas in peer to peer with increasing number of peers it is scaling by itself. Moreover, we can also observe in client server the minimum distribution time is unbounded whereas in case of p2p the curve is getting bounded i.e. showing no matter how many peers it won’t exceed that limit. This scalability in p2p is due to peers being consumer and redistributors at same time.

References :
The book I used for reference -” Computer Networking a Top-Down Approach” -6th edition by James F. Kurose and Keith W. Ross.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads