Asynchronous micro-service simulation method and device and storage medium
By sending the identification and associating the processing results after receiving the request from the business system, the problem that existing tools cannot simulate in the asynchronous call scenario is solved, effectively simulation of asynchronous calls is realized, and the flexibility and efficiency of testing are improved.
Patent Information
- Application Number
- CN202411079520.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-07
- Publication Date
- 2024-12-13
AI Technical Summary
Existing Stub and Mock tools are difficult to simulate microservices in asynchronous call scenarios, and cannot return the request identification immediately after receiving the request and continue to receive the request, resulting in the inability to effectively simulate the scenario of asynchronous call.
After receiving the request from the business system, the corresponding identifier is sent to the business system, and the processing result is generated according to the request, the identification is associated with the processing result, and the processing result is feedbacked in response to the callback instruction or the matching target request is received, so asynchronous call is realized Scene simulation.
The simulation of asynchronous call scenarios is realized, the frequency of manual modification is reduced, the flexibility and efficiency of simulation is improved, and the ability to dynamically process request parameters and return customized responses is suitable for testing various edge cases and exception processes.
Smart Images

Figure CN119135548A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electrical communication technology, and in particular to a simulation method, device and storage medium for asynchronous microservices. Background Art
[0002] At present, stub services and mock tools are common microservice simulation tools. These tools are generally used for simulating synchronous microservices. During the simulation process, two requests need to be simulated separately, and since the request identifier is unique, each simulation can only take effect once, so frequent manual modifications are required. In the asynchronous call scenario, since the above tools need to simulate two requests separately, the simulated server cannot return the request identifier immediately after receiving the request and continue to receive requests, which makes the relevant solutions unable to simulate the asynchronous call scenario.
[0003] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The present application provides a simulation method, device and storage medium for asynchronous microservices, aiming to solve the problem that related solutions cannot simulate asynchronous call scenarios.
[0005] To achieve the above purpose, the present application provides a simulation method for an asynchronous microservice, which is applied to a simulated server. The simulation method for an asynchronous microservice includes the following steps:
[0006] After receiving the request sent by the simulated business system, sending an identifier corresponding to the request to the business system;
[0007] Generate a corresponding processing result according to the request, and associate the identifier with the processing result;
[0008] In response to a callback instruction and / or after receiving a target request sent by the business system that matches the identifier, the processing result is fed back to the business system, wherein the target request contains the same data as the request header and request body of the request.
[0009] In one embodiment, after receiving the request sent by the business system, before sending the corresponding identifier to the business system, the step further includes:
[0010] connecting the network interfaces of the first service and the second service to the proxy server;
[0011] When the first service and the second service transmit messages to each other, the proxy server receives the interaction message through the target network interface connected to the first service and the second service, wherein the interaction message is a data packet sent between the first service and the second service;
[0012] Determine the interaction message as pile data, and generate a corresponding matching rule according to the parsed data of the interaction message;
[0013] When receiving a request message sent by a client, the corresponding pile data is determined according to the matching rule, and a message corresponding to the pile data is fed back to the client.
[0014] In one embodiment, upon receiving a request message sent by a client, determining corresponding pile data according to the matching rule, and feeding back a message corresponding to the pile data to the client comprises:
[0015] Determining a corresponding target value in a request parameter in the request;
[0016] Determine a matching target rule according to the target value, and determine corresponding pile data according to the target rule;
[0017] The corresponding message is determined according to the pile data and fed back to the client.
[0018] In one embodiment, after the step of determining the corresponding pile data according to the matching rule, the method further includes:
[0019] When there is no pile data matching the request message, sending the request message to the target server;
[0020] Receive the real data fed back by the target server, and send the real data to the client.
[0021] In one embodiment, after feeding back the processing result to the business system, the method further includes:
[0022] Get the response corresponding to the target request and the target response;
[0023] Determine, according to the difference comparison module, difference field values of the response and the target response, and determine, according to the difference field values, whether the corresponding versions have changed;
[0024] If the version changes, the versions of the response and the target response are displayed in the target interface respectively.
[0025] In one embodiment, the server further includes:
[0026] The server is provided with a network delay plug-in, a field mapping plug-in, a dynamic timestamp and an identification generation plug-in;
[0027] The network delay plug-in is used to configure the network delay, the field mapping plug-in is used to configure the field mapping relationship of the return message, and the dynamic timestamp and identifier generation plug-in is used to generate time and identifier.
[0028] In one embodiment, after the step of feeding back the processing result to the business system, the method further includes:
[0029] Monitor the interaction process of the simulated service and obtain the request and corresponding response of the interaction process;
[0030] Generate a record log according to the request and response of the interaction process, and feed the record log back to the client;
[0031] In response to the adjustment operation of the client, a corresponding adjustment parameter is determined, and the corresponding target service is optimized according to the adjustment parameter.
[0032] In one embodiment, the step of determining the corresponding adjustment parameter and optimizing the corresponding target service according to the adjustment parameter includes:
[0033] Acquire the adjustment operation, and determine a corresponding behavior feature in the adjustment operation;
[0034] Input the behavior characteristics into a preset model, and output the corresponding adjustment parameters and the target services corresponding to the adjustment parameters through the preset model;
[0035] An adjustment instruction is generated according to the adjustment parameter, and the target service is optimized based on the adjustment instruction.
[0036] In addition, to achieve the above-mentioned purpose, the present application also provides a simulation device for asynchronous microservices, characterized in that the simulation device for asynchronous microservices includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the simulation method for asynchronous microservices as described above.
[0037] In addition, to achieve the above-mentioned purpose, the present application also provides a storage medium, which is a computer-readable storage medium, and a computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, the steps of the simulation method of the asynchronous microservice as described above are implemented.
[0038] The present application provides a simulation method for asynchronous microservices, a simulation device for asynchronous microservices, and a storage medium. After receiving a request sent by a business system, a corresponding identifier is sent to the business system, and then a corresponding processing result is determined according to the request, and the identifier is associated with the processing result. Finally, in response to a callback instruction and / or after receiving a target request sent by the business system that matches the identifier, the processing result is fed back to the business system, thereby realizing the simulation of an asynchronous call scenario. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0040] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0041] Figure 1 This is a flow chart of the first embodiment of the method for simulating asynchronous microservices of the present application;
[0042] Figure 2 This is a simulation flow chart of the asynchronous microservice involved in this embodiment;
[0043] Figure 3 This is a flow chart of a second embodiment of the method for simulating asynchronous microservices of the present application;
[0044] Figure 4 This is a schematic diagram of the recording service involved in this embodiment;
[0045] Figure 5 This is a flow chart of a third embodiment of the method for simulating asynchronous microservices of the present application;
[0046] Figure 6 This is a flow chart of a fourth embodiment of the method for simulating asynchronous microservices of the present application;
[0047] Figure 7 This is a schematic diagram of the architecture of the hardware operating environment of the simulation device of the asynchronous microservice involved in the embodiment of the present application.
[0048] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0049] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0050] In order to better understand the above technical solution, exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0051] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0052] The main solution of the present application is: after receiving a request sent by a business system, sending a corresponding identifier to the business system; determining a corresponding processing result according to the request, and associating the identifier with the processing result; and after responding to a callback instruction and / or receiving a target request sent by the business system that matches the identifier, feeding back the processing result to the business system.
[0053] Currently, Stub and Mock tools are common microservice simulation tools. These tools are generally used to simulate synchronous microservices. They need to simulate two requests separately. In addition, since the request ID is unique, each number creation can only take effect once and needs to be frequently modified manually. Therefore, they cannot cope with flexible actual business scenarios, which makes the related solutions unable to simulate asynchronous call scenarios.
[0054] The present application sends a corresponding identifier to the business system after receiving a request sent by the business system, determines the corresponding processing result according to the request, and associates the identifier with the processing result. After responding to a callback instruction and / or receiving a target request sent by the business system that matches the identifier, the processing result is fed back to the business system, thereby simulating an asynchronous call scenario.
[0055] It should be noted that the execution subject of this embodiment can be the OverMock (self-developed microservice simulation tool) system, or a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or a simulation device of an asynchronous microservice that can realize the above functions, etc., and this embodiment does not specifically limit this. The following takes the OverMock system as the execution subject as an example to illustrate this embodiment and the following embodiments.
[0056] Embodiment 1
[0057] Please refer to Figure 1In a first embodiment, the simulation method of the asynchronous microservice includes the following steps:
[0058] Step S10: After receiving the request sent by the simulated business system, an identifier corresponding to the request is sent to the simulated business system.
[0059] In this embodiment, the processing action is performed by the server, the server is a simulated server, and the identifier can be ID information. After the proxy server receives the request sent by the simulated business system, the proxy server immediately returns a "status" or ID information that does not contain business information, to indicate that the proxy server has successfully received the request.
[0060] Exemplarily, by using OverMock (a self-developed microservice simulation tool), the interaction scenario between the above-mentioned server and the simulated business system is simulated. When the simulated business system initiates a request to the server, the simulated business system does not have to wait for the server to complete the processing and return the result. The server will first feedback the corresponding identifier so that the business system can continue to perform other tasks in the business system. In addition, OverMock can automatically analyze the dependencies between microservices, automatically generate Mock services according to API definitions (such as OpenAPI / Swagger specifications), and reduce the workload of manually creating Mocks. Dynamic data interaction can be achieved through OverMock, that is, request parameters can be dynamically processed, and customized Mock responses can be returned based on the input, which is helpful for testing various edge cases and abnormal processes.
[0061] Specifically, Json-server (server application based on JSON data format) is a very popular lightweight tool. Through Json-server, you can quickly build a REST API (Representational State Transfer API) server that can return lightweight data exchange format (JavaScript Object Notation, JSON) data. First, create a file in Json-serve to define the data structure and content to be simulated, and then run the corresponding file and command in the preset directory and start the simulation server. Alternatively, use the Mock framework or self-built Mock service, such as using Python's Flask (lightweight Web application framework) or Node.js (JavaScript interpreter running on the server) Express (Web application framework) to quickly build a simple server and manually write logic to respond to API (Application Programming Interface) requests. Choose a suitable programming language and framework, write routes and controllers, define the simulated API path and its corresponding response data. Finally, write code to simulate specific business logic, such as state changes, error handling, etc. Start the Mock service and record the service address for the front end or client to use.
[0062] Step S20: Generate a corresponding processing result according to the request, and associate the identifier with the processing result.
[0063] In this embodiment, according to the request of the business system received in the step S10, the request service in the proxy server performs a processing action on the request, that is, confirms the feedback result corresponding to the request, wherein the processing result is the result obtained by the server after data processing and calculation logic execution, and the identifier is associated with the processing result and saved.
[0064] Specifically, the service provider performs corresponding processing based on the received request. This may involve operations such as data processing and computing logic execution. After the processing is completed, the service provider will save the processing result and associate it with the unique identifier generated previously. The purpose of this is to be able to retrieve the processing result based on this identifier later.
[0065] Step S30: in response to a callback instruction and / or after receiving a target request sent by the business system that matches the identifier, the processing result is fed back to the business system, wherein the target request contains the same data as the request header and request body of the request.
[0066] In this embodiment, the business system provides a callback address when sending a request. After processing the request, the server will carry the identifier and processing result to the callback address provided by the business system through a Hypertext Transfer Protocol (HTTP) call or other means, thereby notifying the business system that the processing has been completed, and then the business system receives the processing result of the request. If the pull mode is adopted, the business system will send a target request containing an identifier to the server at an appropriate time or according to a certain strategy, such as timing, to query the processing status and obtain the result. The server searches for the associated processing result based on the received identifier and returns it to the business system.
[0067] In addition, you can also configure the "next hop" to return messages. When the client request matches the rule, multi-level messages can be returned in sequence.
[0068] Optionally, in this embodiment, the server further includes:
[0069] The server is provided with a network delay plug-in, a field mapping plug-in, a dynamic timestamp and identifier generation plug-in; the network delay plug-in is used to configure the network delay, the field mapping plug-in is used to configure the field mapping relationship of the return message, and the dynamic timestamp and identifier generation plug-in is used to generate time and identifier.
[0070] Specifically, a network delay plug-in, a field mapping plug-in, a dynamic timestamp and an identifier generation plug-in are also provided in the simulated server, wherein the network delay plug-in can simulate delays by configuring options and parameters, thereby configuring network delays, the field mapping plug-in associates messages with corresponding fields, thereby configuring the field mapping relationship of the returned message, and the dynamic timestamp and identifier generation plug-in are used to generate time and identifiers. In addition, if the time column returned in the message is the system time, the current time can be obtained through the dynamic timestamp, and if some fields of the message are randomly generated token (temporary token) values, random token values can be generated through the identifier generation plug-in.
[0071] For example, Figure 2 As shown, Figure 2This is a simulation flow chart of the asynchronous microservice involved in the embodiment scheme. Assume that OverMock simulates a scenario in which an e-commerce platform processes the status update of a user's order payment. The user submits an order payment request on the e-commerce platform. After the platform backend server receives the payment request, it first generates a unique identifier, such as "OrderPay_20230401", and then immediately responds to the front-end business system through the interface. In this way, the front end knows that the payment operation has an "identity certificate", and the backend server continues to process the payment request, such as verifying whether the user has successfully paid through a third-party payment platform. Assuming that the payment is successful, the backend system records the processing result and associates the successful status with the previously generated identifier "OrderPay_20230401" and saves it in the database. The corresponding payment result information can be quickly found through this identifier. Once the payment status is confirmed, whether it is through the callback notification of the payment platform or the active query of the business system, this mechanism will work. After the processing is completed, the payment platform will send a callback notification to the e-commerce platform, including the unique identifier "OrderPay_20230401". The backend server of the e-commerce platform receives this callback, finds the associated successful payment record based on the identifier, then updates the order status to "paid", and notifies the user of the successful payment through the business system. Alternatively, the business system initiates a query request on a regular basis / as needed, and carries this identifier to inquire about the order payment status of the backend server. The backend server also searches through the identifier and returns the "paid" status to the frontend, which then displays it to the user.
[0072] In the technical solution provided in this embodiment, after receiving the request sent by the business system, a corresponding identifier is sent to the business system, and then the corresponding processing result is determined according to the request, and the identifier is associated with the processing result. Then, in response to the callback instruction and / or after receiving the target request sent by the business system that matches the identifier, the processing result is fed back to the business system, thereby realizing the simulation of the asynchronous call scenario.
[0073] Embodiment 2
[0074] Please refer to Figure 3 In the second embodiment, before step S10, the following steps are also included:
[0075] Step S40: Connect the network interfaces of the first service and the second service to the proxy server.
[0076] Step S50: When the first service and the second service transmit messages to each other, the proxy server receives interaction messages through a target network interface connected to the first service and the second service, wherein the interaction messages are data packets sent between the first service and the second service.
[0077] Step S60: Determine the interaction message as pile data, and generate corresponding matching rules according to the parsed data of the interaction message.
[0078] In this embodiment, the proxy server is one of a plurality of services provided in the server, wherein a recording mode is provided, wherein the recording mode is used to record messages generated by direct interaction between the first service and the second service, that is, the interaction messages between the first service and the second service are captured and saved by the proxy server, wherein the interaction messages include request messages and response messages, and a specific capturing method may be to connect the network interface of the captured data, that is, to connect the target network interface of the proxy server to the network interfaces of the first service and the second service, or to configure the network interfaces of the first service and the second service to a promiscuous mode so that the target network interface can capture the interaction messages.
[0079] It is understandable that the request message can be a request message sent by the first service to the second service, or a request message sent by the second service to the first service. Similarly, the response message includes the response messages of the first service and the second service. The request header, request body or parameters are customized to generate matching rules. The matching rules can be used to match the corresponding response message according to a field value in the request, or the matching rules can be used to determine the corresponding response message according to the identifier corresponding to the request.
[0080] Specifically, you can configure the proxy server in the jvm parameters of the microservice. Taking the java application as an example, configure the native JDK parameters -Dhttp.proxyHost, -Dhttp.proxyPort, and -Dhttps.proxyHost, -Dhttps.proxyPort as the ip and port information of the OverMock recording server. The OverMock recording server can capture the http and https interaction messages between service A and service B. OverMock provides a page to view the captured messages and display the application information for distinction. Users can choose whether to store the recorded messages for subsequent use, or customize the request header, request body or parameters to generate matching rules.
[0081] In addition, after capturing the interaction message between the first service and the second service, the interaction message can be saved in a database, which can be BoltDB (embedded key / value database), a lightweight key-value storage database suitable for local storage scenarios, which is suitable for configuration storage, caching, small indexing and other scenarios, when the data model is simple and has high requirements for read and write speed. It can also be Elasticsearch (distributed search and analysis engine), which is a distributed full-text search engine built on the Lucene (full-text search engine toolkit) library, designed for large data volumes, real-time analysis and complex search queries.
[0082] Step S70: upon receiving a request message sent by the client, the corresponding pile data is determined according to the matching rule, and a message corresponding to the pile data is fed back to the client.
[0083] In this embodiment, before the client sends a request message to the server, the client first determines the format and type of the message according to the communication protocol, and then determines the data to be sent to the server as responsible data, and encapsulates it into the request, thereby generating a corresponding request message. Then the client sends the request message to the server, and the server determines the corresponding pile data according to the above matching rules, wherein the pile data is the message data captured by the recording service, stored in the database of the server, and associated with the corresponding matching rules, or is a preset data set used to simulate the message data in the real environment, and finally the message corresponding to the pile data is fed back to the client.
[0084] In addition, virtual services can match different rules according to different request data. They can use all real services, all stub data, or some real services and some stub data.
[0085] Optionally, in this embodiment, step S50 includes:
[0086] Determine the corresponding target value in the request parameters, request body and request header in the request; determine the matching target rule according to the target value, and determine the corresponding pile data according to the target rule; determine the corresponding message according to the pile data and feed it back to the client.
[0087] Specifically, the matcher can use stub data when a rule is matched based on the http / https header, parameter, body, or a value in the request body. If no match is found, the matcher accesses the external real dependency service to obtain the real data.
[0088] In addition, the matcher supports multiple matching methods such as exact matching, fuzzy matching, regular matching and path matching, so that different results can be returned when accessing the same microservice without affecting each other. This is suitable for scenarios where different users want the same microservice to return different results for testing.
[0089] Furthermore, in this embodiment, after the step of determining the corresponding pile data according to the matching rule, the method further includes:
[0090] When there is no stub data matching the request message, the request message is sent to the target server; the real data fed back by the target server is received, and the real data is sent to the client.
[0091] Specifically, when the corresponding pile data is not determined by the matching rules in the matcher, that is, there is no matching response message for the requested message, the request message is sent to the target server, wherein the target server is the real server in the actual message interaction process, and the real data fed back by the target server is fed back to the client as a response message.
[0092] For example, Figure 4 As shown, Figure 4 This is a schematic diagram of the recording service involved in the present embodiment. Assume that the first service is service A, and the second service is dependent service B. A proxy server is set between service A and dependent service B through OverMock. The proxy server includes a recording proxy service. During the interaction between service A and dependent service B, the recording proxy service in the proxy server will capture and save the various parameters of the request in real time.
[0093] In the technical solution provided in this embodiment, the interaction message between the first service and the second service is captured by a proxy service, and a corresponding matching rule is generated according to the interaction message, so that when the request message sent by the client is received, the corresponding pile data is determined according to the matching rule, and the message corresponding to the pile data is fed back to the client, so that the real request and response messages can be recorded through the recording function, thereby improving the collection efficiency of the pile data.
[0094] Embodiment 3
[0095] Please refer to Figure 5 In the third embodiment, after feeding back the processing result to the business system, the method further includes:
[0096] Step S80: Obtain the response corresponding to the target request and the target response.
[0097] Step S90: determining the difference field values between the response and the target response according to the difference comparison module, and determining whether the corresponding versions are changed according to the difference field values.
[0098] Step S100: If the version is changed, the versions of the response and the target response are displayed in the target interface respectively.
[0099] In this embodiment, one of the target requests may correspond to one of the responses and one of the target responses, or may correspond to at least two responses. The response and the target response are first parsed through a difference comparison module, and then the field values generated by the parsing are compared to determine the difference field values, so as to determine whether the versions of the response and the target response have changed based on the difference field values.
[0100] Specifically, the difference comparison function can be used to compare the differences in responses to the same request, thereby discovering changes in external services. For example, OverMock stores the service response of version 1.0. If the external service is upgraded to version 1.1, the changes between versions can be detected to flexibly detect changes in external services, and the differences in versions can also be visualized. When comparing different responses to the same request, the corresponding comparison rules can be further configured according to the difference field values to issue difference warnings.
[0101] In the technical solution provided in this embodiment, the response corresponding to the target request and the target response are obtained, and then the difference field values of the response and the target response are determined according to the difference comparison module, and whether the corresponding version has changed is determined according to the difference field value. If the version has changed, the versions of the response and the target response are respectively displayed in the target interface, thereby realizing version comparison of different responses to the same request and visually displaying the differences.
[0102] Embodiment 4
[0103] Please refer to Figure 6 In the fourth embodiment, after step S30, the method further includes:
[0104] Step S110: monitor the interaction process of the simulated service, and obtain the request and corresponding response of the interaction process.
[0105] In this embodiment, a monitoring mechanism is used to track and record all interactions with the simulated server, wherein the monitoring mechanism can be a monitoring tool or a monitoring plug-in deployed in the server. These interactions include the request sent by the client to the service and all the parameters it carries, as well as the response returned by the service to the client, whether it is a successful data packet or an error message. This is usually achieved through a network packet capture tool, an application performance management tool, or a custom logging module.
[0106] Specifically, you can use a tool like Wireshark to capture network packets, or embed logging statements in your code to collect this information.
[0107] Step S120: Generate a record log according to the request and response of the interaction process, and feed the record log back to the client.
[0108] In this embodiment, after collecting the request and response information, the server will organize the data and generate log records that are easy to understand and analyze, wherein the log records contain timestamps, request types, request URLs, request parameters, response status codes, response times, and response body summaries, etc. Afterwards, the server will feed back the logs to the client or administrator in some form, such as through an API, email, or a web interface, so as to review the operation status of the simulated server.
[0109] Step S130: In response to the adjustment operation of the client, a corresponding adjustment parameter is determined, and the corresponding target service is optimized according to the adjustment parameter.
[0110] In this embodiment, when the client finds that the service performance or function needs to be improved based on log analysis, the administrator will make corresponding adjustment operations and determine corresponding adjustment parameters, including modifying configuration parameters such as timeout, number of concurrent connections, optimizing database queries, adjusting load balancing strategies, etc. The server receives and parses the adjustment operation to obtain the corresponding adjustment parameters, and then configures the service or algorithm according to the adjustment parameters.
[0111] In addition, you can set up a configuration management system that can receive external instructions, verify their validity, and then apply them to the server. The optimization process can also include A / B testing new configurations to ensure that the changes have the expected positive effects.
[0112] Optionally, in this embodiment, step S130 includes:
[0113] Acquire the adjustment operation, and determine the corresponding behavior characteristics in the adjustment operation; input the behavior characteristics into a preset model, and output the corresponding adjustment parameters and the target service corresponding to the adjustment parameters through the preset model; generate adjustment instructions according to the adjustment parameters, and optimize the target service based on the adjustment instructions.
[0114] Specifically, the adjustment operation is performed by the administrator based on the adjustment interface of the client. The client feeds back the adjustment operation to the simulation server. The simulation server determines the behavior characteristics corresponding to the adjustment operation through a semantic analysis algorithm. The behavior characteristics include increasing parameter values, reducing parameter values, or modifying the configuration item functions in the simulation server. The preset model can be a trained machine learning model, such as a regression model, a decision tree, a neural network, etc., which can predict an ideal adjustment strategy based on the input behavior characteristics. The adjustment parameters directly guide how to optimize the target service. For example, the output may be "reducing database query latency requires increasing cache capacity to XXMB." "Target service" indicates which specific service or component should be adjusted. Finally, the adjustment instruction is executed to actually change the configuration or parameters of the target service to complete the optimization process.
[0115] In the technical solution provided in this embodiment, the interaction process of the simulated service is monitored, and the request and the corresponding response of the interaction process are obtained, and then a record log is generated according to the request and response of the interaction process, and the record log is fed back to the client, and finally, in response to the adjustment operation of the client, the corresponding adjustment parameters are determined, and the corresponding target service is optimized according to the adjustment parameters, so that the performance of the simulated service can be optimized by monitoring the simulated service in real time and adjusting the corresponding parameters.
[0116] Since the system introduced in the embodiment of the present application is a system used to implement the method of the embodiment of the present application, based on the method introduced in the embodiment of the present application, the person skilled in the art can understand the specific structure and deformation of the system, so it is not repeated here. All systems used in the method of the embodiment of the present application belong to the scope of protection of this application.
[0117] The present application provides a simulation device for asynchronous microservices, and the simulation device for asynchronous microservices includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the simulation method for the asynchronous microservice in the above-mentioned embodiment 1.
[0118] Reference below Figure 7, which shows a schematic diagram of the structure of a simulation device suitable for implementing the asynchronous microservice of the embodiment of the present application. The simulation device of the asynchronous microservice in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The simulation device of the asynchronous microservice shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0119] like Figure 7 As shown, the simulation device of the asynchronous microservice may include a processing device 1001 (e.g., a core processor, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the simulation device of the asynchronous microservice are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the simulation device of the asynchronous microservice to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows the simulation device of the asynchronous microservice with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided instead.
[0120] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0121] The simulation device of the asynchronous microservice provided by the present application adopts the simulation method of the asynchronous microservice in the above embodiment, which can solve the technical problem that the related solution cannot simulate the asynchronous call scenario. Compared with the prior art, the beneficial effects of the simulation device of the asynchronous microservice provided by the present application are the same as the beneficial effects of the simulation method of the asynchronous microservice provided by the above embodiment, and the other technical features in the simulation device of the asynchronous microservice are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0122] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0123] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0124] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, the computer-readable program instructions being used to execute the simulation method for asynchronous microservices in the above-mentioned embodiment.
[0125] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0126] The computer-readable storage medium may be included in the simulation device of the asynchronous microservice; or may exist independently without being assembled into the simulation device of the asynchronous microservice.
[0127] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the simulation device of the asynchronous microservice, the simulation device of the asynchronous microservice: after receiving a request sent by the simulated business system, sends an identifier corresponding to the request to the simulated business system;
[0128] Generate a corresponding processing result according to the request, and associate the identifier with the processing result; after responding to a callback instruction and / or receiving a target request sent by the business system that matches the identifier, feed the processing result back to the business system, wherein the target request contains the same data as the request header and request body of the request.
[0129] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0130] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0131] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0132] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned asynchronous microservice simulation method, and can solve the technical problem that the related solutions cannot simulate asynchronous call scenarios. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the asynchronous microservice simulation method provided by the above-mentioned embodiment, and will not be repeated here.
[0133] An embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the above-mentioned method for simulating asynchronous microservices.
[0134] The computer program product provided by this application can solve the technical problem that the related solutions cannot simulate the scenario of asynchronous calls. Compared with the prior art, the beneficial effects of the computer program product provided by the embodiment of this application are the same as the beneficial effects of the simulation method of asynchronous microservices provided by the above embodiment, which will not be repeated here.
[0135] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.
Claims
1. A simulation method for asynchronous microservices, characterized in that: Applied to the simulated server, the simulation method of the asynchronous microservice includes the following steps: After receiving the request sent by the simulated business system, sending an identifier corresponding to the request to the simulated business system; Generate a corresponding processing result according to the request, and associate the identifier with the processing result; In response to a callback instruction and / or after receiving a target request sent by the business system that matches the identifier, the processing result is fed back to the business system, wherein the target request contains the same data as the request header and request body of the request.
2. The method according to claim 1, characterized in that After receiving the request sent by the business system, before sending the corresponding identifier to the business system, the method further includes: connecting the network interfaces of the first service and the second service to the proxy server; When the first service and the second service transmit messages to each other, the proxy server receives the interaction message through the target network interface connected to the first service and the second service, wherein the interaction message is a data packet sent between the first service and the second service; Determine the interaction message as pile data, and generate a corresponding matching rule according to the parsed data of the interaction message; When receiving a request message sent by a client, the corresponding pile data is determined according to the matching rule, and a message corresponding to the pile data is fed back to the client.
3. The method according to claim 2, characterized in that The step of determining corresponding pile data according to the matching rule upon receiving a request message sent by the client, and feeding back a message corresponding to the pile data to the client comprises: Determining a corresponding target value in a request parameter in the request; Determine a matching target rule according to the target value, and determine corresponding pile data according to the target rule; The corresponding message is determined according to the pile data and fed back to the client.
4. The method according to claim 2, characterized in that After the step of determining the corresponding pile data according to the matching rule, the method further includes: When there is no pile data matching the request message, sending the request message to the target server; Receive the real data fed back by the target server, and send the real data to the client.
5. The method according to claim 1, characterized in that After feeding back the processing result to the business system, the method further includes: Get the response corresponding to the target request and the target response; Determine, according to the difference comparison module, difference field values of the response and the target response, and determine, according to the difference field values, whether the corresponding versions have changed; If the version changes, the versions of the response and the target response are displayed in the target interface respectively.
6. The method according to claim 1, characterized in that The server is provided with a network delay plug-in, a field mapping plug-in, a dynamic timestamp and an identification generation plug-in, and the method comprises: The network delay plug-in is used to configure the network delay, the field mapping plug-in is used to configure the field mapping relationship of the return message, and the dynamic timestamp and identifier generation plug-in is used to generate time and identifier.
7. The method according to claim 1, characterized in that After the step of feeding back the processing result to the business system, the method further includes: Monitor the interaction process of the simulated service and obtain the request and corresponding response of the interaction process; Generate a record log according to the request and response of the interaction process, and feed the record log back to the client; In response to the adjustment operation of the client, a corresponding adjustment parameter is determined, and the corresponding target service is optimized according to the adjustment parameter.
8. The method according to claim 7, characterized in that The step of determining the corresponding adjustment parameters and optimizing the corresponding target service according to the adjustment parameters includes: Acquire the adjustment operation, and determine a corresponding behavior feature in the adjustment operation; Input the behavior characteristics into a preset model, and output the corresponding adjustment parameters and the target services corresponding to the adjustment parameters through the preset model; An adjustment instruction is generated according to the adjustment parameter, and the target service is optimized based on the adjustment instruction.
9. A simulation device for asynchronous microservices, characterized in that: The simulation device of the asynchronous microservice includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the simulation method of the asynchronous microservice according to any one of claims 1 to 8.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for simulating asynchronous microservices according to any one of claims 1 to 8 are implemented.
