Search code examples
network-programmingdistributed-computingdistributed-system

What is the difference between P2P and Client-Server Architectural model in Distributed Systems


So we have two architectural models in distributed systems, P2P and Client-Server

I'm already familiar with both concepts in general networking, but it has come to my understanding that in a Client-Server model, the server might as well be a client to another server, which really confuses me because wouldn't that basically be similar to P2P where every computer is considered a "peer"? Why have the two models anyway?


Solution

  • It's not a very precise question, so excuse me if the answer isn't what you had in mind. Essentially, the Client/Server (C/S) and Peer-to-Peer (P2P) models express two different kinds of communication pattern: asymmetric and symmetric, respectively. In the C/S model, each participant is doing something quite different: one might be sending mail, and the other receiving it, or one is a web browser wanting content, and the other a server dishing it out. The P2P model involves participants cooperating among themselves to achieve the same task, such as file-sharing.

    Perhaps what's confusing you about the C/S model is a pattern like a proxy, in which the proxy server is a server to some nodes, and a client to others. This is still very much the C/S rather than P2P model of operation, but the proxy operates in both the client and server roles, quite likely using the same protocol in both cases (it's generally called a "gateway" when the protocols are different). In the case of an HTTP proxy, for example, the browser client treats the HTTP proxy much like an ordinary web server. In fact, the proxy may be the web server as far as the browser is concerned: most decently large-scale websites are actually many servers behind load-balancing proxies, or similar. The proxy may not hold the data that is being requested, in which case it fetches it from some other web server in the role of a client.

    P2P protocols, in contrast, tend to be doing the same thing at each node. Torrent-like file-sharing is an obvious example: participating nodes are distributing files between themselves. Some nodes have data which other nodes want. There may be nodes which are mostly receiving data (leechers) and nodes which are mostly sending data (seeders), but the protocol is the same for all participants.

    Some applications will even benefit from a hybrid approach. In telecommunication applications, you generally want some nodes acting as servers in order to facilitate things like call establishment, but once a call is taking place, it's best if the end-nodes can communicate directly with each other as peers.