Unified interface management method and application platform based on microservices
Through the unified interface management method based on microservices, the problems of high module coupling and insufficient system stability in the traditional web development model are solved, low coupling and high fault tolerance are achieved, and thermal updates and 24/7 services are supported.
Patent Information
- Application Number
- CN202111662140.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2041-12-30
AI Technical Summary
Under the traditional web development model, the module is highly coupled, it is difficult to support the access and modification of model interfaces, and the system stability and fault tolerance are insufficient, which cannot meet the needs of providing services on 24/7.
Adopt a unified interface management method based on microservices, and determine the target server by responding to external interface call requests, and performing permission verification and result recording, supporting hot updates and asynchronous processing, reducing the coupling of each microservice.
It realizes low coupling and high fault tolerance for each microservice, supports thermal updates, does not affect other interface services, and meets the needs of providing services 24/7.
Smart Images

Figure CN114461359B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of microservices, and in particular to a unified interface management method based on microservices and an application platform thereof. Background Art
[0002] At present, the number of model services in the bank is gradually increasing, and the same model service will be called by different business departments. Therefore, the monitoring, statistics, and management of model services have become increasingly important. Providing a unified interface management platform to uniformly monitor, count, and manage these interfaces is a prerequisite for the bank to gradually promote the sharing of model services by business departments. Waiting for different types of models to be delivered by different suppliers and then transformed into a unified interface will face the problem of modifying the existing business system call interface. In addition, since the availability of model services directly affects business availability, the platform system needs to be highly stable and scalable.
[0003] For the traditional web development model, each module is highly coupled and is hard-coded to encapsulate the entire service, which is not conducive to the access and modification of the model interface, making development difficult and scalable. In addition, the traditional web development model has poor flexibility. Any modification in any place requires the entire platform system to be restarted to take effect. This results in the interface forwarding service of all normal models being stopped for each update, which does not meet the platform system's need to provide stable services to downstream business systems 24 hours a day. At the same time, the traditional web development model has low fault tolerance. If a program error occurs in any place, the entire platform system will be shut down, which also cannot meet business needs.
[0004] Therefore, in order to solve the above problems, a unified interface management method based on microservices and its application platform are needed. Summary of the invention
[0005] The purpose of the present invention is to provide a unified interface management method based on microservices and an application platform thereof.
[0006] To achieve the above object, the technical solution adopted by the present invention is as follows:
[0007] A unified interface management method based on microservices, the unified interface management method comprising: responding to an external interface call request, determining a target server according to the interface call request, and performing authority verification on the interface call request, the verification result is passed or failed, and when the verification result of the interface call request is passed, sending the interface call request to the target server to call the target model.
[0008] Furthermore, the unified interface management method further includes: recording the calling result of the interface calling request, and storing the interface calling request and the corresponding calling result.
[0009] Furthermore, the interface call request includes a target interface number and request information;
[0010] The unified interface management method also includes: parsing the interface call request to obtain the corresponding target interface number and request information, and determining the target server according to the pre-stored correspondence between the interface and the server, and performing authority verification on the interface call request based on the target interface number; if the parsing of the interface call request is abnormal, interrupting the interface call request.
[0011] Furthermore, the unified interface management method also includes: querying in the pre-stored processing class according to the target interface number to obtain the processing class corresponding to the target interface number, and determining the transmission method of the interface call request based on the correspondence between the pre-stored interface and the server; if the query result is empty, interrupting the interface call request.
[0012] Further preferably, the transmission method includes sending the interface call request directly to the target server, or forwarding the interface call request to the target server through a queue forwarding service.
[0013] Furthermore, the interface call request also includes attachment information;
[0014] The unified interface management method further includes: parsing the interface call request to obtain corresponding attachment information, and processing the interface call request according to the attachment information.
[0015] Furthermore, the unified interface management method further includes: asynchronously processing the request information, serializing the attachment information, and returning flow information, wherein the flow information corresponds to the interface call request.
[0016] Furthermore, the unified interface management method further includes: querying corresponding interface call requests and corresponding call results through the transaction information.
[0017] An application platform based on the unified interface management method described above, the application platform comprising:
[0018] A business system configured to send an interface call request;
[0019] An Nginx server connected to the business system, wherein the Nginx server is configured to pre-store a correspondence between a unified interface and a corresponding server;
[0020] A plurality of model application servers, which are respectively connected to the Nginx server, and the model application servers are configured to provide a unified interface microservice according to a pre-stored model;
[0021] A database server is connected to the model application server, and the database server includes a permission database, and the permission database is configured to store permission data required for calling the unified interface.
[0022] Furthermore, the database server also includes a statistical database, and the statistical database is configured to store the call results of the interface call request.
[0023] The advantages of the present invention are as follows: each microservice has low coupling, supports hot update, is convenient for access and modification of the model interface, and has strong scalability; each microservice can be started and stopped independently, and when a certain interface is updated, it does not affect other interface services; it has high fault tolerance, and if an error occurs somewhere, it will only affect the corresponding service, and other functions of the platform can still continue to provide services. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0025] Figure 1 It is a schematic diagram of the principle of the application platform provided by the embodiment of the present invention;
[0026] Figure 2 is a working schematic diagram of the calling interface provided by an embodiment of the present invention;
[0027] Figure 3 This is a workflow diagram of a synchronous call provided by an embodiment of the present invention;
[0028] Figure 4 This is a workflow diagram of an asynchronous call provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to enable those skilled in the art to better understand the scheme of the present invention, and to more clearly understand the purpose, technical scheme and advantages of the present invention, the technical scheme in the embodiment of the present invention is clearly and completely described below in conjunction with specific embodiments and with reference to the accompanying drawings. It should be noted that the implementation methods not shown or described in the accompanying drawings are forms known to those skilled in the art. In addition, although demonstrations of parameters containing specific values may be provided herein, it should be understood that the parameters do not need to be exactly equal to the corresponding values, but may be approximated to the corresponding values within an acceptable error tolerance or design constraint. Obviously, the described embodiments are only embodiments of a part of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work should belong to the scope of protection of the present invention. In addition, the terms "including" and "having" in the specification and claims of the present invention and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment containing a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0030] In one embodiment of the present invention, a unified interface management method based on microservices is provided, and the unified interface management method includes: responding to an external interface call request, determining a target server according to the interface call request, and performing authority verification on the interface call request, and the verification result is passed or failed. When the verification result of the interface call request is passed, the interface call request is sent to the target server to call the target model, and the call result of the interface call request is recorded, and the interface call request and the corresponding call result are stored.
[0031] In one embodiment of the present invention, the interface call request includes a target interface number and request information. The unified interface management method also includes: parsing the interface call request to obtain the corresponding target interface number and request information, and determining the target server according to the correspondence between the pre-stored interface and the server, and performing authority verification on the interface call request based on the target interface number; if the parsing of the interface call request is abnormal, interrupting the interface call request. In this embodiment, the unified interface management method also includes: querying in the pre-stored processing class according to the target interface number to obtain the processing class corresponding to the target interface number, and determining the transmission method of the interface call request based on the correspondence between the pre-stored interface and the server; if the query result is empty, interrupting the interface call request. Wherein, the transmission method includes sending the interface call request directly to the target server, or, as Figure 2As shown, the interface call request is forwarded to the target server through a queue forwarding service.
[0032] In one embodiment of the present invention, the interface is called by a synchronous calling method, such as Figure 3 As shown in the figure, the specific process is as follows: the external system calls the synchronous call interface / uis / ocr interface (com.uis.controller.OcrController); then, the server parses the request parameters, and if the parsing is abnormal, it interrupts and returns; secondly, according to the target interface number of the request, it verifies whether the system has the authority to request the interface number (the system and interface permissions are configured in the uis_system_interface table); thirdly, according to the interface number, it finds the processing class of the corresponding interface in the program, and if it cannot be found, the request fails; then, it determines whether there is an attachment in the request message, that is, the request information, and determines whether it is a background body according to the is_trial in the request parameter. The experience page sends a request (only the request sent by the background experience has the is_trial field), the experience interface uses the local default image, and the system request uses the attachment in the message body; then, in the processing class of the corresponding interface, the table configuration is determined, whether the interface of the request model is sent directly to the supplier server, or the queue forwarding service (uis_queue service), the queue uis_queue service needs to forward it, send it to the queue server, and directly request the supplier interface (configuration table: uis_app_service_server table (interface forwarding relationship table)); finally, the call interface return result is obtained, the asynchronous thread records it in the db2 result table, and returns the result.
[0033] In one embodiment of the present invention, the interface call request also includes attachment information. The unified interface management method also includes: parsing the interface call request, obtaining corresponding attachment information, and processing the interface call request according to the attachment information. In this embodiment, the unified interface management method also includes: asynchronously processing the request information, serializing the attachment information, and returning flow information, so that the corresponding interface call request and the corresponding call result can be queried through the flow information, wherein the flow information corresponds to the interface call request.
[0034] Specifically, for asynchronous processing, we now combine Figure 4A specific description of asynchronous calls is as follows: first, the synchronous call interface / uis / ocr / async interface (com.uis.controller.OcrController) is called; then, the server parses the request parameters, and returns if the parsing is abnormal; secondly, based on the requested service interface number, check whether the system has the authority to request the interface number (the system and interface permissions are configured in the uis_system_interface table); thirdly, based on the interface number, find the processing class of the corresponding interface in the program, if not found, the request fails; then, the request information is packaged into an activemq message and sent to mq, and the attachment is serialized to mongodb; then the serial number is returned for query; then, the mq consumer consumption message is processed (the specific logic is the same as the synchronous call, except that the query results are saved in mongo in the asynchronous call process, which will not be repeated here); finally, other systems use the serial number to query the results, get the results from mongodb and return them.
[0035] In one embodiment of the present invention, an application platform based on the unified interface management method described above is provided, the application platform comprising a business system configured to send an interface call request, an Nginx server configured to pre-store a correspondence between a unified interface and a corresponding server, a plurality of model application servers configured to provide unified interface microservices according to pre-stored models, and a database server, wherein the database server comprises a permission database and a statistical database, the permission database being configured to store permission data required for calling the unified interface, and the statistical database being configured to store call results of the interface call request.
[0036] Specifically, in this embodiment, Figure 1 As shown, this application platform includes:
[0037] (1) Business department system: The business department system accesses the Ngnix server to obtain the corresponding service according to the encapsulated unified interface URL. The business department does not need to know the application server IP and port where the specific model is deployed.
[0038] (2) Nginx server, which configures the correspondence between each encapsulated unified interface URL and the application server deployed by the specific model;
[0039] (3) Model application server. The content deployed on the model application server includes the following two parts:
[0040] a. The service provided by the supplier is in the form of HTTP. The same model can be deployed on multiple servers for load balancing;
[0041] b. Unified interface microservice: The unified interface microservice receives the request sent by Nginx and performs permission verification, interface data extraction and conversion, calls the specific model of the local supplier, stores and converts the results, and returns them. It should be emphasized that one of the benefits of deploying the unified interface microservice locally is that in addition to calling local web services, it can also directly call SDK interface services, such as TTS;
[0042] (4) Database server, which stores the following two contents:
[0043] a. Permission database, which stores the user permissions required to call each unified interface service. Different business departments have different permissions. It should be noted that the native services provided by suppliers do not have permission input parameters, and external systems can still call the supplier's native services at will;
[0044] b. Statistical database, which stores partial information of the results returned after each interface service call and some general statistical information. The content that needs to be stored by each interface service is extracted by the developer based on the results of each supplier model;
[0045] (5) AI platform portal:
[0046] a. Application experience portal, which provides a display and experience interface for each unified interface microservice, and can also specify a specific model application server URL for post-launch model interface testing;
[0047] b. Application management portal, which provides a one-to-many relationship between the interface configured in nginx and the machine of each unified interface microservice, and can hot-modify a record to bring the machine online or offline; and also configures a many-to-many permission relationship between each unified interface microservice and the business department; at the same time, it provides a flexible and configurable report display interface and log query function for the statistical results of each unified interface microservice call.
[0048] In one embodiment of the present invention, the design of the unified interface parameters specifically includes the client request address:
[0049] (1) Do not specify the specific application deployment server address, and let Nginx decide on forwarding:
[0050] http: / / ai.szrcb.com / uis / {service_type} / ?service_name={service_name};
[0051] Among them, uis stands for unified interface service;
[0052] For example, http: / / ai.szrcb.com / uis / ocr / ?service_name=invoice;
[0053] (2) Specify the specific application deployment server address and port:
[0054] http: / / {ip}:{port} / usi / {service_type} / ? service_name={service_name};
[0055] service_type:ocr, etc.
[0056] service_name: invoice, id_card, license, etc.
[0057] The design of unified interface parameters also includes client request parameters:
[0058] uis_param: general input parameter. Model-specific handlers can add additional fields.
[0059] model_param: model-specific input parameters, which can be extracted by the model-specific handler and passed to the model-specific API;
[0060] uis_service_name: request service name. Since multiple models may be deployed on one machine, it needs to be specified. The parameter name is extracted from the URL parameter.
[0061] ip: client request IP. If possible, this parameter does not need to be entered by the user but is extracted from the request message.
[0062] uis_result: general call result, which is the call result converted after the specific model handler extracts the result content after receiving the lower-level service interface. You can add additional fields by yourself. Note that the additional fields added for each specific model cannot be displayed in the interface statistics report because other models may not have them.
[0063] model_result: a specific model result, which is the model output converted after the specific model handler extracts the result content after receiving the lower-level service interface.
[0064] In addition, it should be noted that if the batch call interface for the same model is provided separately, then a separate table needs to be created for the batch call interface, and each model needs to be stored for API statistical reports.
[0065] The various interface services, mq message queue services, statistical services, and background page web services provided by this application platform are all designed based on microservices and are started independently of each other. In addition, the permission database, statistical database, and log files are isolated from each other. As time goes by and the amount of data increases, the statistical script is run regularly every night without affecting the statistical query and interface forwarding functions.
[0066] The idea of this application platform embodiment is the same as the working process of the unified interface management method in the above embodiment. The entire content of the above unified interface management method embodiment is incorporated into this application platform embodiment by full reference and will not be repeated here.
[0067] The above description is only a preferred embodiment of the present invention, and does not limit the patent scope thereof. Any equivalent structure or equivalent process transformation made by using the contents of the present invention specification and drawings, directly or indirectly applied in other related technical fields, is also included in the patent protection scope of the present invention.
Claims
1. An application platform based on a unified interface management method, characterized in that: The application platform includes: A business department system is configured to send an interface call request, wherein the interface call request includes a target interface number, request information, and attachment information; An Nginx server connected to the business department system, wherein the Nginx server is configured to pre-store a correspondence between a unified interface and a corresponding model application server; A plurality of model application servers, which are respectively connected to the Nginx server, and the model application servers are configured to provide a unified interface microservice according to a pre-stored model, and the unified interface microservice is deployed locally; A database server connected to the model application server, the database server comprising a permission database configured to store permission data required for calling a unified interface; The unified interface management method includes: responding to the interface call request of the business department system, parsing the interface call request, obtaining the corresponding target interface number, request information and attachment information, and determining the target server according to the pre-stored correspondence between the interface and the server, and performing authority verification on the interface call request based on the target interface number. If the parsing of the interface call request is abnormal, the interface call request is interrupted. When the verification result of the interface call request is passed, the interface call request is sent to the target server to call the target model; and asynchronously processing the request information, serializing the attachment information, and returning flow information, wherein the flow information corresponds to the interface call request, and the flow information is returned through the flow. The water information query corresponding interface call request and corresponding call result; wherein, the asynchronous processing includes: first, calling the synchronous call interface or UIS or OCR or Async interface; then, the server parses the request parameters, and interrupts and returns if the parsing is abnormal; secondly, according to the requested service interface number, check whether the system has the authority to request the interface number; thirdly, according to the interface number, find the processing class of the corresponding interface in the program, if not found, the request fails; then, the request information is packaged into an activemq message and sent to mq, and the attachment is serialized to mongodb; then the serial number is returned for query; then, the consumption message of the mq consumer is processed; finally, other systems use the serial number to query the result, get the result from mongodb and return it; The application platform also includes an AI platform portal, which includes an application experience portal and an application management portal. The application experience portal provides an interface for each unified interface microservice, and specifies the model application server URL for model interface testing after going online; the application management portal provides a one-to-many relationship between the interface configured in the Nginx server of each unified interface microservice and the machine, and performs machine online and offline by means of hot modification records; the application management portal also configures a many-to-many authority relationship between each unified interface microservice and the business department of the business department system, and the business department does not need to know the application server IP and port for model deployment; Each interface microservice is started and stopped independently. When a certain interface is updated, it does not affect the services provided by other interfaces.
2. The application platform according to claim 1, characterized in that: The database server also includes a statistical database, which is configured to store the call results of the interface call request.
3. The application platform according to claim 1, characterized in that: The unified interface management method also includes: querying in the pre-stored processing class according to the target interface number to obtain the processing class corresponding to the target interface number, and determining the transmission method of the interface call request based on the correspondence between the pre-stored interface and the model application server; if the query result is empty, interrupting the interface call request.
4. The application platform according to claim 3, characterized in that: The transmission method includes sending the interface call request directly to the target server, or forwarding the interface call request to the target server through a queue forwarding service.
Citation Information
Patent Citations
Cloud management platform based on micro-service architecture
CN105162884A
Micro-service access control method and device, electronic equipment and storage medium
CN111600899A