Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to decompose a monolithic database to realize micro-service

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to decompose a single database to achieve micro-services". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. let's study and learn "how to decompose a single database to achieve micro-services".

Database by service mode

In the micro-service architecture, large data lakes need to be transformed into distributed databases to match specific services. Doing so creates the necessary separation of concerns between services that only need to access specific parts of the original database. This also helps teams that manage their own service sets to maintain the independent control they need.

According to the model recommended by Praful Todkar, decomposing a single database needs to be done at the same time as the services it supports-sometimes referred to as a database by service mode. This should be a step-by-step process and require the team to:

Separate a single service from a single unit and route traffic to it

Detach tables from the same database and match them to the service

Create a new, smaller database next to the table and route traffic to it

Removes previous data and schemas from the original database.

Separate services and tables

During the migration of microservices, reorganizing the entire database is a bit like changing tires while driving. Doing so can lead to a variety of failures and increase the chances of losing data or destroying functionality.

The right thing to do is to start small and make a logical separation between the old architecture and the new microservices. After you select the service to remove from the cell, create a new data table (or tables) that contains only the data required by the new service.

In this step, clear routing rules are critical. First, the team needs to reroute traffic from a single application to a new microservice. Then, they must transfer parts of the old single database to the table, which will eventually form the framework of the new database. All of these require modern networking capabilities, such as the service grid approach implemented by tools such as Istio.

Parity is also critical when converting detached tables into a new distributed database. Make sure that the data in the old and new databases is fully synchronized. After confirming the data parity, delete the table and old data from the previous database.

The usage pattern is easy to manage, but not too dependent.

A schema is a metadata set that describes the structure of the data in the database. Some teams prefer to organize data by schema, creating a unique database schema for each service rather than the entire database. This approach has undisputed benefits because there are fewer databases to manage and a higher degree of unity between them.

However, this approach is very close to the single data lake model, and we are trying to move away from this model. If there is a choice, developers and architects tend to be familiar with the approach, even if it seems to be objectively counterproductive. They will compromise and follow the service model. But remember: whenever possible, it is best to set up a dedicated database for each service, rather than relying on the overall architecture.

The best part of microservices is that it allows you to assign dedicated databases to some services and use shared databases for other services. This decision usually depends on the importance of the service and the type of data it handles. The team structure also plays a role here. Some services require strict autonomy from the teams that manage them, while other services are best shared among multiple teams.

Choosing the best database for micro-services is usually built on a large relational database. When migrating to a microservice, choosing a database for the new architecture is a big decision.

There are many database options, including:

Key-value database

Document storage database

Graphic database

Column-based database

Each type of database model is suitable for specific types of data management needs. For example, key-value databases and column databases are best suited for structured data, graphics for semi-structured data, and document storage for unstructured data.

Keep in mind that each database type has different read and write speeds and different vendor tools around different databases. Before selecting any database type or toolset, run the test with sample data. For example, for services that require real-time performance, you will need a database with strong memory performance.

Although enterprises are migrating to microservices, relational databases will not disappear any time soon. For a variety of reasons, some parts of many applications perform best in traditional architectures and will rely on the old single database to run. The good news is that microservices support this multi-type model of database management. Therefore, don't try to remove each part of the application from the monomer just because other services are migrating to microservices.

Thank you for your reading. the above is the content of "how to decompose a single database to achieve micro-service". After the study of this article, I believe you have a deeper understanding of the problem of how to decompose a single database to achieve micro-service. the specific use also needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report