GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing apple.github.io — Architecture — FoundationDB 8.0.1 documentation ArchitectureFoundationDB makes your architecture flexible and easy to operate. Your applications can send their data directly to FoundationDB or to a layer, a user-written module that can provide a new data model, compatibility with existing systems, or even serve as an entire framework. In both cases, all data is stored in a single place via an ordered, transactional key-value API. The following diagram details the logical architecture.
Detailed FoundationDB ArchitectureThe FoundationDB architecture chooses a decoupled design, where processes are assigned different heterogeneous roles (e.g., Coordinators, Storage Servers, Master). The cluster attempts to recruit different roles as separate processes, however, it is possible that multiple stateless roles get colocated (recruited) on a single process to meet the cluster recruitment goals. Scaling the database is achieved by horizontally expanding the number of processes for separate roles: CoordinatorsAll clients and servers connect to a FoundationDB cluster with a cluster file, which contains the IP:PORT or HOSTNAME:PORT of the coordinators. Both the clients and servers use the coordinators to connect with the cluster controller. The servers will attempt to become the cluster controller if one does not exist, and register with the cluster controller once one has been elected. Clients use the cluster controller to keep an up-to-date list of GRV proxies and commit proxies. Cluster ControllerThe cluster controller is a singleton elected by a majority of coordinators. It is the entry point for all processes in the cluster. It is responsible for determining when a process has failed, telling processes which roles they should become, and passing system information between all of the processes. MasterThe master is responsible for coordinating the transition of the write sub-system from one generation to the next. The write sub-system includes the master, GRV proxies, commit proxies, resolvers, and transaction logs. The three roles are treated as a unit, and if any of them fail, we will recruit a replacement for all three roles. The master provides the commit versions for batches of the mutations to the commit proxies. Historically, Ratekeeper and Data Distributor were coupled with the Master on the same process. Since 6.2, both have become singletons in the cluster. Their lifetimes are no longer tied to the Master.
GRV ProxiesThe GRV proxies are responsible for providing read versions and communicating with Ratekeeper to control the rate of providing read versions. To provide a read version, a GRV proxy will ask the master for the largest committed version at this point in time, while simultaneously checking that the transaction logs have not been stopped. Ratekeeper will artificially slow down the rate at which the GRV proxy provides read versions. Commit ProxiesThe proxies are responsible for committing transactions, reporting committed versions to the master, and tracking the storage servers responsible for each range of keys. Commits are accomplished by:
The key space starting with the Transaction LogsThe transaction logs make mutations durable to disk for fast commit latencies. The logs receive commits from the commit proxy in version order, and only respond to the commit proxy once the data has been written and fsync’ed to an append-only mutation log on disk. Before the data is even written to disk we forward it to the storage servers responsible for that mutation. Once the storage servers have made the mutation durable, they pop it from the log. This generally happens roughly 6 seconds after the mutation was originally committed to the log. We only read from the log’s disk when the process has been rebooted. If a storage server has failed, mutations bound for that storage server will build up on the logs. Once data distribution makes a different storage server responsible for all of the missing storage server’s data we will discard the log data bound for the failed server. ResolversThe resolvers are responsible for determining conflicts between transactions. A transaction conflicts if it reads a key that has been written between the transaction’s read version and commit version. The resolver does this by holding the last 5 seconds of committed writes in memory, and comparing a new transaction’s reads against this set of commits. Storage ServersThe vast majority of processes in a cluster are storage servers. Storage
servers are assigned ranges of keys and are responsible for storing all
of the data for that range. They keep 5 seconds of mutations in memory,
and an on-disk copy of the data as of 5 seconds ago. Clients must read at
a version within the last 5 seconds, or they will get a
Data DistributorThe data distributor manages the lifetime of storage servers, decides which storage server is responsible for which data range, and ensures data is evenly distributed across all storage servers (SS). The data distributor, as a singleton in the cluster, is recruited and monitored by the Cluster Controller. See internal documentation. RatekeeperRatekeeper monitors system load and slows down client transaction rate when the cluster is close to saturation by lowering the rate at which the proxy provides read versions. Ratekeeper, as a singleton in the cluster, is recruited and monitored by the Cluster Controller. ClientsA client links with specific language bindings (i.e., client libraries) in order to communicate with a FoundationDB cluster. The language bindings support loading multiple versions of C libraries, allowing the client to communicate with FoundationDB clusters running older versions. Currently, C, Go, Python, Java, and Ruby bindings are officially supported. Transaction ProcessingA database transaction in FoundationDB starts by a client contacting one of the GRV proxies to obtain a read version, which is guaranteed to be larger than any commit version that the client may know about (even through side channels outside the FoundationDB cluster). This is needed so that a client will see the result of previous commits that have happened. Then the client may issue multiple reads to storage servers and obtain values at that specific read version. Client writes are kept in local memory without contacting the cluster. By default, reading a key that was written in the same transaction will return the newly written value. At commit time, the client sends the transaction data (all reads and writes) to one of the commit proxies and waits for a commit or abort response from the commit proxy. If the transaction conflicts with another one and cannot commit, the client may choose to retry the transaction from the beginning. If the transaction commits, the commit proxy also returns the commit version to the client and to the master so that GRV proxies can access the latest committed version. Note that this commit version is larger than the read version and is chosen by the master. The FoundationDB architecture separates the scaling of client reads and writes (i.e., transaction commits). Because clients directly issue reads to sharded storage servers, reads scale linearly to the number of storage servers. Similarly, writes are scaled by adding more processes to Commit Proxies, Resolvers, and Log Servers in the transaction system. Determine Read VersionWhen a client requests a read version from a GRV proxy, the GRV proxy asks the master for the latest committed version and checks that a set of transaction logs satisfying the replication policy is live. Then the GRV proxy returns the maximum committed version as the read version to the client.
The GRV proxy contacts the master for the latest committed versions because the master is a central place for keeping the largest committed version reported by all commit proxies. Checking that a set of transaction logs satisfying the replication policy is live ensures that the GRV proxy has not been replaced by a newer generation of GRV proxies. This is because GRV proxy is a stateless role recruited in each generation. If a recovery has happened and the old GRV proxy is still live, this old GRV proxy could still give out read versions. As a result, a read-only transaction may see stale results (a read-write transaction will be aborted). By checking a set of transaction logs satisfying the replication policy is live, the GRV proxy makes sure no recovery has happened, thus the read-only transaction sees the latest data. Note that the client cannot simply ask the master for read versions because this approach puts more work on the master, whose role cannot be scaled. Even though providing read versions is not very expensive, it still requires the master to get a transaction budget from Ratekeeper, batch requests, and potentially maintain thousands of network connections from clients.
Transaction CommitA client transaction commits in the following steps:
Note that the commit proxy sends each resolver its respective key ranges. If any one of the resolvers detects a conflict, then the transaction is not committed. This has the flaw that if only one of the resolvers detects a conflict, the other resolver will still think the transaction has succeeded and may fail future transactions with overlapping write conflict ranges, even though these future transactions can commit. In practice, a well-designed workload will only have a very small percentage of conflicts, so this amplification will not affect performance. Additionally, each transaction has a five-second window. After five seconds, resolvers will remove the conflict ranges of old transactions, which also limits the chance of this type of false conflict.
Background WorkThere are a number of background tasks happening in addition to transaction processing:
Transaction System RecoveryThe transaction system implements the write pipeline of the FoundationDB cluster and its performance is critical to the transaction commit latency. A typical recovery takes about a few hundred milliseconds, but longer recoveries (usually a few seconds) can happen. Whenever there is a failure in the transaction system, a recovery process is performed to restore the transaction system to a new configuration, i.e., a clean state. Specifically, the Master process monitors the health of GRV Proxies, Commit Proxies, Resolvers, and Transaction Logs. If any one of the monitored processes fails, the Master process terminates. The Cluster Controller will detect this event, and then recruits a new Master, which coordinates the recovery and recruits a new transaction system instance. In this way, the transaction processing is divided into a number of epochs, where each epoch represents a generation of the transaction system with its unique Master process. For each epoch, the Master initiates recovery in several steps. First, the Master reads the previous transaction system states from Coordinators and locks the coordinated states to prevent another Master process from recovering at the same time. Then the Master recovers previous transaction system states, including all Log Servers’ information, stops these Log Servers from accepting transactions, and recruits a new set of GRV Proxies, Commit Proxies, Resolvers, and Transaction Logs. After the previous Log Servers are stopped and a new transaction system is recruited, the Master writes the coordinated states with the current transaction system information. Finally, the Master accepts new transaction commits. See details in this documentation. Because GRV Proxies, Commit Proxies, and Resolvers are stateless, their recoveries require no extra work. In contrast, Transaction Logs save the logs of committed transactions, and we need to ensure all previously committed transactions are durable and retrievable by storage servers. That is, for any transactions that the Commit Proxies may have sent back commit responses, their logs are persisted in multiple Log Servers (e.g., three servers if replication degree is 3). Finally, a recovery will fast forward time by 90 seconds, which would
abort any in-progress client transactions with ``commit_result_unknown`` error: If a recovery happens while a
transaction is committing (i.e., after a commit proxy has sent mutations to
transaction logs), a client may receive
ResourcesExisting Architecture Documentation |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |