P2P networks are like a group of friends sharing resources without a leader. Each person can give and receive, creating a system where everyone's equal. This setup allows for direct sharing and decision-making among all participants.
Distributed systems are like a team working on a project together. They're designed to handle big tasks, keep working even if someone drops out, and share the workload. They use special ways to talk and make decisions as a group.
Peer-to-Peer (P2P) Networks and Decentralization
P2P Network Architecture
- P2P networks consist of interconnected nodes that share resources and perform tasks without relying on a central server
- Nodes in a P2P network act as both clients and servers, allowing them to consume and provide services simultaneously
- P2P networks enable direct communication and resource sharing between nodes, eliminating the need for intermediaries (BitTorrent)
- Decentralization is a key characteristic of P2P networks, where control and decision-making are distributed among participating nodes
Network Topology and Node Roles
- Network topology refers to the arrangement and interconnection of nodes in a P2P network
- Common P2P network topologies include unstructured (Gnutella) and structured (Chord) networks
- Unstructured networks have a random or ad-hoc organization, while structured networks follow a specific overlay structure
- Nodes in a P2P network can assume different roles based on their capabilities and responsibilities
- Full nodes maintain a complete copy of the network's data and participate in validating and propagating transactions (Bitcoin full nodes)
- Light nodes, also known as thin clients, rely on full nodes for network interactions and only store relevant data (SPV clients in Bitcoin)
Distributed Systems Fundamentals
Characteristics and Benefits
- Distributed systems consist of multiple interconnected computers that work together to achieve a common goal
- Key characteristics of distributed systems include scalability, fault tolerance, and resource sharing
- Scalability enables distributed systems to handle increasing workloads by adding more nodes to the network (horizontal scaling)
- Fault tolerance ensures that the system continues to operate correctly even in the presence of node failures or network disruptions
Communication and Coordination
- Network protocols define the rules and formats for communication between nodes in a distributed system
- Examples of network protocols include TCP/IP for reliable data transfer and HTTP for web-based interactions
- Nodes in a distributed system coordinate their actions and share information to maintain consistency and achieve desired outcomes
- Coordination mechanisms, such as consensus algorithms (Paxos, Raft), enable nodes to agree on a shared state or make collective decisions
- Message passing is a fundamental communication paradigm in distributed systems, where nodes exchange messages to share data and trigger actions
Advanced P2P Concepts
Distributed Hash Tables (DHTs)
- DHTs are a class of decentralized systems that provide efficient lookup and storage of key-value pairs across a P2P network
- DHTs enable scalable and fault-tolerant storage and retrieval of data without relying on a central authority
- Key features of DHTs include distributed indexing, self-organization, and load balancing among participating nodes
- Examples of DHT implementations include Kademlia, which is used in BitTorrent for peer discovery, and Chord, which provides a ring-based topology for efficient lookups
Overlay Networks and Routing
- Overlay networks are logical networks built on top of existing physical networks to provide additional functionality and abstractions
- P2P networks often utilize overlay networks to enable efficient routing and resource discovery
- Examples of overlay networks include Freenet for anonymous and censorship-resistant communication
- Routing in P2P networks involves determining the path for messages to travel from source to destination nodes
- Structured P2P networks employ deterministic routing algorithms based on the overlay topology (Chord's finger tables)
- Unstructured P2P networks rely on flooding or random walk techniques to propagate queries and locate resources (Gnutella's query flooding)