Public for the first time! Alibaba Cloud Open Source PolarDB Overall Architecture and Enterprise Features

Alibaba Cloud Open Source PolarDB.Introduction:

Alibaba Cloud Open Source PolarDB. At the Alibaba Cloud Open Source PolarDB Enterprise Architecture Conference on March 2, Beixia, an expert in the core technology of Alibaba Cloud PolarDB , gave a wonderful speech on the theme of " PolarDB Overall Architecture Design and Enterprise Features".

PolarDB Enterprise Architecture Conference on March 2, Beixia , an expert in the core technology of Alibaba Cloud
PolarDB , gave a wonderful speech on the theme of " PolarDB Overall Architecture Design and Enterprise Features". It mainly shares the storage and computing separation architecture, HTAP architecture, and node high-availability architecture are the three architectures that PolarDB can support. PolarDB also has enterprise-level features of availability, high performance, and security. And analyze the overall architecture and enterprise-level features of PolarDB .
Live review video: https://developer.aliyun.com/topic/PolarDB_release
PDF download: https://developer.aliyun.com/topic/download?id=8348
The following is organized according to the video content of the conference speech:
PolarDB is a cloud-native database independently developed by Alibaba Cloud. Its source code has been fully open sourced (source code repository address: https://github.com/ApsaraDB/PolarDB-for-PostgreSQL ). The following will explain the overall architecture and enterprise-level features of open source PolarDB in detail.

1. Alibaba Cloud Open Source PolarDB.Overall architecture design of PolarDB


The infrastructure of PolarDB is cloud-native. A traditional database consists of a main database, a standby database, and a Standby node. The main database replicates the redo log to the standby database. The architecture of traditional databases has the following four problems:
① Poor scalability. When adding nodes, you need to completely copy the data first, which usually takes hours or even longer.
② poor reliability. Synchronous replication is required between the primary database and the standby database , which will result in a performance drop of more than 20%; if asynchronous replication is used, there will be a risk of data loss.
③ Poor usability. After the primary database fails, HA will switch to the standby database. The new standby database needs to play back a large number of redo logs to enter the serviceable state, which may take minutes.
④The cost is high. The storage cost increases linearly with the number of nodes, and some resources need to be reserved.
In order to completely solve the above problems, PolarDB proposes a cloud-native architecture to decouple computing and storage resources.

On the left side of the above figure is a traditional database. Its CPU, memory, and storage are all on one server, which is called the integration of computing and storage. On the right is the architecture of PolarDB , which is divided into two types of nodes: computing nodes and storage nodes. Data is stored in a storage pool composed of storage nodes, and each computing node reads the data in the storage pool through a high-speed network.

The advantages of the architecture that separate computing and storage lie in the following aspects:
①Extreme and elastic scalability: storage and computing can be independently expanded.
②Reduce storage costs: then how many computing clusters are expanded, there is always only one copy of the data.
③Ease of use: It has the advantages of distributed and the somatosensory of a single-machine database, because each computing node can see all the data. For users, any computing node is equivalent to a stand-alone database.
④High reliability: The underlying shared storage provides the functions of three copies and second-level snapshots, providing a more convenient way for database backup.
PolarDB not only designs and develops an architecture that separates computing and storage, but also performs a lot of optimization on the module stack of the database.

In the transaction layer, CSN snapshots are implemented to replace the traditional transaction snapshots; in the log layer, a core data structure such as LogIndex is implemented , which solves the unique past page and future page data problems encountered under the separation of computing and storage architecture. At the same time, delayed playback and parallel playback are realized; in the cache layer, the resident BufferPool and multi-version pages are realized; in the storage layer, the ability of pre-reading and pre-expansion of DirectIO model pages is realized.

In addition, users often need to perform complex analysis and query on the data of TP transactions, such as making summary reports and reconciliations at night. Such queries are generally some very complex SQL, but the concurrency is not high, which is a typical OLAP scenario.
Initially , PolarDB 's computing and storage separation architecture can only be calculated by a single computing node when processing such complex SQL, which cannot exert the overall computing power of the computing cluster, and at the same time there is no way to take advantage of the large bandwidth of the storage pool.

There are usually two types of solutions in the industry at that time:
① Deploy an AP system outside the original TP system, and import the TP transaction data to the AP system through the log. The problem with this solution is that the delay between the two systems is relatively high, which will result in low data freshness. In addition, deploying an independent AP system will increase the cost of storage and operation and maintenance.
② Execute AP query locally on the original TP system, but this will inevitably cause the two services of TP and AP to affect each other. In addition, there is no way for the AP system to expand elastically.
Therefore, PolarDB has developed a distributed computing engine based on shared storage, which is also the first solution in the industry. This solution has the following advantages:

①It is an integrated storage solution, TP and AP share a data stored on the shared storage. Compared with the two systems, it reduces storage costs and provides millisecond-level data freshness, that is, a piece of data inserted in the TP system can be queried in milliseconds in the IP system.
② TP and IP are physically isolated and do not affect each other. Some computing nodes execute stand-alone engines to process high-concurrency TP queries, while other nodes execute distributed query engines to process complex AP queries.
③ It has the ability to expand elastically. When the system faces some complex SQL, if the computing power is insufficient , computing nodes can be quickly added, and new nodes can also be quickly added to the cluster of distributed computing engines.
Compared with the traditional OLAP system, it is an instant system that does not need to redistribute and redistribute data, and the performance has been greatly improved.

Implementing a complete distributed computing engine on shared storage needs to implement the following modules:
① Distributed optimizer. The optimizer generates a distributed execution plan number according to the data distribution characteristics. PolarDB is a secondary development based on the GPORCA optimizer framework. During the development process, the optimizer needs to be aware that the data is shared. The GPORCA optimizer framework is based on share-nothing, so applying to PolarDB is bound to add a lot of rule conversions.
② Distributed executor. In order to implement a distributed executor, a complete set of parallelized operators needs to be implemented. For example, when doing data scanning, because the underlying data in PolarDB is shared, each computing node needs to parallelize the scanning operation word when doing sequential scanning . These operators are finally assembled into a volcano execution model.
③ transaction consistency. Since distributed execution spans multiple computing nodes, it is necessary to use unified data locations and snapshots to determine the visibility of transactions, so as to ensure that the data queried by each node is full-value consistent data.
④ SQL is fully compatible. In order to enable the new distributed computing engine to be used by the user's business, a lot of development work for compatibility with the SQL standard is also required.

Implementing a complete distributed computing engine on shared storage needs to implement the following modules:
① Distributed optimizer. The optimizer generates a distributed execution plan number according to the data distribution characteristics. PolarDB is a secondary development based on the GPORCA optimizer framework. During the development process, the optimizer needs to be aware that the data is shared. The GPORCA optimizer framework is based on share-nothing, so applying to PolarDB is bound to add a lot of rule conversions.
② Distributed executor. In order to implement a distributed executor, a complete set of parallelized operators needs to be implemented. For example, when doing data scanning, because the underlying data in PolarDB is shared, each computing node needs to parallelize the scanning operation word when doing sequential scanning . These operators are finally assembled into a volcano execution model.
③ transaction consistency. Since distributed execution spans multiple computing nodes, it is necessary to use unified data locations and snapshots to determine the visibility of transactions, so as to ensure that the data queried by each node is full-value consistent data.
④ SQL is fully compatible. In order to enable the new distributed computing engine to be used by the user's business, a lot of development work for compatibility with the SQL standard is also required.

PolarDB architectures mentioned above , users can freely combine them according to business scenarios. For example, through the combination of cloud native + HTAP, services that require elasticity, TP, and AP can be met. Moreover, the free combination of the three architectures is implemented in a set of binaries, and the user only needs to perform a simple configuration in the configuration file to realize the free combination of the three architectures.

2. Alibaba Cloud Open Source PolarDB.PolarDB Enterprise Features


There are four aspects to the enterprise-level features of
PolarDB . ①Architectural support, which has been explained in detail in the previous article, will not be repeated here.
②High performance.
•1) PolarDB implements the pipeline of CSN snapshot and WAL log, which solves the problem of high concurrency lower critical section.
•2) Implemented the optimization of read-ahead and pre-expansion, RelSizeCache and CLOG. Then these optimizations are optimizations for IO under the DirectIO model. After the storage and computing are separated, each IO of the storage needs to access the back-end storage pool through the network, which is different from the native scenario, so a lot of optimization work is required.
•3) Developed the logIndex core data structure, which records the redo logs that occurred in the history of each page. It can not only solve the data correctness problem of past pages and future pages unique to the separation of computing and storage, but also solve the half-write problem unique to PB databases.
③High availability.
•1 ) Implemented DataMax , which provides log mode to support the deployment of two locations and three centers , and also implements Online Promote, delayed playback and parallel playback. These three major functions optimize the speed of crash recovery and shorten the unavailable time when the DB process crashes.
•2) The resident BufferPool is implemented . After the DB process restarts, the buffer needs to be re-initialized, and the current machine configuration will cause the buffer to become larger and larger, which makes the initialization of the buffer take a lot of time.
•3) Replication Slot is provided to solve the problem of slot loss during DB failover. It uses shared storage to store slot information on shared storage, thus solving the problem of lost replication slots.
•4) The memory control at the operator level is implemented, and an upper limit is set for the memory of each operator to avoid the collapse of the entire DB process due to too much memory of a single operator.
④Safety . PolarDB provides the function of transparent encryption to ensure that the data stored on the disk is encrypted data. Currently, transparent encryption supports AES 128-bit and AES 256-bit encryption algorithms as well as the national secret SM4.

3.Alibaba Cloud Open Source PolarDB.PolarDB open source community


PolarDB has been open sourced to github . Source code warehouse address: https://github.com/ApsaraDB/PolarDB-for-PostgreSQL

In the process of open source, our strategy is to be 100% compatible with the community standard PostgreSQL, to ensure that users can seamlessly migrate from standard stand-alone PostgreSQL to PolarDB . Second, we open source all components, including the PolarDB kernel, the PolarDB distributed file system, and the PolarDB cloud management and control , and promise that the open source code is exactly the same as the code on the public cloud .

While opening the cloud code, we also provide a wealth of documents and video materials, such as architecture principle documents, core function documents, and quick start documents.

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00