Introduction to database middleware


Database middleware is a software layer that connects databases and applications to simplify database management, improve performance and scalability, and provide additional functionality and services. In distributed systems and large-scale applications, database middleware plays an important role.

What is database middleware?

Database middleware is a software layer between the database system and the application. It acts as an abstraction layer, shielding the details of the underlying database and providing a simpler interface to applications. The main goal of database middleware is to provide higher performance, availability, scalability, and simplify database management.
There are three typical database middleware design solutions: proxy, smart-client, and unitized architecture.

Smart-client mode

Establish data sharding and routing rules through an independent logical layer to achieve preliminary management of a single database, enabling applications to connect to multiple single databases to achieve expansion of concurrency and storage capabilities. As part of the application system, it has a deep intrusion into the business. A typical product of this kind of client component is Sharding-JDBC.
Insert image description here

advantage

Simple to implement. Most database vendors have provided corresponding database driver drivers for different languages. For example, mysql provides mysql-connector-java driver for java language, and mysql-connector-python driver for python. The client communication protocol is already at the driver level. Did it. Therefore, middleware in smart-client mode usually only needs to be encapsulated on this basis.

Natural decentralization. The smart-client method is directly introduced by the application in the form of SDK. As the application is deployed on different nodes, it is directly connected to the database, and there is no need for a proxy layer in the middle. Therefore, except for network resources, there is basically no competition for any other resources, and there is no need to consider high availability issues. As long as all application nodes are not down, the database can be accessed.

shortcoming

Usually only a certain language is supported. For example, tddl, zebra, and sharding-jdbc are all developed using the Java language, so users using other languages ​​cannot use these middleware. If other languages ​​are to be used, then multi-language clients must be developed.
Version upgrade is difficult. Because an application uses a data source proxy to introduce a dependency on a jar package. When multiple applications depend on a certain version of the jar package, once this version has bugs, all applications need to be upgraded. Upgrading the database proxy is relatively easy, because the service is deployed separately. As long as the proxy server is upgraded, all applications connected to the proxy will naturally be upgraded.

Proxy mode

It manages data rules and routing rules in the form of independent middleware, exists as an independent process, and is isolated from the business application layer and single database, reducing the impact on applications. With the development of agent middleware, some distributed transaction processing capabilities will also be derived. A typical product of this middleware is MyCat.
Insert image description here

advantage

Multi-language support. No matter you use php, java or other languages, it can be supported. Taking the mysql database as an example, if the proxy itself implements the mysql communication protocol, then you can regard it as a mysql server. The official mysql team provides different client drivers for different languages, such as mysql-connector-java in java language, mysql-connector-python in python language, etc. Therefore, developers of different languages ​​can use the corresponding driver officially provided by mysql to establish communication with this proxy server.
Be transparent with business development students. Since proxy can be used as a mysql server, theoretically, business students do not need to make too many code modifications to complete the access.

shortcoming

Implementation is complex. Because proxy needs to implement the communication protocol on the server side of the database being proxied, implementation is difficult. Usually we see some proxy mode database middleware, which can actually only proxy a certain kind of database, such as mysql. There is almost no database middleware that can proxy multiple databases (sqlserver, PostgreSQL, Oracle) at the same time.
The proxy itself needs to ensure high availability. Since the application originally accessed the database directly, it now accesses the proxy, which means that the proxy must ensure high availability. Otherwise, the proxy hangs up and the database cannot be accessed normally, which is embarrassing.
Tenant isolation. There may be multiple applications accessing the underlying database of the proxy, which will inevitably cause resource competition for the proxy's own memory, network, CPU, etc. The proxy needs to have the ability to isolate.

unit architecture

The unitized architecture is a complete reconstruction of the business application system. The application system is split into several instances, and an independent single database is configured to allow each instance to manage a certain range of data. For example, for the food delivery system, independent application instances can be built for each city to manage their own data. When cross-city business occurs, orders are placed by migrating user information.
Insert image description here

advantage

Flexible expansion. The unitized architecture uses unified segmentation rules to split the application layer and data layer three-dimensionally. Whether it is an elastic expansion or contraction scenario or a multi-location and multi-center scenario, the number of logical "slices" can be freely divided according to the data center capacity. .
The network consumes less time and the link stability is high. The unitized architecture uses "units" to form a closed loop of logical calls and data access within the "unit". Only a few calls in specific scenarios will be accessed across units. In this way, almost most requests can be returned within the region, which greatly improves the efficiency of the unit. This reduces access time, avoids service disruption caused by cross-regional access link congestion, and improves link stability. What is important is the significant fault isolation effect brought by the unit, and the observability of the link has also been significantly improved, that is, the above-mentioned problems caused by cross-regional access are shielded from the link access level.

shortcoming

Complex scheduling management. First, a unified unitized rule center needs to be determined to store and issue unitized rules. The implementation method can be to implement the unitized rule service by itself, or to use the registration configuration center, or the two can coexist. It is difficult to change unitization rules after they are enabled, so you need to be careful when choosing the splitting dimensions of unitized slices.
Renovation costs are high. Unitization requires thinking about infrastructure transformation from a global perspective. Construction means that now or in the future, we need to buy more machines, build more computer rooms, and build more framework platforms for support, as well as various various problems brought about by the architecture upgrade process. Such problems require more money, people, and time.
The risk is high. Unitization transformation involves many participants, takes a long time to implement, and has a large business impact. For example, architects need to redesign the architecture, R&D personnel need to adapt and develop for unitization, operation and maintenance personnel need to purchase and deploy, and testers need to fully implement the unitization transformation. Return to all businesses, etc. Problems in one of them may cause delays or create hidden dangers.

Summarize

Way advantage shortcoming
Proxy mode 1. Multi-language support
2. Transparent to business development
1. Complex implementation
2. Proxy needs to ensure high availability
3. Tenant isolation needs to be considered
Smart-client mode 1. Simple to implement and easy to use
2. Naturally decentralized
1. Usually only supports a certain language
2. Version upgrade is difficult
unitization 1. Flexible expansion
2. Low network consumption and high link stability
1. Requires complex management and scheduling
2. High transformation cost 3. High risk

Guess you like

Origin blog.csdn.net/u011397981/article/details/135185209