Micro-service access method and device, equipment and medium
By splitting the target software into multiple microservices and creating gateway microservices, the problem of low access efficiency of microservices is solved, and the client can access multiple microservices through gateway microservices, improving access efficiency.
Patent Information
- Application Number
- CN202510788005.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-12
- Publication Date
- 2025-08-29
AI Technical Summary
In the microservice architecture, the client interacts more frequently when accessing microservices, which affects access efficiency.
Split the target software into multiple microservices and create a gateway microservice as a unified entrance. The client accesses multiple microservices through the gateway microservice interface, reducing direct interaction with microservices.
Provide a unified interface through gateway microservices, reducing the number of interactions between clients and microservices and improving microservice access efficiency.
Smart Images

Figure CN120567935A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of microservice technology, and in particular to a microservice access method, apparatus, device, and medium. Background Art
[0002] In the era of cloud computing, microservice architecture has been applied to the development and deployment of various systems. Microservices can have massive node programs to provide services. It is an architecture that separates applications into multiple separate services.
[0003] In related technologies, when a client accesses a microservice in a microservice architecture, it needs to locally record the call address of each microservice and access the corresponding microservice using the call address. However, this method of accessing microservices requires a large number of interactions between the client and the microservice, which affects the efficiency of microservice access. Summary of the Invention
[0004] The embodiments of the present application provide a microservice access method, apparatus, device, and medium, which can solve the problem of low microservice access efficiency.
[0005] In a first aspect, an embodiment of the present application provides a microservice access method, including:
[0006] Get the target software;
[0007] Split the target software into multiple microservices;
[0008] Create a gateway microservice, which is used to provide a unified external interface for multiple microservices so that clients can access multiple microservices through the interface.
[0009] In a second aspect, an embodiment of the present application provides a microservice access device, comprising:
[0010] Acquisition module, used to acquire target software;
[0011] Splitting module, used to split the target software into multiple microservices;
[0012] The first creation module is used to create a gateway microservice, wherein the gateway microservice is used to provide a unified external interface for multiple microservices, so that the client can access the multiple microservices through the interface.
[0013] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the steps of the microservice access method provided in the embodiment of the present application are implemented.
[0014] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the steps of the microservice access method provided in the embodiment of the present application are implemented.
[0015] In an embodiment of the present application, target software is obtained; the target software is split into multiple microservices; and a gateway microservice is created. The gateway microservice is used to provide a unified external interface for the multiple microservices, allowing clients to access the multiple microservices through the interface. In this way, the client does not need to record the call address of each microservice and can access the microservices through the unified external interface provided by the gateway microservice. This can reduce the number of interactions between the client and the microservices when accessing the microservices, and can improve the efficiency of microservice access. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0017] Figure 1 This is a flowchart of the microservice access method provided in an embodiment of the present application;
[0018] Figure 2 This is a schematic diagram of the microservice deployment provided by the embodiment of the present application;
[0019] Figure 3 This is a schematic diagram of the structure of the microservice access device provided in an embodiment of the present application;
[0020] Figure 4 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is merely to provide a better understanding of the present application by illustrating the examples of the present application.
[0022] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, the elements defined by the phrase "comprising..." do not exclude the presence of other identical elements in the process, method, article, or device comprising the elements.
[0023] The following, in conjunction with the accompanying drawings, describes in detail the microservice access method, apparatus, device, and medium provided in the embodiments of the present application through specific embodiments and their application scenarios.
[0024] Figure 1 This is a flow chart of the microservice access method provided by the embodiment of this application. Figure 1 As shown, microservice access methods can include:
[0025] Step 101: Obtain target software;
[0026] Step 102: Split the target software into multiple microservices;
[0027] In some possible implementations of the present application, different microservices may have different business functions, or may belong to different functional areas. Therefore, in step 102, the target software may be split into multiple microservices according to functional areas or business functions.
[0028] When the target software is split into multiple microservices based on functional areas, functional overlap and coupling can be effectively avoided, dependencies and dependencies between microservices can be reduced, and the impact of modifying one microservice on other microservices can be minimized. For example, the configuration microservice only supports configuration of the service center, while the gateway microservice supports routing, forwarding, and user login functions.
[0029] When dividing microservices according to business functions, modules with the same business functions can be divided into one microservice, or modules related to business functions can be divided into one microservice.
[0030] Step 103: Create a gateway microservice, where the gateway microservice is used to provide a unified external interface for multiple microservices, so that the client can access the multiple microservices through the interface.
[0031] In some possible implementations of the embodiments of the present application, the gateway microservice is the only external entrance to the target software. The gateway microservice routes the client's access request to the corresponding microservice. For the client, it can only communicate directly with the gateway microservice.
[0032] In some possible implementations of the embodiments of the present application, the gateway microservice may also record all access requests from the client to the microservice and the responses of the microservice to the client to facilitate subsequent analysis.
[0033] In an embodiment of the present application, target software is obtained; the target software is split into multiple microservices; and a gateway microservice is created. The gateway microservice is used to provide a unified external interface for the multiple microservices, allowing clients to access the multiple microservices through the interface. In this way, the client does not need to record the call address of each microservice and can access the microservices through the unified external interface provided by the gateway microservice. This can reduce the number of interactions between the client and the microservices when accessing the microservices, and can improve the efficiency of microservice access.
[0034] In some possible implementations of the embodiments of the present application, the microservice access method provided by the embodiments of the present application may also include: creating a configuration microservice, wherein the configuration microservice is used to store configuration information corresponding to multiple microservices; and storing the configuration information corresponding to multiple microservices in the configuration microservice.
[0035] In an embodiment of the present application, when the configuration information corresponding to a microservice is modified, it can be modified directly in the configuration microservice without having to modify it in the microservice.
[0036] In some possible implementations of the embodiments of the present application, storing configuration information corresponding to multiple microservices in the configuration microservice may include: creating multiple first configuration files corresponding to the multiple microservices respectively in the configuration microservice; creating multiple second configuration files corresponding to the multiple configuration information respectively in the configuration microservice; storing the multiple configuration information respectively in the multiple second configuration files; storing the file identifier of the second configuration file corresponding to the configuration information required by the first microservice in the first configuration file corresponding to the first microservice, wherein the first microservice is any one of the multiple microservices.
[0037] Exemplarily, assuming that the target software is divided into 6 microservices, the 6 microservices are microservice A to microservice F, then 6 first configuration files corresponding to the 6 microservices are created, and the 6 first configuration files are configuration files a to configuration files f, where microservice A corresponds to configuration file a, microservice B corresponds to configuration file b, microservice C corresponds to configuration file c, microservice D corresponds to configuration file d, microservice E corresponds to configuration file e, and microservice F corresponds to configuration file f.
[0038] Assume that there are 10 configuration information, namely configuration information 1 to configuration information 10. Then, 10 second configuration files corresponding to the 10 configuration information are created, namely configuration file 1 to configuration file 10, where configuration information i corresponds to configuration file i, and i is a positive integer greater than or equal to 1 and less than or equal to 10.
[0039] Store configuration information i in configuration file i.
[0040] Taking microservice A as an example, assuming that the configuration information required by microservice A includes configuration information 1, configuration information 3, and configuration information 5, the file identifier of configuration file 1, the file identifier of configuration file 3, and the file identifier of configuration file 5 are stored in configuration file a. When the configuration information of microservice A is needed, the file identifier of configuration file 1, the file identifier of configuration file 3, and the file identifier of configuration file 5 are obtained from configuration file a, and then configuration information 1 is obtained from configuration file 1, configuration information 3 is obtained from configuration file 3, and configuration information 5 is obtained from configuration file 5.
[0041] In some possible implementations of the embodiments of the present application, when a certain configuration information needs to be modified, only the configuration file corresponding to that configuration information needs to be modified, without modifying the configuration files corresponding to other configuration information. When the configuration information required by a microservice needs to be modified, only the file identifier in the configuration file corresponding to that microservice needs to be modified, without modifying the file identifiers in the configuration files corresponding to other microservices. This can improve the efficiency of configuration information modification and enhance the usability and stability of the software.
[0042] In some possible implementations of the embodiments of the present application, in order to facilitate the distinction between various configuration files, the configuration file corresponding to the microservice can be identified (i.e., named) with the microservice name, and the configuration file corresponding to the configuration information can be named with the configuration information name.
[0043] In some possible implementations of the embodiments of the present application, the microservice access method provided by the embodiments of the present application may also include: determining a main service from multiple microservices; deploying the main service, configuration microservice and gateway microservice in a first server; and deploying microservices other than the main service in multiple microservices in multiple second servers.
[0044] The embodiments of the present application do not limit the method for determining the primary service. Any available method can be applied to the embodiments of the present application. For example, a microservice that interacts with other microservices is determined as the primary service.
[0045] In some possible implementations of the embodiments of the present application, microservices other than the main service in the multiple microservices can be deployed in multiple second servers according to actual needs.
[0046] The embodiments of the present application do not limit the method used to deploy microservices other than the main service in multiple microservices on multiple second servers. Any available method can be applied to the embodiments of the present application. For example, microservices other than the main service in multiple microservices are evenly deployed in multiple second servers. For another example, microservices other than the main service in multiple microservices are deployed in each second server in the multiple second servers.
[0047] In some possible implementations of the embodiments of the present application, when certain microservices interact only with the main service, these microservices and the main service can be deployed in the same server.
[0048] In some possible implementations of the present invention, a microservice deployed on the same server as the main service can communicate one-to-one with the main service via OpenFeign; a microservice deployed on a different server can communicate one-to-many with the main service via RabbitMQ. OpenFeign is an open, declarative web service client, and RabbitMQ is a message queue based on the Advanced Message Queue Protocol (AMQP). The client and gateway microservice communicate via SocketIO, a real-time communication library based on WebSockets that supports two-way communication.
[0049] like Figure 2 As shown, Figure 2 This is a schematic diagram of the microservice deployment provided in an embodiment of the present application.
[0050] exist Figure 2 In this example, the configuration microservice, gateway microservice, microservice 1 (main service), and microservice 2 are deployed on server 1. Microservice 3, microservice 4, microservice 5, and microservice 6 are deployed on servers 2, 3, and 4. The client communicates with the gateway microservice in server 1 through SocketIO, microservice 1 communicates with microservice 2 through OpenFeign, and microservice 3, microservice 4, microservice 5, and microservice 6 communicate with microservice 1 through RabbitMQ.
[0051] The present application also provides a microservice access device, such as Figure 3 shown. Figure 3 : is a schematic diagram of the structure of a microservice access device provided in an embodiment of the present application. The microservice access device 300 may include:
[0052] Acquisition module 301, used to acquire target software;
[0053] A splitting module 302 is used to split the target software into multiple microservices;
[0054] The first creation module 303 is used to create a gateway microservice, wherein the gateway microservice is used to provide a unified external interface for multiple microservices, so that the client can access the multiple microservices through the interface.
[0055] In an embodiment of the present application, target software is obtained; the target software is split into multiple microservices; and a gateway microservice is created. The gateway microservice is used to provide a unified external interface for the multiple microservices, allowing clients to access the multiple microservices through the interface. In this way, the client does not need to record the call address of each microservice and can access the microservices through the unified external interface provided by the gateway microservice. This can reduce the number of interactions between the client and the microservices when accessing the microservices, and can improve the efficiency of microservice access.
[0056] In some possible implementations of the embodiment of the present application, the splitting module 302 is specifically configured to:
[0057] Split the target software into multiple microservices according to functional areas or business functions.
[0058] In some possible implementations of the embodiments of the present application, the microservice access device 300 provided in the embodiments of the present application may further include:
[0059] The second creation module is used to create a configuration microservice, wherein the configuration microservice is used to store configuration information corresponding to multiple microservices;
[0060] The storage module is used to store the configuration information corresponding to multiple microservices in the configuration microservice.
[0061] In some possible implementations of the embodiments of the present application, the storage module may include:
[0062] A first creation submodule is used to create a plurality of first configuration files corresponding to the plurality of microservices in the configuration microservice;
[0063] A second creation submodule is used to create a plurality of second configuration files corresponding to the plurality of configuration information in the configuration microservice;
[0064] A first storage submodule is used to store the plurality of configuration information into a plurality of second configuration files respectively;
[0065] The second storage submodule is used to store the file identifier of the second configuration file corresponding to the configuration information required by the first microservice in the first configuration file corresponding to the first microservice, wherein the first microservice is any one of the multiple microservices.
[0066] In an embodiment of the present application, when a certain configuration information needs to be modified, it is only necessary to modify the configuration file corresponding to the configuration information, and there is no need to modify the configuration files corresponding to other configuration information; when the configuration information required by a certain microservice needs to be modified, it is only necessary to modify the file identifier in the configuration file corresponding to the microservice, and there is no need to modify the file identifiers in the configuration files corresponding to other microservices. In this way, the efficiency of configuration information modification can be improved, and the availability and stability of the software can be improved.
[0067] In some possible implementations of the embodiments of the present application, the microservice access device 300 provided in the embodiments of the present application may further include:
[0068] The determination module is used to determine the main service from multiple microservices;
[0069] A first deployment module is used to deploy the main service and the gateway microservice in the first server;
[0070] The second deployment module is used to deploy microservices other than the main service in the multiple microservices on multiple second servers.
[0071] Figure 4 It is a structural diagram of an electronic device provided in an embodiment of the present application.
[0072] The electronic device may include a processor 401 and a memory 402 storing computer program instructions.
[0073] Specifically, the processor 401 may include a central processing unit (CPU) or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0074] Memory 402 may include a large capacity memory for data or instructions. By way of example and not limitation, memory 402 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 402 may include removable or non-removable (or fixed) media. Where appropriate, memory 402 may be inside or outside the electronic device. In some specific embodiments, memory 402 is a non-volatile solid-state memory.
[0075] In some specific embodiments, the memory may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Therefore, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the microservice access method according to the present application.
[0076] The processor 401 reads and executes the computer program instructions stored in the memory 402 to implement the steps of the microservice access method provided in the embodiment of the present application.
[0077] In one example, the electronic device may further include a communication interface 403 and a bus 410. Figure 4 As shown, the processor 401 , the memory 402 , and the communication interface 403 are connected via a bus 410 and communicate with each other.
[0078] The communication interface 403 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0079] The bus 410 includes hardware, software, or both that couples components of the electronic device to each other. By way of example and not limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, the bus 410 may include one or more buses. Although embodiments herein describe and illustrate a particular bus, this application contemplates any suitable bus or interconnect.
[0080] The electronic device can execute the steps of the microservice access method provided in the embodiment of the present application, thereby achieving the corresponding technical effects of the microservice access method provided in the embodiment of the present application.
[0081] In addition, in conjunction with the microservice access method in the above embodiment, the present application also provides a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when executed by a processor, the computer program instructions implement the steps of the microservice access method provided in the embodiment of the present application. Examples of computer-readable storage media include non-transitory computer-readable media, such as ROM, RAM, magnetic disks, or optical disks.
[0082] An embodiment of the present application provides a computer program product, which includes computer program instructions; when the computer program instructions are executed by a processor, the steps of the microservice access method provided in the embodiment of the present application are implemented, and the same technical effects can be achieved. To avoid repetition, they are not described here.
[0083] It should be understood that the present application is not limited to the specific configurations and processes described above and illustrated in the figures. For the sake of brevity, a detailed description of known methods is omitted here. In the above embodiments, several specific steps are described and illustrated as examples. However, the method process of the present application is not limited to the specific steps described and illustrated. Those skilled in the art can make various changes, modifications, and additions, or change the order of the steps after understanding the spirit of the present application.
[0084] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable read-only memory (ERM), floppy disks, compact disc read-only memory (CD-ROM), optical discs, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0085] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps. In other words, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0086] Aspects of the present disclosure have been described above with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit. It is also understood that each box in the block diagram and / or flowchart and the combination of the boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0087] The above description is only a specific embodiment of the present application. Those skilled in the art will clearly understand that for the convenience and brevity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the scope of protection of the present application is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the scope of protection of the present application.
Claims
1. A microservice access method, characterized in that: The method comprises: Get the target software; Splitting the target software into multiple microservices; A gateway microservice is created, wherein the gateway microservice is used to provide a unified external interface for the multiple microservices, so that a client can access the multiple microservices through the interface.
2. The method according to claim 1, characterized in that Splitting the target software into multiple microservices includes: The target software is split into multiple microservices according to functional areas or business functions.
3. The method according to claim 1, characterized in that The method further comprises: Creating a configuration microservice, wherein the configuration microservice is used to store configuration information corresponding to the multiple microservices; The configuration information corresponding to the multiple microservices is stored in the configuration microservice.
4. The method according to claim 3, characterized in that Storing the configuration information corresponding to the multiple microservices in the configuration microservice includes: Creating a plurality of first configuration files corresponding to the plurality of microservices respectively in the configuration microservice; Creating a plurality of second configuration files corresponding to the plurality of configuration information respectively in the configuration microservice; Storing the plurality of configuration information in the plurality of second configuration files respectively; The file identifier of the second configuration file corresponding to the configuration information required by the first microservice is stored in the first configuration file corresponding to the first microservice, wherein the first microservice is any one of the multiple microservices.
5. The method according to claim 1, characterized in that The method further comprises: Determine a main service from the multiple microservices; Deploy the main service and the gateway microservice in a first server; Deploy microservices other than the main service in the multiple microservices on multiple second servers.
6. A microservice access device, characterized in that: The device comprises: Acquisition module, used to acquire target software; A splitting module, used to split the target software into multiple microservices; The first creation module is used to create a gateway microservice, wherein the gateway microservice is used to provide a unified external interface for the multiple microservices, so that the client can access the multiple microservices through the interface.
7. The device according to claim 6, characterized in that The device further comprises: A second creation module is used to create a configuration microservice, wherein the configuration microservice is used to store configuration information corresponding to the multiple microservices; A storage module is used to store the configuration information corresponding to the multiple microservices in the configuration microservice.
8. The device according to claim 7, characterized in that The storage module includes: A first creation submodule is configured to create, in the configuration microservice, a plurality of first configuration files corresponding to the plurality of microservices respectively; A second creation submodule is used to create a plurality of second configuration files corresponding to the plurality of configuration information in the configuration microservice; A first storage submodule, configured to store the plurality of configuration information into the plurality of second configuration files respectively; The second storage submodule is configured to store a file identifier of a second configuration file corresponding to configuration information required by a first microservice in a first configuration file corresponding to the first microservice, wherein the first microservice is any one of the multiple microservices.
9. An electronic device, characterized in that: The electronic device includes: a processor and a memory storing computer program instructions; The processor reads and executes the computer program instructions to implement the steps of the microservice access method according to any one of claims 1 to 5.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement the steps of the microservice access method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Micro-service system creation method, device and equipment, medium and micro-service system
CN112346717A
Micro-service configuration system, device and medium
CN113918215A
Micro-service automatic deployment method and device and storage medium
CN113961198A
Service access method and device, electronic equipment and storage medium
CN118316779A
Method and device for providing micro-service based on data service platform, and storage medium
WO2020211222A1