> For the complete documentation index, see [llms.txt](https://ret2basic.gitbook.io/ctfnote/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ret2basic.gitbook.io/ctfnote/computer-science/distributed-systems/architecture/system-architectures.md).

# System Architectures

Centralization vs. Decentralization

## Centralized Organizations

* **Simple Client-Server Architecture**: client $$\Longleftrightarrow$$ server
  * Request-reply behavior
* **Multitiered Architectures**
  * **two-tiered** architecture: **client** machine and **server** machine
    * User interface
    * Application
    * Database
  * **three-tiered** architecture: **a server also acts as a client**
    * Client
    * Application server
    * Database server

## Decentralized Organizations

### Concepts

* **Vertical Distribution**
  * Placing logically different components on different machines.
* **Horizontal Distribution**
  * A client or server may be physically split up into logically equivalent parts, but each part is operating on its own share of the complete data set, thus balancing the load.
  * Peer-to-peer (P2P) systems support horizontal distribution.
* **Peer-to-Peer (P2P) Systems**
  * The processes that constitute a P2P system are all **equal**.
  * Each process will **act as a client and a server at the same time** (acting as a **servant**)
* **Overlay Network**
  * A network in which the **nodes** are formed by the processes and the **links** represent the possible communication channels (**TCP** connections).

### Structured Peer-to-Peer Systems

* Nodes are organized in an overlay that adheres to **a specific, deterministic topology**: a ring, a binary tree, a grid, etc.
* The topology is used to look up data by its **key**
  * Distributed hash table (DHT)
  * `key(data_item) = hash(data_item_value)`
  * `existing_node = lookup(key)`

### Unstructured Peer-to-Peer Systems

* Each node maintains **an ad hoc list of neighbors**.
* Data lookup requires **searching**
  * **Flooding:** a node sends the request to **all its neighbors** (expensive)
  * **Random walks:** a node asks **a randomly chosen neighbor** (takes longer time)
