P2P vs. Client-Server

Before we move on with the details of BitTorrent, it's useful to do a quantitative comparison of the P2P architecture with the client-server architecture.

Quantitative Comparison of P2P with Client-Server

Let’s calculate how long it will take to transmit a file from one server to a number of clients based on both the P2P and server-client architectures. The calculations will be performed based on the following givens.

  • A server that can upload at a rate of upsup_s where upsup_s is the upload speed in bits/second.
  • There are NN clients all wanting to download the same file from the server. Client ii can upload at a rate of upiup_i bits/second and download at a rate of dwnidwn_i bits/second.
  • The size of the file that all the peers want is SS.

Client-Server

Let’s start with the client-server architecture. The following can be observed.

  • Since NN clients each want a file of size SS, the server will have to upload NSNS bits. The upload rate of the server is upsup_s so the server will take at least NSups\frac{NS}{up_s} time to transmit the file to all NN clients.
  • The client with the lowest download rate (dwnmin=min(dwni)dwn_{min} = min(dwn_i)) will take at least Sdwnmin\frac{S}{dwn_{min}} time to download the full file.

So, in total the time taken to transmit the file will be the maximum of both of the times above, i.e.:

max{NSups,Sdwnmin}\max{\{\frac{NS}{up_s},\frac{S}{dwn_{min}} \}}

P2P

We can make the following observations:

  • Initially, only the server has the file. It has to throw the file out into the network and to do that, it will take at least Sups\frac{S}{up_s} time. While the file is being sent out into the network of peers, they start to distribute it amongst themselves.
  • The peer with the lowest download rate (dwnmindwn_{min}) will take at least Sdwnmin\frac{S}{dwn_{min}} time to download the full file.
  • The file cannot be transmitted faster than the total upload speed of the entire network: (upsum={up1+up2+up3+...+upN}up_{sum} = \{up_1+up_2+up_3+...+up_N\}). Since the file has to be distributed to all NN peers, NSNS bits have to be transmitted, that will take NSupsum\frac{NS}{up_{sum}} time.

Therefore, the time taken in total to distribute a file of size SS to NN peers is:

max{Sups,Sdwnmin,NSupsum}\max{\{\frac{S}{up_s},\frac{S}{dwn_{min}} ,\frac{NS}{up_{sum}}\}}

Note that as the number of clients/peers, NN, grows, the time taken by the client-server architecture also grows. Here is a graph of how the distribution time grows for each architecture as the number of clients/peers grow:

Press + to interact
Graph of How p2p Scales vs Client-Server attributed
Graph of How p2p Scales vs Client-Server attributed

P2P networks are extremely mathematically scalable. The resources of a P2P system grows with the number of peers in the system. Thus, applications with P2P architecture are self-scaling.

Please attempt the question in the widget below. Our AI will evaluate your answer.

What are the considerations when choosing P2P over a client-server architecture?

Quick Quiz! #

1

In a client-server model, the rate at which a client can download a file is limited by the ______.

A)

server upload rate

B)

client download rate

C)

min( a , b )

Question 1 of 20 attempted

Let’s now get into how processes communicate!

Get hands-on with 1400+ tech skills courses.