Micro-service implementation method and system supporting rapid switching of underlying databases
By layering the back-end logic code into the business logic layer and the data service layer, the problems of mixed code and large workload for adapting to different underlying databases in the existing technology are solved, and the development efficiency and product reliability of software products when adapting to switch to the underlying database are improved.
Patent Information
- Application Number
- CN202411668179.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-03-28
AI Technical Summary
The existing microservice development methods based on underlying databases have problems such as mixed code, large workload for adapting to different underlying databases, long testing cycles, and inability to support multiple underlying databases.
By layering the back-end logic code into the business logic layer and the data service layer, developers develop microservices at the data service layer by adapting to the business logic layer data interface standards, realizing that software products support the underlying database switching.
It simplifies the background service development process of software products when adapting to switch the underlying database, optimizes code logic, and improves development efficiency and product reliability.
Smart Images

Figure CN119718264A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software product development based on underlying databases, and in particular to a microservice implementation method and system that supports rapid switching of underlying databases. Background Art
[0002] With the development of software development and database technology, microservice development based on the underlying database has become the main theme of software development. The current database-based microservice development method has the following characteristics:
[0003] The business logic layer and data service layer codes are in the same microservice, and the backend service is usually provided by a microservice;
[0004] There is no clear boundary between the business logic layer code and the data service layer code, and they are intertwined. There is no standardized definition of the data service interface called by the business logic layer;
[0005] There is only one service process in the backend, and the data service layer can only establish a connection with one database through the connection pool. It is impossible to obtain data from multiple source databases.
[0006] The above characteristics lead to the following problems:
[0007] 1. The code is mixed, difficult to sort out, and lacks hierarchical logic.
[0008] 2. The development workload of adapting to different underlying databases is large.
[0009] 3. The testing cycle is long, and the function and performance testing of the data interface needs to start from the entire platform function.
[0010] 4. It is unable to meet the needs of various underlying databases to support microservices.
[0011] In software projects, due to factors such as customer procurement and policies, the software platform sometimes needs to urgently switch to adapt to the underlying database. In the software development process, simple adaptation of the underlying database becomes an urgent need. Summary of the invention
[0012] The technical task of the present invention is to address the above shortcomings and provide a microservice implementation method and system that supports rapid switching of the underlying database, which can simplify the workload, optimize code logic, and improve development efficiency and product reliability during the background service development process of adapting and switching the underlying database of software products.
[0013] The technical solution adopted by the present invention to solve the technical problem is:
[0014] A microservice implementation method that supports fast switching of underlying databases, which divides the backend logic code into microservice layers, a business logic layer and a data service layer; the code involving the platform business logic, the data service interface and the client connection part are classified into the business logic layer microservice, and the data service implementation, the data access layer and the driver part are classified into the data service layer microservice; developers develop microservices of the data service layer by adapting the data interface standard of the business logic layer, so as to realize the software product support for the switching of the underlying database.
[0015] This method splits the backend service code of the software into two layers, the upper layer microservice performs business logic processing and data interface definition, and the lower layer microservice is responsible for connecting to the underlying database and implementing data services. In the case of switching the underlying database, it is only necessary to complete the development and adaptation of the lower layer microservice, and then replace and deploy the lower layer microservice. This method divides the backend service architecture of the software into layers and refines it, and standardizes the definition of the data interface layer. The lower layer microservice will not involve changes to the upper layer business logic code during the adaptation and development process, and the microservice development of the data service layer is directly carried out according to the interface and interface function description. This method is mainly used to simplify the workload of software products in the background service development process of adapting and switching the underlying database, optimizing code logic, and improving development efficiency and product reliability.
[0016] Furthermore, the method is applicable to the development of back-end microservices for software products using a B / S or C / S architecture. The microservice layered architecture can support Web (B / S) or App (C / S) applications and is not limited to the separation of the front-end and back-end.
[0017] Furthermore, the business logic layer includes: a control layer, a service layer, a data interface layer, and a client tool; the business logic layer provides interactive interface services to the front end of the B / S or C / S;
[0018] The control layer is mainly responsible for the interface definition with the interaction layer; the data interface layer is responsible for the interface definition with the data service layer; the service layer is responsible for business logic processing;
[0019] The interface between the business logic layer and the interaction layer adopts the form of REST interface;
[0020] The business logic layer and the data service layer communicate through RPC or REST interfaces, and use accounts and encrypted channels for security protection.
[0021] Furthermore, the data service layer implements the data interface definition of the business logic layer and provides data interface services for the business logic layer; the data service layer structure includes: server tools, service layer, driver layer, and may include a persistence layer;
[0022] The server-side tools provide data service interfaces and security authentication interfaces; the service layer provides basic services and logical services.
[0023] Furthermore, under the premise of implementing the standard interface of the business logic layer in the data service layer, the underlying database can be switched by deploying different data service layer microservices;
[0024] And under the premise of meeting the data interface definition of the business logic layer, the database table structure can be adjusted and optimized as long as it can meet the data interface service implementation.
[0025] Furthermore, a single business logic layer microservice can call multiple data service layer microservices;
[0026] A single data service layer microservice can provide data services to multiple business logic layer microservices that define interfaces;
[0027] That is, multiple data service layer microservices can support the same business logic layer service call; a single data service layer microservice can support multiple business logic layer microservice calls;
[0028] The same platform can be supported by multiple databases of the same type, or a specified database type can be used.
[0029] Furthermore, the implementation process of this method is as follows:
[0030] S1. The front end performs data query operations and accesses the query interface of the business logic layer;
[0031] S2, the business logic layer performs logic processing and calls the data interface layer interface;
[0032] S3, the data interface layer requests the data service of the interface from the data service layer through the RPC\REST client;
[0033] S4, the data service layer receives the data service request from the business logic layer through the server;
[0034] S5. The data service layer queries the database through the driver program and provides services to the business logic layer after service processing.
[0035] The present invention also claims a microservice implementation system that supports fast switching of underlying databases, including: a front-end interaction layer module, a business logic layer module and a data service layer module.
[0036] The front-end interaction layer module includes a front-end UI and an interaction layer;
[0037] The business logic layer module includes a control layer, a service layer, a data interface layer and a client tool;
[0038] The data service layer module includes a server-side tool, a service layer and a driver layer;
[0039] The system realizes adaptation and switching of the underlying database and provides data services through the above-mentioned microservice implementation method that supports rapid switching of the underlying database.
[0040] The present invention also claims a microservice implementation device that supports fast switching of underlying databases, comprising: at least one memory and at least one processor;
[0041] The at least one memory is used to store a machine-readable program;
[0042] The at least one processor is used to call the machine-readable program to implement the above method.
[0043] The present invention also claims protection for a computer-readable medium having computer instructions stored thereon, which, when executed by a processor, causes the processor to perform the above method.
[0044] Compared with the prior art, the microservice implementation method and system supporting fast switching of underlying databases of the present invention have the following beneficial effects:
[0045] The present invention splits the backend service into business logic layer microservices and data service layer microservices. While ensuring that the platform business functions are met and the database needs to be switched urgently, the existing technology and the data service interface defined by the business logic layer are fully utilized to adapt and develop data service layer microservices, solving the problem of difficulty in developing and testing the underlying database adaptation and switching, and improving the product delivery cycle and reliability. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is a diagram showing the overall architecture of a microservice implementation method supporting rapid switching of underlying databases provided by an embodiment of the present invention;
[0047] Figure 2 It is a schematic diagram of data interaction provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0048] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.
[0049] The embodiment of the present invention provides a microservice implementation method that supports fast switching of underlying databases. The backend logic code is divided into microservice layers, which are divided into a business logic layer and a data service layer. The code, data service interface and client connection part related to the platform business logic are classified into the business logic layer microservice, and the data service implementation, data access layer and driver part are classified into the data service layer microservice. Developers develop microservices for the data service layer by adapting the business logic layer data interface standard to solve the need for software products to support the switching of underlying databases. The overall architecture diagram of this method is shown in the figure below. Figure 1 shown.
[0050] This method is suitable for the development of back-end microservices for software products using B / S or C / S architecture, that is, the microservice layered architecture can support Web (B / S) or App (C / S) applications, and is not limited to the separation of front-end and back-end.
[0051] The business logic layer includes: a control layer, a service layer, a data interface layer, and a client tool; the business logic layer provides interactive interface services to the front end of the B / S or C / S.
[0052] The control layer is mainly responsible for interface definition with the interaction layer; the data interface layer is responsible for interface definition with the data service layer; and the service layer is responsible for business logic processing.
[0053] The interface between the business logic layer and the interaction layer adopts the form of REST interface;
[0054] The business logic layer and the data service layer communicate through RPC or REST interfaces, and use accounts and encrypted channels for security protection.
[0055] The data service layer implements the data interface definition of the business logic layer and provides data interface services for the business logic layer; the data service layer structure includes: server-side tools, service layer, persistence layer (optional), and driver layer.
[0056] The server-side tools provide data service interfaces and security authentication interfaces; the service layer provides basic services and logical services.
[0057] On the premise that the data service layer implements the standard interface of the business logic layer, the underlying database can be switched by deploying different data service layer microservices.
[0058] And under the premise of meeting the data interface definition of the business logic layer, the database table structure can be adjusted and optimized as long as it can meet the data interface service implementation.
[0059] For this layered microservice architecture, a single business logic layer microservice can call multiple data service layer microservices; a single data service layer microservice can provide data services to multiple business logic layer microservices that define interfaces. That is, multiple data service layer microservices can support the same business logic layer service call; a single data service layer microservice can support multiple business logic layer microservice calls.
[0060] The same platform can be supported by multiple databases of the same type, or a specified database type can be used.
[0061] like Figure 2 As shown, the implementation process of this method is as follows:
[0062] S1. The front end performs data query operations and accesses the query interface of the business logic layer;
[0063] S2, the business logic layer performs logic processing and calls the data interface layer interface;
[0064] S3, the data interface layer requests the data service of the interface from the data service layer through the RPC\REST client;
[0065] S4, the data service layer receives the data service request from the business logic layer through the server;
[0066] S5. The data service layer queries the database through the driver program and provides services to the business logic layer after service processing.
[0067] This method splits the backend service code of the software into two layers, the upper layer microservice performs business logic processing and data interface definition, and the lower layer microservice is responsible for connecting to the underlying database and implementing data services. In the case of switching the underlying database, it is only necessary to complete the development and adaptation of the lower layer microservice, and then replace and deploy the lower layer microservice. This method divides the backend service architecture of the software into layers and refines it, and standardizes the definition of the data interface layer. The lower layer microservice will not involve changes to the upper layer business logic code during the adaptation and development process, and the microservice development of the data service layer is directly carried out according to the interface and interface function description. This method is mainly used to simplify the workload of software products in the background service development process of adapting and switching the underlying database, optimizing code logic, and improving development efficiency and product reliability.
[0068] An embodiment of the present invention also provides a microservice implementation system that supports rapid switching of underlying databases. The system implements adaptive switching of underlying databases and provides data services through the microservice implementation method that supports rapid switching of underlying databases described in the above embodiment.
[0069] The system includes: front-end interaction layer module, business logic layer module and data service layer module.
[0070] The front-end interaction layer module includes the front-end UI and the interaction layer. The system can support Web (B / S) or App (C / S) applications, and is not limited to the separation of the front and back ends.
[0071] The business logic layer module includes a control layer, a service layer, a data interface layer and client tools. The control layer is mainly responsible for the interface definition with the interaction layer; the data interface layer is responsible for the interface definition with the data service layer; and the service layer is responsible for business logic processing.
[0072] The business logic layer provides interactive interface services to the front end of B / S or C / S. The interface between the business logic layer and the interactive layer adopts the form of REST interface; the business logic layer and the data service layer communicate through RPC or REST interface, and use accounts and encrypted channels for security protection.
[0073] The data service layer module implements the data interface definition of the business logic layer and provides data interface services for the business logic layer. The data service layer module includes server tools, service layer and driver layer. The server tools provide data service interface and security authentication interface; the service layer provides basic services and logic services.
[0074] Under the premise that the data service layer module implements the standard interface of the business logic layer, the underlying database can be switched by deploying different data service layer microservices. And under the premise of meeting the definition of the business logic layer data interface, the database table structure can be adjusted and optimized as long as it can meet the data interface service implementation.
[0075] In the layered microservice architecture of the system, multiple data service layer microservices can support the same business logic layer service call; a single data service layer microservice can support multiple business logic layer microservice calls.
[0076] The same platform can be supported by multiple databases of the same type, or a specified database type can be used.
[0077] The implementation process of the system is as follows:
[0078] S1. The front end performs data query operations and accesses the query interface of the business logic layer;
[0079] S2, the business logic layer performs logic processing and calls the data interface layer interface;
[0080] S3, the data interface layer requests the data service of the interface from the data service layer through the RPC\REST client;
[0081] S4, the data service layer receives the data service request from the business logic layer through the server;
[0082] S5. The data service layer queries the database through the driver program and provides services to the business logic layer after service processing.
[0083] An embodiment of the present invention further provides a microservice implementation device that supports fast switching of underlying databases, comprising: at least one memory and at least one processor;
[0084] The at least one memory is used to store a machine-readable program;
[0085] The at least one processor is used to call the machine-readable program to implement the microservice implementation method that supports fast switching of the underlying database described in the above embodiment.
[0086] The embodiment of the present invention also provides a computer-readable medium, on which computer instructions are stored, and when the computer instructions are executed by a processor, the processor executes the microservice implementation method for supporting fast switching of underlying databases described in the above embodiment. Specifically, a system or device equipped with a storage medium can be provided, on which software program codes for implementing the functions of any of the above embodiments are stored, and a computer (or CPU or MPU) of the system or device reads and executes the program code stored in the storage medium.
[0087] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.
[0088] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer by a communication network.
[0089] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.
[0090] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or written to a memory provided in an expansion unit connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or the expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.
[0091] The present invention is shown and described in detail above through the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the code review methods in the above different embodiments can be combined to obtain more embodiments of the present invention, and these embodiments are also within the protection scope of the present invention.
Claims
1. A microservice implementation method that supports fast switching of underlying databases, characterized in that: The backend logic code is divided into microservice layers, namely the business logic layer and the data service layer; the code related to the platform business logic, data service interface and client connection part are classified into the business logic layer microservice, and the data service implementation, data access layer and driver part are classified into the data service layer microservice; Developers develop microservices at the data service layer by adapting the data interface standards of the business logic layer, so that software products can support switching of underlying databases.
2. According to claim 1, a microservice implementation method that supports fast switching of underlying databases is characterized in that: This method is suitable for the development of back-end microservices for software products using a B / S or C / S architecture. The microservice layered architecture can support Web or App applications and is not limited to the separation of the front-end and back-end.
3. According to claim 2, a microservice implementation method that supports fast switching of underlying databases is characterized in that: The business logic layer includes: control layer, service layer, data interface layer, client tools; the business logic layer provides interactive interface services to the front end of B / S or C / S; The control layer is responsible for defining the interface with the interaction layer; the data interface layer is responsible for defining the interface with the data service layer; the service layer is responsible for business logic processing; The interface between the business logic layer and the interaction layer adopts the form of REST interface; The business logic layer and the data service layer communicate through RPC or REST interfaces, and use accounts and encrypted channels for security protection.
4. A microservice implementation method supporting fast switching of underlying databases according to claim 2 or 3, characterized in that: The data service layer implements the data interface definition of the business logic layer and provides data interface services for the business logic layer; The data service layer structure includes: server-side tools, service layer, driver layer, and may include a persistence layer; The server-side tools provide data service interfaces and security authentication interfaces; the service layer provides basic services and logical services.
5. According to a method for implementing a microservice that supports fast switching of underlying databases as described in claim 1, it is characterized in that: On the premise that the data service layer implements the standard interface of the business logic layer, the underlying database can be switched by deploying different data service layer microservices; And on the premise of meeting the data interface definition of the business logic layer, the database table structure can be adjusted and optimized.
6. A microservice implementation method supporting fast switching of underlying databases according to claim 1, characterized in that: A single business logic layer microservice can call multiple data service layer microservices; A single data service layer microservice can provide data services to multiple business logic layer microservices that define interfaces; The same platform can be supported by multiple databases of the same type, or a specified database type can be used.
7. A microservice implementation method supporting fast switching of underlying databases according to claim 1, characterized in that: The implementation process of this method is as follows: S1. The front end performs data query operations and accesses the query interface of the business logic layer; S2, the business logic layer performs logic processing and calls the data interface layer interface; S3, the data interface layer requests the data service of the interface from the data service layer through the RPC\REST client; S4, the data service layer receives the data service request from the business logic layer through the server; S5. The data service layer queries the database through the driver program and provides services to the business logic layer after service processing.
8. A microservice implementation system that supports fast switching of underlying databases, characterized in that: include: Front-end interaction layer module, business logic layer module and data service layer module, The front-end interaction layer module includes a front-end UI and an interaction layer; The business logic layer module includes a control layer, a service layer, a data interface layer and a client tool; The data service layer module includes a server-side tool, a service layer and a driver layer; The system realizes adaptation and switching of the underlying database and provision of data services through the microservice implementation method supporting rapid switching of the underlying database as described in any one of claims 1 to 7.
9. A microservice implementation device that supports fast switching of underlying databases, characterized in that: include: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is used to call the machine-readable program to implement the method described in any one of claims 1 to 7.
10. A computer-readable medium, characterized in that The computer readable medium stores computer instructions, which, when executed by a processor, cause the processor to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Hierarchical cloud management platform based on microservice architecture
CN107786379A
Micro-service hierarchical structure supporting flexible expansion
CN112711396A
Intelligent development method and system based on hierarchical micro-service
CN112817946A
Systems, methods, and apparatuses for simultaneously running parallel databases
US20220374411A1