A data processing method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202210473059.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-29
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2042-04-29
AI Technical Summary
[0086]通过响应于客户端发送的第一请求,确定第一请求对应的行为特征信息;根据行为特征信息确定对第一请求的处理方式;处理方式包括异步处理方式或者同步处理方式;在异步处理方式或者同步处理方式下,若确定进入第一操作执行状态,生成第一操作对应的事务消息;向消息中间件发送事务消息;根据行为特征信息执行第一操作,确定第一操作的执行结果;根据执行结果,向客户端发送第一请求响应,并向消息中间件发送回滚消息或者执行成功消息;回滚消息用于指示消息中间件删除事务消息,执行成功消息用于指示消息中间件向行为特征信息记录模块推送行为特征信息。本公开使得服务端在面对突发请求高峰时,可以保持高稳定性和高可用性。
Smart Images

Figure CN117014508B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of Internet technology, and in particular to a data processing method, apparatus, electronic device and storage medium. Background Technology
[0002] With the development of the internet and the widespread use of mobile devices, people are increasingly inclined to engage in various forms of entertainment on mobile devices, such as watching short videos and live streams through applications.
[0003] When users engage with such applications, they generate various actions, such as commenting and sending gifts, which trigger a surge in requests. This often exposes issues with the availability, stability, and performance of the backend service. Therefore, it is necessary to optimize the backend service to handle sudden spikes in requests. Summary of the Invention
[0004] This disclosure provides a data processing method, apparatus, electronic device, and storage medium. The technical solution of this disclosure is as follows:
[0005] According to a first aspect of the present disclosure, a data processing method is provided, comprising:
[0006] In response to the first request sent by the client, determine the behavioral characteristic information corresponding to the first request;
[0007] The processing method for the first request is determined based on behavioral characteristic information; the processing method may include asynchronous processing or synchronous processing.
[0008] In both asynchronous and synchronous processing modes, if it is determined that the first operation execution state has been entered, a transaction message corresponding to the first operation is generated.
[0009] Send a transaction message to the message broker;
[0010] Execute the first operation based on the behavioral characteristic information, and determine the execution result of the first operation;
[0011] Based on the execution result, a first request response is sent to the client, and a rollback message or an execution success message is sent to the message middleware. The rollback message is used to instruct the message middleware to delete the transaction message, and the execution success message is used to instruct the message middleware to push the behavior feature information to the behavior feature information recording module.
[0012] In one possible embodiment, determining the processing method for the first request based on behavioral characteristic information includes:
[0013] The category of the first request is determined based on behavioral characteristics.
[0014] Determine the processing method for the first request based on its category.
[0015] In one possible embodiment, determining the processing method for the first request based on its category includes:
[0016] When the first request is of type 1, the processing method for the first request is determined to be synchronous processing.
[0017] Determining to enter the first operation execution state includes:
[0018] Upon receiving the behavioral characteristic information sent by the first request receiving module, it is determined to enter the first operation execution state.
[0019] In one possible embodiment, the behavioral feature information includes a first account identifier and a behavioral feature value; performing a first operation based on the behavioral feature information includes:
[0020] Based on the first account identifier and behavioral characteristic value, the information corresponding to the first account identifier in the local database is processed.
[0021] In one possible embodiment, determining the processing method for the first request based on its category includes:
[0022] When the first request is classified as category two, the processing method for the first request is determined to be asynchronous processing.
[0023] Determining to enter the first operation execution state includes:
[0024] When a set of behavioral feature information to be processed is obtained from a first preset cache area according to a first preset time interval, it is determined to enter the first operation execution state; wherein, the set of behavioral feature information includes a preset number of behavioral feature information.
[0025] In one possible embodiment, the behavioral characteristic information includes a first account identifier and behavioral characteristic values;
[0026] Before performing the first operation based on behavioral characteristic information, the following steps are also included:
[0027] The set of behavioral feature information to be processed is divided into multiple behavioral feature information subsets; multiple behavioral feature information subsets correspond to multiple different account identifiers; each behavioral feature information in each behavioral feature information subset corresponds to the same account identifier.
[0028] Determine the total behavioral feature value corresponding to each subset of behavioral feature information;
[0029] Perform the first operation based on behavioral characteristic information, including:
[0030] Based on the first account identifier and the total behavioral feature value corresponding to the first account identifier, the information corresponding to the first account identifier in the local database is processed.
[0031] In one possible embodiment, after sending the transaction message to the message broker, the process further includes:
[0032] Receive a callback message sent by the message middleware; the callback message is generated by the message middleware if it does not receive a rollback message and an execution success message within a preset time after receiving the transaction message;
[0033] In response to the query message, retrieve the execution result of the first operation;
[0034] When the execution result indicates that the first operation was executed successfully, a success message is sent to the message middleware; or, when the execution result indicates that the first operation failed, a rollback message is sent to the message middleware.
[0035] In one possible embodiment, after determining the processing method for the first request based on the behavioral characteristic information, the method further includes:
[0036] Based on the token bucket model, behavioral feature information is sent to the message middleware or the first operation processing module.
[0037] In one possible embodiment, based on the token bucket model, the behavioral feature information is sent to the message middleware or the first operation processing module, including:
[0038] Determine the number of tokens required to send behavioral characteristic information;
[0039] If the number of tokens in the current token bucket is greater than or equal to the required number of tokens, the behavior feature information is sent to the message middleware; or, if the number of tokens in the current token bucket is less than the required number of tokens, the behavior feature information is cached in the second preset cache area; according to the second preset time interval, a preset number of behavior feature information is read from the second preset cache area, and the preset number of behavior feature information is sent to the message middleware or the first operation processing module.
[0040] In one possible embodiment, the first request includes an idempotency identifier; the idempotency identifier is generated by the client; the behavioral feature information includes a behavioral feature identifier;
[0041] In response to the first request sent by the client, determine the behavioral characteristic information corresponding to the first request, including:
[0042] In response to the first request sent by the client, the corresponding behavioral feature identifier is obtained based on the idempotency identifier carried in the first request.
[0043] In one possible embodiment, obtaining the corresponding behavioral feature identifier based on the idempotency identifier carried in the first request includes:
[0044] Obtain the mapping relationship between idempotent identifiers and behavioral feature identifiers; the mapping relationship includes multiple idempotent identifiers and multiple behavioral feature identifiers, with a one-to-one correspondence between the multiple idempotent identifiers and the multiple behavioral feature identifiers;
[0045] If it is determined that the idempotent identifier carried in the first request exists among multiple idempotent identifiers, then the corresponding behavioral feature identifier is determined from the mapping relationship; or, if it is determined that the idempotent identifier carried in the first request does not exist among multiple idempotent identifiers, then the corresponding behavioral feature identifier is generated by the behavioral feature identifier generation module.
[0046] In one possible embodiment, the corresponding behavioral feature identifier is generated by the behavioral feature identifier generation module, including:
[0047] The legitimacy of the first account corresponding to the first request is determined by the behavior feature identification generation module; the legitimacy includes the frequency of the first account's behavior and / or risk level; the frequency of behavior represents the number of times the first account initiates the first request within a preset time period; the risk level is determined according to preset judgment rules.
[0048] Once the first account is determined to be legitimate, the behavior feature generation module generates the corresponding behavior feature identifier.
[0049] According to a second aspect of the present disclosure, a data processing apparatus is provided, comprising:
[0050] The first request receiving module is configured to execute a response to the first request sent by the client and determine the behavioral characteristic information corresponding to the first request.
[0051] The first request receiving module is also configured to determine the processing method for the first request based on behavioral characteristic information; the processing method includes asynchronous processing or synchronous processing.
[0052] The first operation processing module is configured to execute in asynchronous or synchronous processing mode. If it is determined to enter the first operation execution state, it generates the transaction message corresponding to the first operation.
[0053] The first operation processing module is also configured to send transaction messages to the message middleware;
[0054] The first operation processing module is also configured to perform a first operation based on behavioral feature information and determine the execution result of the first operation;
[0055] The first operation processing module is also configured to send a first request response to the client based on the execution result, and send a rollback message or an execution success message to the message middleware; the rollback message is used to instruct the message middleware to delete the transaction message, and the execution success message is used to instruct the message middleware to push the behavior feature information to the behavior feature information recording module.
[0056] In one possible embodiment, the first request receiving module includes:
[0057] The first determining submodule is configured to determine the category of the first request based on behavioral characteristic information;
[0058] The second determining submodule is configured to determine how to handle the first request based on the category of the first request.
[0059] In one possible embodiment, the second determining submodule is configured to determine, when the category of the first request is a first category, the processing method for the first request is synchronous processing.
[0060] The third determining module is configured to determine whether to enter the first operation execution state when it receives behavioral feature information sent by the first request receiving module.
[0061] In one possible embodiment, the behavioral characteristic information includes a first account identifier and behavioral characteristic values;
[0062] The first operation processing module is configured to process the information corresponding to the first account identifier in the local database based on the first account identifier and behavioral characteristic value.
[0063] In one possible embodiment, the second determining submodule is configured to determine, when the category of the first request is the second category, the processing method for the first request is asynchronous processing.
[0064] The first operation processing module is configured to determine to enter the first operation execution state when it retrieves a set of behavioral feature information to be processed from a first preset cache area according to a first preset time interval; wherein the set of behavioral feature information includes a preset number of behavioral feature information.
[0065] In one possible embodiment, the behavioral feature information includes a first account identifier and behavioral feature values; the apparatus further includes:
[0066] The first operation processing module is configured to divide the set of behavioral feature information to be processed into multiple behavioral feature information subsets; multiple behavioral feature information subsets correspond to multiple different account identifiers; each behavioral feature information in each behavioral feature information subset corresponds to the same account identifier; and determine the total behavioral feature value corresponding to each behavioral feature information subset.
[0067] The first operation processing module is configured to process the information corresponding to the first account identifier in the local database based on the first account identifier and the total behavioral feature value corresponding to the first account identifier.
[0068] In one possible embodiment, the device further includes:
[0069] The first operation processing module is configured to execute the callback message sent by the message receiving middleware; the callback message is generated by the message middleware when it does not receive a rollback message and an execution success message within a preset time after receiving the transaction message;
[0070] The first operation processing module is configured to respond to the callback message and query the execution result of the first operation;
[0071] The first operation processing module is configured to send an execution success message to the message middleware when the execution result indicates that the first operation was executed successfully; or, send a rollback message to the message middleware when the execution result indicates that the first operation failed.
[0072] In one possible embodiment, the first request receiving module is configured to perform a token bucket model-based operation, sending behavioral feature information to the message middleware or the first operation processing module.
[0073] In one possible embodiment, the first request receiving module is configured to: determine the number of tokens required to send behavioral feature information; if the number of tokens in the current token bucket is greater than or equal to the required number of tokens, send the behavioral feature information to the message middleware; or; if the number of tokens in the current token bucket is less than the required number of tokens, cache the behavioral feature information in a second preset cache area; read a preset number of behavioral feature information from the second preset cache area according to a second preset time interval, and send the preset number of behavioral feature information to the message middleware.
[0074] In one possible embodiment, the first request includes an idempotency identifier; the idempotency identifier is generated by the client; the behavioral feature information includes a behavioral feature identifier;
[0075] The first request receiving module is configured to execute a response to the first request sent by the client and obtain the corresponding behavioral feature identifier based on the idempotency identifier carried in the first request.
[0076] In one possible embodiment, the first request receiving module is configured to perform an operation to obtain a mapping relationship between idempotent identifiers and behavioral feature identifiers; the mapping relationship includes multiple idempotent identifiers and multiple behavioral feature identifiers, with a one-to-one correspondence between the multiple idempotent identifiers and the multiple behavioral feature identifiers; if it is determined that the idempotent identifier carried in the first request exists among the multiple idempotent identifiers, then the corresponding behavioral feature identifier is determined from the mapping relationship; or; if it is determined that the idempotent identifier carried in the first request does not exist among the multiple idempotent identifiers, then the corresponding behavioral feature identifier is generated by the behavioral feature identifier generation module.
[0077] In one possible embodiment, a behavior feature identification generation module is also included;
[0078] The behavior feature identifier generation module is configured to determine the legitimacy of the first account corresponding to the first request; the legitimacy includes the frequency of the first account's behavior operations and / or risk level; the frequency of behavior operations represents the number of times the first account initiates the first request within a preset time; the risk level is determined according to preset judgment rules; if the first account is determined to be legitimate, the corresponding behavior feature identifier is generated.
[0079] According to a third aspect of the present disclosure, an electronic device is provided, comprising:
[0080] processor;
[0081] Memory used to store processor-executable instructions;
[0082] The processor is configured to execute instructions to implement the data processing method provided in the first aspect of the present disclosure.
[0083] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, which, when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the data processing method provided in the first aspect of the present disclosure.
[0084] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program stored in a readable storage medium, wherein at least one processor of a computer device reads from the readable storage medium and executes the computer program, causing the computer device to perform the data processing method provided in the first aspect of the present disclosure.
[0085] The technical solutions provided by the embodiments of this disclosure have at least the following beneficial effects:
[0086] By responding to a first request sent by the client, the system determines the behavioral characteristic information corresponding to the first request; based on the behavioral characteristic information, it determines the processing method for the first request; the processing method includes asynchronous processing or synchronous processing; under asynchronous or synchronous processing, if it is determined that the system is entering the first operation execution state, a transaction message corresponding to the first operation is generated; the transaction message is sent to the message middleware; the first operation is executed based on the behavioral characteristic information, and the execution result of the first operation is determined; based on the execution result, a first request response is sent to the client, and a rollback message or an execution success message is sent to the message middleware; the rollback message is used to instruct the message middleware to delete the transaction message, and the execution success message is used to instruct the message middleware to push the behavioral characteristic information to the behavioral characteristic information recording module. This disclosure enables the server to maintain high stability and high availability when facing sudden surges in requests.
[0087] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0088] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0089] Figure 1 This is a schematic diagram illustrating an application environment according to an exemplary embodiment;
[0090] Figure 2 This is a flowchart illustrating a data processing method according to an exemplary embodiment;
[0091] Figure 3 This is a flowchart illustrating a data interaction according to an exemplary embodiment;
[0092] Figure 4 This is a flowchart illustrating a data processing method according to an exemplary embodiment;
[0093] Figure 5 This is a schematic diagram illustrating a data processing procedure based on a token bucket model according to an exemplary embodiment;
[0094] Figure 6 This is a schematic diagram illustrating data interaction between various modules of a server according to an exemplary embodiment;
[0095] Figure 7 This is a schematic diagram illustrating data interaction between various modules of a server according to an exemplary embodiment;
[0096] Figure 8This is a schematic diagram illustrating data interaction between various modules of a server according to an exemplary embodiment;
[0097] Figure 9 This is a schematic diagram illustrating data interaction between various modules of a client and a server according to an exemplary embodiment;
[0098] Figure 10 This is a schematic diagram illustrating data interaction between various modules of a client and a server according to an exemplary embodiment;
[0099] Figure 11 This is a schematic diagram illustrating data interaction between various modules of a client and a server according to an exemplary embodiment;
[0100] Figure 12 This is a schematic diagram illustrating data interaction between various modules of a client and a server according to an exemplary embodiment;
[0101] Figure 13 This is a block diagram illustrating a data processing apparatus according to an exemplary embodiment;
[0102] Figure 14 This is a block diagram illustrating an electronic device for data processing according to an exemplary embodiment. Detailed Implementation
[0103] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0104] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar first objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0105] It should be noted that the user information involved in this disclosure (including but not limited to user device information, user personal information, etc.) is all information authorized by the user or fully authorized by all parties.
[0106] In related technologies, backend servers may face sudden surges in requests. The data processing method of this disclosure can optimize the server so that it can maintain high stability and high availability when facing sudden surges in requests.
[0107] like Figure 1 As shown, Figure 1 This is a schematic diagram of an application environment for a data processing method according to an exemplary embodiment. The application environment may include a client 101 and a server 102, and the client 101 and the server 102 may be connected via a wired network or a wireless network.
[0108] In one possible embodiment, the user of client 101 logs into the application with pre-registered user information to use the data processing service provided by server 102; client 101 may generate a first request based on user operation and send the first request to server 102;
[0109] Server 102 responds to the first request sent by client 101, determines the behavioral characteristic information corresponding to the first request, and determines the processing method for the first request based on the behavioral characteristic information. The processing method includes asynchronous processing or synchronous processing. Under asynchronous or synchronous processing, if server 102 determines to enter the first operation execution state, it generates a transaction message corresponding to the first operation. Then, server 102 sends the transaction message to the message middleware. Based on the behavioral characteristic information, server 102 executes the first operation and determines the execution result of the first operation. Then, based on the execution result, server 102 sends a first request response to client 101 and sends a rollback message or an execution success message to the message middleware. The rollback message is used to instruct the message middleware to delete the transaction message, and the execution success message is used to instruct the message middleware to push the behavioral characteristic information to the behavioral characteristic information recording module.
[0110] The client 101 can be a smartphone, tablet, laptop, desktop computer, etc., but is not limited to these. The client 101 can have client software, such as an application (App), installed to provide human-computer interaction functions. This application can be a standalone application or a subroutine within an application. For example, the application could be a news application, a live streaming application, or a video application. Users of the client 101 can log in to the application using pre-registered user information, which may include an account and password.
[0111] In this context, server 102 can be a server that provides backend services for the application in client 101. Specifically, the services provided by server 102 can be data processing services. Server 102 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0112] It should be understood that Figure 1 The application environment shown is only an example. In actual applications, the data processing method of this disclosure embodiment can be executed independently by the client or the server, or the data processing method of this disclosure embodiment can be executed in cooperation between the client and the server. This disclosure embodiment does not limit the specific application environment.
[0113] Figure 2 This is a flowchart illustrating a data processing method according to an exemplary embodiment, such as... Figure 2 As shown, data processing methods are used for Figure 1 Taking the server-side as an example, the steps include:
[0114] In step S201, in response to the first request sent by the client, the behavioral characteristic information corresponding to the first request is determined.
[0115] In this embodiment, the server includes multiple service modules, such as a first request receiving module, a first operation processing module, a second operation processing module, a behavior feature identifier generation module, and a service module for recording behavior feature information. Each service module is configured to execute different implementation steps. The first request receiving module in the server is responsible for uniformly receiving first requests from different clients, processing them accordingly, and then forwarding them to the first operation processing module to execute the corresponding first operation. The first request receiving module mainly acts as a gateway.
[0116] For ease of explanation and understanding, please refer to Figure 3 , Figure 3 This is a schematic diagram illustrating the interaction between various modules on the server side during a data processing process, according to an exemplary embodiment. The following is in conjunction with... Figure 3 To elaborate.
[0117] like Figure 3 As shown, step S201 is executed by the first request receiving module, that is, the first request receiving module responds to the first request sent by the client and determines the behavioral feature information corresponding to the first request.
[0118] The first request is generated on the client side. The user on the client side performs the first action on the specified page, which triggers the generation of the first request.
[0119] After receiving the first request from the client, the first request receiving module parses the first request to determine the behavioral characteristic information corresponding to the first request.
[0120] In step S203, the processing method for the first request is determined based on the behavioral characteristic information; the processing method includes asynchronous processing or synchronous processing.
[0121] In this embodiment of the disclosure, such as Figure 3 As shown, step S203 is executed by the first request receiving module; that is, the server determines the processing method for the first request based on the behavioral feature information through the first request receiving module; the processing method includes asynchronous processing or synchronous processing.
[0122] In related technologies, the first request receiving module adopts a synchronous processing method for all first requests. That is, the first request receiving module sends the first request to the first operation processing module, the first operation processing module executes the corresponding first operation, and after generating the corresponding first operation result, the first operation processing module sends a message to the client indicating whether the operation was successful or failed based on the actual operation result. However, in high-concurrency scenarios, the first operation processing module needs to process each first request sequentially, which will slow down the server's response to the client and consume a lot of processor memory.
[0123] Therefore, in this embodiment of the disclosure, the first request receiving module adopts different processing methods according to the first request corresponding to different behavioral feature information. The different processing methods include asynchronous processing and synchronous processing.
[0124] In one possible embodiment, the step S203 above, which determines the processing method for the first request based on behavioral characteristic information, may include the following steps:
[0125] In step S2031, the category of the first request is determined based on the behavioral characteristic information.
[0126] In one possible embodiment, the category of the first request is determined based on the behavioral feature values carried in the behavioral feature information.
[0127] Specifically, when the behavioral feature value carried in the behavioral feature information is greater than or equal to a preset behavioral feature value, the category of the first request is determined to be the first category; when the behavioral feature value carried in the behavioral feature information is less than the preset behavioral feature value, the category of the first request is determined to be the second category. The preset behavioral feature value can be determined according to the actual application scenario.
[0128] In step S2033, the processing method for the first request is determined according to the category of the first request.
[0129] In one possible embodiment, step S2033 above, determining the processing method for the first request based on the category of the first request, includes:
[0130] When the first request is of type 1, the processing method for the first request is determined to be synchronous processing.
[0131] When the first request is classified as category two, the processing method for the first request is determined to be asynchronous processing.
[0132] In the synchronous processing mode, after processing the first request, the first request receiving module forwards the corresponding behavioral feature information to the first operation processing module, so that the first operation processing module can execute the corresponding first operation based on the behavioral feature information. In the asynchronous processing mode, the first request receiving module sends the behavioral feature information to the message middleware, and the message middleware realizes asynchronous processing of the behavioral feature information. The message middleware can be any one of RabbitMQ, Kafka, or RocketMQ.
[0133] In the above embodiments, the first request receiving module determines the category of the first request based on behavioral feature information and adopts different processing methods for different categories of first requests. When the first request is determined to be of the first category, i.e., the corresponding behavioral feature value is relatively large, the first request receiving module determines to adopt a synchronous processing method; when the first request is determined to be of the second category, i.e., the corresponding behavioral feature value is relatively small, the first request determines to adopt an asynchronous processing method. In this way, by prioritizing the synchronous processing of first requests with larger behavioral feature values, it is ensured that user requests with high behavioral feature values can receive timely feedback. For first requests with smaller behavioral feature values, the asynchronous processing method will not cause user dissatisfaction. Thus, when faced with a large number of first requests, by adopting a combination of synchronous and asynchronous processing methods, the server-side data processing method can be optimized, thereby improving the server-side processing efficiency.
[0134] In one possible embodiment, after determining the processing method for the first request based on the behavioral feature information in step S203 above, the data processing method of this disclosure embodiment further includes the following steps:
[0135] In step S204, based on the token bucket model, the behavioral feature information is sent to the message middleware or the first operation processing module.
[0136] Step S204 is executed by the first request receiving module; the token bucket model is a rate limiting algorithm. A token bucket can be viewed as a container holding a certain number of tokens. When evaluating data traffic specifications using the token bucket model, the specific criterion is whether the number of tokens in the token bucket is sufficient to satisfy data forwarding. Each piece of data that needs to be forwarded must retrieve a certain number of tokens from the token bucket (the specific number of tokens depends on the data size) before it can be forwarded normally.
[0137] Specifically, the aforementioned token bucket model, which sends behavioral feature information to the message middleware or the first operation processing module, may include, for example: Figure 4 The following steps are shown:
[0138] In step S401, the number of tokens required to send the behavioral feature information is determined;
[0139] In step S403, it is determined whether the number of tokens in the current token bucket is greater than or equal to the required number of tokens; if the number of tokens in the current token bucket is greater than or equal to the required number of tokens, step S505 is executed; otherwise, steps S507 to S509 are executed.
[0140] In step S405, the behavioral feature information is sent to the message middleware or the first operation processing module;
[0141] In step S407, the behavioral feature information is cached in the second preset cache area;
[0142] In step S409, a preset number of behavioral feature information is read from the second preset cache area according to the second preset time interval, and the preset number of behavioral feature information is sent to the message middleware or the first operation processing module.
[0143] The following is combined with Figure 5 The above embodiments will be described in detail. For example... Figure 5As shown, in high-concurrency scenarios, before forwarding behavioral feature information, the first request receiving module rate-limits the first request using a token bucket model. For the behavioral feature information to be forwarded, it first determines the number of tokens required to send the behavioral feature information, and then checks whether the number of tokens in the current token bucket is greater than or equal to the required number of tokens. If the number of tokens in the current token bucket is greater than or equal to the required number of tokens, it means that there are enough tokens in the bucket to forward the data, i.e., a token has been obtained, and the behavioral feature information is directly sent to the message middleware or the first operation processing module. If the number of tokens in the current token bucket is less than the required number of tokens, it means that there are not enough tokens in the bucket to forward the data, i.e., a token cannot be obtained, and the behavioral feature information is cached in the second preset cache area. Subsequently, the first request receiving module can read a preset number of behavioral feature information from the second preset cache area according to the second preset time interval, and send the preset number of behavioral feature information to the message middleware or the first operation processing module. Whether the behavioral feature information is sent to the message middleware or the first operation processing module can be determined by combining the category corresponding to the behavioral feature information described in the above embodiment, which will not be elaborated here.
[0144] In the above embodiments, when the concurrency of the first request exceeds the acceptable range, the token bucket model is used to forward the behavioral feature information. In this way, the availability of the service can be guaranteed, so as to prevent the system from being paralyzed due to excessive pressure on the server caused by unexpected requests.
[0145] In step S205, under either asynchronous or synchronous processing mode, if it is determined that the first operation execution state has been entered, a transaction message corresponding to the first operation is generated.
[0146] In step S207, a transaction message is sent to the message middleware.
[0147] In step S209, a first operation is performed based on the behavioral characteristic information, and the execution result of the first operation is determined.
[0148] In step S211, based on the execution result, a first request response is sent to the client, and a rollback message or an execution success message is sent to the message middleware; the rollback message is used to instruct the message middleware to delete the transaction message, and the execution success message is used to instruct the message middleware to push the behavior feature information to the behavior feature information recording module.
[0149] In this embodiment of the disclosure, such as Figure 3As shown, the above steps S205 to S209 are executed by the first operation processing module; that is, if the first operation processing module determines that it has entered the first operation execution state, on the one hand, it generates a transaction message corresponding to the first operation and sends the transaction message to the message middleware; on the other hand, it also executes the first operation according to the behavioral feature information and determines the execution result of the first operation; wherein, the transaction message is used to indicate that the behavioral feature information is recorded.
[0150] It should be noted that, in the asynchronous processing mode, the execution order of the above steps 205 to S211 is as follows: the first request receiving module directly sends the first request response to the client; after determining that it has entered the first operation execution state, the first operation processing module executes steps S205 to S209 and S211, which involve sending a rollback message or an execution success message to the message middleware.
[0151] The first operation processing module will synchronize the execution result to the first request receiving module, so that the first request receiving module can send the first request response to the client.
[0152] In the application scenario disclosed herein, executing the first operation and recording the corresponding behavioral characteristic information constitute a transaction. Both actions must be completed for the transaction to be considered complete; that is, either both operations succeed, or if one fails, the transaction must be rolled back to its state before it began. This ensures data consistency, guaranteeing that actual operations correspond to records. Specifically, it avoids situations where the client's user account behavioral characteristic values increase or decrease without the server recording the corresponding information, or vice versa.
[0153] In this embodiment of the disclosure, after determining that it has entered the first operation execution state, the first operation processing module directly executes the corresponding first operation, such as calling the database to deduct the behavior feature value of the request initiator's account from the user account behavior feature value information table; and records the behavior feature information corresponding to the first operation in an asynchronous processing manner. In this way, compared with the method of synchronously recording the behavior feature information corresponding to the first operation, in a high-concurrency environment, it can avoid the situation where data is blocked due to insufficient synchronous processing, thereby alleviating the pressure on the server.
[0154] Therefore, in this embodiment of the disclosure, in order to achieve the purpose of asynchronously recording behavioral feature information, if the first operation processing module determines that it is entering the first operation execution state, in addition to executing the first operation according to the behavioral feature information, it also generates a transaction message corresponding to the first operation and sends the transaction message to the message middleware. Through the transaction management function of the message middleware, the asynchronous recording of the behavioral feature information corresponding to the first operation is achieved. The message middleware can be RocketMQ. Through the transaction management function provided by RocketMQ, it can be guaranteed that the above-mentioned transaction operation and message sending either both succeed or both fail, thereby ensuring eventual data consistency.
[0155] Under normal circumstances, such as Figure 6 As shown, before executing the first operation, the first operation processing module sends a transaction message to the message middleware. This transaction message is equivalent to a half-message or pre-message, meaning it is invisible to the subscribers of the message middleware. In this scenario, the subscribers include the service module that records behavioral feature information. After successfully sending the transaction message (i.e., receiving the response message from the message middleware), the first operation processing module executes the first operation. If the first operation processing module successfully executes the first operation, it submits an execution success message to the message middleware. Based on the submitted execution success message, the message middleware transforms the half-message into a full message and pushes the transaction message recording behavioral feature information to the subscribers, thus completing the asynchronous recording of behavioral feature information. Alternatively, as... Figure 7 As shown, if the first operation processing module fails to execute the first operation, it sends a rollback message to the message middleware. The message middleware deletes the transaction message based on the rollback message, and the subscriber will not know that this transaction message exists.
[0156] In practical applications, network fluctuations or network outages may occur in the first operation processing module, causing the rollback message and execution success message to fail to be sent. In this case, the message middleware uses a transaction reverse lookup mechanism to reverse look up the transaction processing results of the first message processing module.
[0157] Accordingly, in one possible embodiment, after sending the transaction message to the message middleware in step S207 above, the data processing method of this embodiment further includes the following steps:
[0158] In step S2081, a callback message sent by the message middleware is received; the callback message is generated by the message middleware when it does not receive a rollback message and an execution success message within a preset time after receiving the transaction message.
[0159] In step S2083, in response to the query message, the execution result of the first operation is queried.
[0160] In step S2085, when the execution result indicates that the first operation was executed successfully, an execution success message is sent to the message middleware; or, when the execution result indicates that the first operation failed, a rollback message is sent to the message middleware.
[0161] Specifically, such as Figure 8 As shown, the message middleware starts timing when it receives a transaction message. If it does not receive a rollback message and an execution success message from the first operation processing module within a preset time, it sends a lookup message to the first message processing module. The first message processing module uses the lookup message to check the local transaction status, i.e., to query the execution result of the first operation. When the execution result indicates that the first operation was executed successfully, the first message processing module sends an execution success message to the message middleware. When the execution result indicates that the first operation failed, the first message processing module sends a rollback message to the message middleware.
[0162] In the above embodiments, the transaction reverse lookup mechanism of the message middleware is used to solve the problem that the first operation processing module fails to submit messages under network anomalies such as network fluctuations, thus ensuring the eventual consistency of data.
[0163] In this embodiment of the disclosure, after the first request receiving module determines which processing method to use for the first request, the judgment conditions for the first operation processing module to enter the first operation execution state are different under different processing methods.
[0164] For ease of explanation and understanding, the following will be combined with Figure 9 and Figure 10 Further explanation is needed.
[0165] In one possible implementation, such as Figure 9 As shown, after determining that the first request belongs to the second category and adopting an asynchronous processing method, the first request receiving module first sends the behavioral feature information to the message middleware. After receiving the feedback message from the message middleware indicating that the operation was successful, the first request receiving module directly sends the first request response to the client. Subsequently, the message middleware pushes the behavioral feature information to the first operation processing module for processing.
[0166] In this scenario, after receiving the behavioral feature information, the first operation processing module does not directly process the behavioral feature information, because processing each behavioral feature information requires calling the database to perform corresponding database operations, and the execution of database operations consumes a lot of processor resources. Therefore, the first operation processing module adopts a batch processing method for the behavioral feature information obtained in the asynchronous processing mode; that is, the first operation processing module first stores the received behavioral feature information to be processed in the first preset cache area, and then retrieves a preset number of behavioral feature information to be processed from the first preset cache area every first preset time interval for batch processing.
[0167] Therefore, correspondingly, the first operation processing module determining to enter the first operation execution state in the above step S205 may include: the first operation processing module determining to enter the first operation execution state when it obtains a set of behavioral feature information to be processed from the first preset cache area according to the first preset time interval; wherein, the set of behavioral feature information includes a preset number of behavioral feature information.
[0168] Understandably, the transaction message generated by the first operation processing module during the batch processing of multiple behavioral feature information is used to instruct the recording of these multiple behavioral feature information.
[0169] Another possible embodiment, such as Figure 10 As shown, after determining that the category of the first request is the first category and adopting the synchronous processing method, the first request receiving module directly sends the behavioral feature information to the first operation processing module for processing. Based on the processing result of the first operation processing module, the first request receiving module sends the first request response to the client when the processing result indicates that the operation is successful.
[0170] Therefore, the first operation processing module determining to enter the first operation execution state in step S205 above may include: when the first operation processing module receives the behavioral feature information sent by the first request receiving module, it determines to enter the first operation execution state.
[0171] In the above embodiments, the first operation processing module, as the main service module of the server, can improve the response latency of the client's first request by adopting a combination of synchronous and asynchronous processing methods when faced with a large number of first requests.
[0172] Furthermore, in the above possible embodiments, both the first request for the first category and the first request for the second category are processed by the first operation processing module. To further optimize the processing efficiency of the first operation processing module, in a further embodiment of this disclosure, the first operation processing module can be used only to process the first request for the first category. For the first request for the second category, other independent service modules, such as the second operation processing module, can be used to process the first request for the second category. Thus, by assigning the first requests of different categories to different operation processing modules for processing, and with each operation processing module being independent of the others, the corresponding operation processing module adopts a synchronous processing method for the first request of important categories, and an asynchronous processing method for the first request of secondary categories. In this way, the processing resources are reasonably allocated, which can improve the availability and stability of the overall service of the server.
[0173] In this embodiment of the disclosure, the behavioral feature information includes a first account identifier and a behavioral feature value; wherein, the first account identifier may include a first account identifier, and the behavioral feature value is the corresponding feature value generated when the first account performs a behavior.
[0174] In one possible embodiment, if the first request is of the first category, the first operation performed in step S209 above based on the behavioral feature information may include: processing the information corresponding to the first account identifier in the local database based on the first account identifier and the behavioral feature value.
[0175] Specifically, the first operation processing module directly calls the behavior feature information record table corresponding to the first account identifier in the behavior feature information corresponding to the first request in the local database, and then performs a deduction operation on the behavior feature information record table according to the behavior feature value.
[0176] In another possible embodiment, when the first request is of the second category, before performing the first operation based on the behavioral characteristic information, the data processing method of this disclosure embodiment may further include the following steps:
[0177] In step S2090, the set of behavioral feature information to be processed is divided into multiple behavioral feature information subsets; multiple behavioral feature information subsets correspond to multiple different account identifiers; each behavioral feature information in each behavioral feature information subset corresponds to the same account identifier;
[0178] In step S2092, the total behavioral feature value corresponding to each subset of behavioral feature information is determined;
[0179] Correspondingly, the above-mentioned execution of the first operation based on behavioral characteristic information may include:
[0180] In step S2094, the information corresponding to the first account identifier in the local database is processed according to the first account identifier and the total behavioral feature value corresponding to the first account identifier.
[0181] Specifically, based on the previous embodiments, the first operation processing module adopts a batch processing method for the first request of the second category; however, even with the batch processing method, the synchronous update of different account information will generate a large number of row locks and deadlock detections, which will lead to a sharp decline in the performance of the local database.
[0182] Therefore, during the first operation processing module's execution of the first operation, when batch processing the first requests of the second category, preprocessing steps S2090 to S2092 can also be performed on the set of behavioral feature information to be processed; for example, the set of behavioral feature information to be processed includes behavioral feature information 1 (userid: 1001, coin: 10), behavioral feature information 2 (userid: 1002, coin: 12), behavioral feature information 3 (userid: 1001, coin: 10), behavioral feature information 4 (userid: 1002, coin: 22)..., each behavioral feature information carrying the corresponding account identifier and Behavioral feature values: Based on the account identifiers corresponding to each behavioral feature, two subsets of behavioral feature information can be obtained. The first subset includes behavioral feature information 1 and behavioral feature information 3, corresponding to account identifier 1001, with a total behavioral feature value of 20. The second subset includes behavioral feature information 2 and behavioral feature information 4, corresponding to account identifier 1002, with a total behavioral feature value of 34. After determining the total behavioral feature value for each subset, for each account identifier, only the behavioral feature information record table corresponding to each account identifier needs to be read once, and all deduction operations can be performed at once. This avoids multiple repeated database operations on the same account, improving database performance.
[0183] In the existing scenario, if the client does not receive a response from the server within a certain period after sending the first request, the client will automatically initiate a retry of the first request. In related technologies, the server obtains a behavioral feature identifier for each received first request and first request retry. This means that the first request retry and the original first request confirmation are two separate first operations. That is, the server will also execute the corresponding operation logic for the first request retry. As a result, there will be situations where the user only performs the relevant behavior once, but the client performs the operation two or more times.
[0184] Based on this, the embodiments of this disclosure implement the idempotency of the request chain to ensure that multiple operations will not occur when the client initiates a first request retry.
[0185] In one possible embodiment, the first request includes an idempotency identifier; the idempotency identifier is generated by the client; the behavioral feature information includes a behavioral feature identifier;
[0186] Accordingly, step S201 above, in response to the first request sent by the client, determines the behavioral feature information corresponding to the first request, which may include: in response to the first request sent by the client, obtaining the corresponding behavioral feature identifier based on the idempotency identifier carried in the first request.
[0187] The first request mentioned above includes a first request retry, which is automatically generated when the client does not receive a response from the server within a preset time. The first request retry is generated based on the parameters of the first first request, that is, the idempotency identifier carried in the first request retry is the same as the idempotency identifier carried in the first first request. The server-side first request receiving module obtains the corresponding behavior feature identifier according to the idempotency identifier carried in the first request. In this way, the uniqueness of the behavior feature identifier is guaranteed by the uniqueness of the idempotency identifier, thereby realizing the idempotency of the request chain and solving the problem of the backend server performing repeated operations for a single client action.
[0188] In one possible embodiment, obtaining the corresponding behavioral feature identifier based on the idempotency identifier carried in the first request may include the following steps:
[0189] Obtain the mapping relationship between idempotent identifiers and behavioral feature identifiers; the mapping relationship includes multiple idempotent identifiers and multiple behavioral feature identifiers, with a one-to-one correspondence between the multiple idempotent identifiers and the multiple behavioral feature identifiers;
[0190] If it is determined that the idempotent identifier carried in the first request exists among multiple idempotent identifiers, then the corresponding behavioral feature identifier is determined from the mapping relationship; or, if it is determined that the idempotent identifier carried in the first request does not exist among multiple idempotent identifiers, then the corresponding behavioral feature identifier is generated by the behavioral feature identifier generation module.
[0191] The server-side first request receiving module stores a mapping relationship between idempotency identifiers and behavioral feature identifiers. When receiving a first request (including a first request retry) from a client, it first determines whether the idempotency identifier it carries exists. Generally, if the idempotency identifier carried in the first request does not exist, the first request receiving module obtains the corresponding behavioral feature identifier for it and saves the mapping relationship between the idempotency identifier and the corresponding behavioral feature identifier. However, if the idempotency identifier carried in the first request retry is determined to exist, then the corresponding behavioral feature identifier can be retrieved from the stored mapping relationship between idempotency identifiers and behavioral feature identifiers.
[0192] The above embodiments will be further explained below with reference to specific application scenarios.
[0193] like Figure 11 As shown, when the client sends the first request, assuming the idempotency identifier carried by the first request is key1, the server executes the following steps: The first request receiving module responds to the first request, obtains a behavior feature identifier 10001, and then writes the correspondence between the idempotency identifier key1 and the behavior feature identifier 10001 to the Redis database using the SETNX command; the writing format can be key-value format, such as {key: key1, value: 10001}; after the Redis database reports that the SETNX command was executed successfully, the first request receiving module sends the behavior feature information carrying the behavior feature identifier 10001 to other service modules for subsequent processing, such as sending it to the first operation processing module to execute the first operation; under normal circumstances, the first request receiving module will send the first request response back to the client. If the client does not receive the first request response within a preset time after sending the first request, it will initiate a retry of the first request;
[0194] like Figure 12As shown, when the client sends a first request retry, the first request retry carries the same idempotent identifier key1 as the first request. The server executes the following steps: The first request receiving module responds to the first request retry by obtaining a behavior feature identifier 10002; here, the first request receiving module will re-obtain a behavior feature identifier for each first request or first request retry; at this time, when the first request receiving module writes the mapping relationship between the idempotent identifier key1 and the behavior feature identifier 10002 to the Redis database using the SETNX command, it will receive a SETNX command execution failure instruction returned by the Redis database, because the mapping relationship between key1 and 10001 already exists in the Redis database; at this time, the first request receiving module obtains the behavior feature identifier 10001 corresponding to key1 using the GET{key} command, and then the first request receiving module sends the behavior feature information carrying the behavior feature identifier 10001 to other service modules for subsequent processing.
[0195] In the above embodiments, before forwarding the behavior feature information, the first request receiving module assigns a corresponding behavior feature identifier to the behavior feature information to be forwarded based on the idempotent identifier carried in the first request. Due to the uniqueness of the idempotent identifier, it can be guaranteed that the behavior feature identifier assigned to the first request retry is the same as that assigned to the first request in the first instance, so that the subsequent service modules will not repeat the first operation.
[0196] Furthermore, when a user on the client performs an action on a specified page, triggering the generation of the first request, an idempotent identifier corresponding to that action is generated synchronously. This idempotent identifier is sent to the first request receiving module on the server along with the first request. In one possible embodiment, the idempotent identifier can be generated on the client, or it can be generated in a specified service module on the server and returned to the client, or it can be generated on the specified server. One method of generating the idempotent identifier includes using the MD5 algorithm to generate the idempotent identifier based on the first account identifier and the timestamp of the user performing the action.
[0197] In one possible embodiment, the above-mentioned generation of the corresponding behavioral feature identifier by the behavioral feature identifier generation module may include the following steps:
[0198] The legitimacy of the first account corresponding to the first request is determined by the behavior feature identification generation module; the legitimacy includes the frequency of the first account's behavior and / or risk level; the frequency of behavior represents the number of times the first account initiates the first request within a preset time period; the risk level is determined according to preset judgment rules.
[0199] Once the first account is determined to be legitimate, the behavior feature generation module generates the corresponding behavior feature identifier.
[0200] In related technologies, the verification of the legitimacy of the first account is performed in the first operation processing module. That is, the first operation processing module verifies the legitimacy of the first account only after receiving the behavioral feature information. If the account is invalid, the first operation is not executed. In this embodiment, the verification of the legitimacy of the first account is placed before the generation of the behavioral feature identifier. That is, the behavioral feature identifier generation module generates the corresponding behavioral feature identifier only when the first account is determined to be legitimate, and then the first operation processing module processes the behavioral feature information. The first account can be either the first account itself or the account used to receive gifts. This avoids unnecessary waste of resources. Furthermore, the behavioral feature identifier generation module and the first operation processing module are two independent service modules. By allocating resources reasonably, the first operation processing module only needs to execute the corresponding first operation, which reduces the burden on the first operation processing module. Moreover, when the first operation processing module executes any first operation, the behavioral feature identifier generation module can simultaneously verify the legitimacy of the first account corresponding to other first requests, thereby improving the server's ability to process data in parallel.
[0201] In summary, the embodiments of this disclosure optimize the server-side data processing method, including adopting different processing methods for different types of first requests during the reception of the client's first request to improve the ability to process data in parallel; and implementing idempotency during the preprocessing of the first request to ensure eventual data consistency and solve the problem of repetitive operations; and recording behavioral characteristic information asynchronously through transaction messages during the execution of the first operation corresponding to the first request to improve user response speed. Furthermore, the optimized core service module of the server—the first operation processing module—only performs a locking action when executing the first operation. Compared to related technologies that require multiple locking and unlocking operations, this disclosure can significantly reduce the granularity of the lock. Through the data processing method provided by the above embodiments of this disclosure, the server can maintain high stability and high availability when facing sudden surges in requests.
[0202] Figure 13 This is a block diagram of a data processing apparatus according to an exemplary embodiment. (Refer to...) Figure 13 The device includes a first request receiving module and a first operation processing module;
[0203] The first request receiving module 1301 is configured to execute a response to a first request sent by the client and determine the behavioral feature information corresponding to the first request.
[0204] The first request receiving module 1301 is further configured to determine the processing method for the first request based on behavioral characteristic information; the processing method includes asynchronous processing or synchronous processing.
[0205] The first operation processing module 1302 is configured to execute in asynchronous or synchronous processing mode. If it is determined to enter the first operation execution state, it generates a transaction message corresponding to the first operation.
[0206] The first operation processing module 1302 is also configured to send transaction messages to the message middleware;
[0207] The first operation processing module 1302 is also configured to perform a first operation based on behavioral feature information and determine the execution result of the first operation;
[0208] The first operation processing module 1302 is also configured to send a first request response to the client based on the execution result, and send a rollback message or an execution success message to the message middleware; the rollback message is used to instruct the message middleware to delete the transaction message, and the execution success message is used to instruct the message middleware to push the behavior feature information to the behavior feature information recording module.
[0209] In one possible embodiment, the first request receiving module 1301 includes:
[0210] The first determining submodule is configured to determine the category of the first request based on behavioral characteristic information;
[0211] The second determining submodule is configured to determine how to handle the first request based on the category of the first request.
[0212] In one possible embodiment, the second determining submodule is configured to determine, when the category of the first request is a first category, the processing method for the first request is synchronous processing.
[0213] The third determining module is configured to determine to enter the first operation execution state when it receives behavioral feature information sent by the first request receiving module 1301.
[0214] In one possible embodiment, the behavioral characteristic information includes a first account identifier and behavioral characteristic values;
[0215] The first operation processing module 1302 is configured to process the information corresponding to the first account identifier in the local database based on the first account identifier and the behavior feature value.
[0216] In one possible embodiment, the second determining submodule is configured to determine, when the category of the first request is the second category, the processing method for the first request is asynchronous processing.
[0217] The first operation processing module 1302 is configured to determine to enter the first operation execution state when it obtains a set of behavioral feature information to be processed from the first preset cache area according to the first preset time interval; wherein the set of behavioral feature information includes a preset number of behavioral feature information.
[0218] In one possible embodiment, the behavioral feature information includes a first account identifier and behavioral feature values; the apparatus further includes:
[0219] The first operation processing module 1302 is configured to divide the set of behavioral feature information to be processed into multiple behavioral feature information subsets; the multiple behavioral feature information subsets correspond to multiple different account identifiers; each behavioral feature information in each behavioral feature information subset corresponds to the same account identifier; and determine the total behavioral feature value corresponding to each behavioral feature information subset.
[0220] The first operation processing module 1302 is configured to process the information corresponding to the first account identifier in the local database based on the first account identifier and the total characteristic value of the behavior corresponding to the first account identifier.
[0221] In one possible embodiment, the device further includes:
[0222] The first operation processing module 1302 is configured to execute a callback message sent by the message receiving middleware. The callback message is generated by the message middleware when it does not receive a rollback message or an execution success message within a preset time after receiving the transaction message.
[0223] The first operation processing module 1302 is configured to respond to the callback message and query the execution result of the first operation;
[0224] The first operation processing module 1302 is configured to send an execution success message to the message middleware when the execution result indicates that the first operation was executed successfully; or to send a rollback message to the message middleware when the execution result indicates that the first operation failed.
[0225] In one possible embodiment, the first request receiving module 1301 is configured to execute a token bucket model to send behavioral feature information to the message middleware or the first operation processing module 1302.
[0226] In one possible embodiment, the first request receiving module 1301 is configured to: determine the number of tokens required to send behavioral feature information; if the number of tokens in the current token bucket is greater than or equal to the required number of tokens, send the behavioral feature information to the message middleware; or; if the number of tokens in the current token bucket is less than the required number of tokens, cache the behavioral feature information in a second preset cache area; read a preset number of behavioral feature information from the second preset cache area according to a second preset time interval, and send the preset number of behavioral feature information to the message middleware.
[0227] In one possible embodiment, the first request includes an idempotency identifier; the idempotency identifier is generated by the client; the behavioral feature information includes a behavioral feature identifier;
[0228] The first request receiving module 1301 is configured to execute a response to a first request sent by the client and obtain the corresponding behavioral feature identifier based on the idempotency identifier carried in the first request.
[0229] In one possible embodiment, the first request receiving module 1301 is configured to perform an operation to obtain a mapping relationship between idempotent identifiers and behavioral feature identifiers; the mapping relationship includes multiple idempotent identifiers and multiple behavioral feature identifiers, with each idempotent identifier and behavioral feature identifier corresponding one-to-one; if it is determined that the idempotent identifier carried in the first request exists among the multiple idempotent identifiers, then the corresponding behavioral feature identifier is determined from the mapping relationship; or; if it is determined that the idempotent identifier carried in the first request does not exist among the multiple idempotent identifiers, then the corresponding behavioral feature identifier is generated by the behavioral feature identifier generation module.
[0230] In one possible embodiment, a behavior feature identification generation module is also included;
[0231] The behavior feature identifier generation module is configured to determine the legitimacy of the first account corresponding to the first request; the legitimacy includes the frequency of the first account's behavior operations and / or risk level; the frequency of behavior operations represents the number of times the first account initiates the first request within a preset time; the risk level is determined according to preset judgment rules; if the first account is determined to be legitimate, the corresponding behavior feature identifier is generated.
[0232] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0233] Figure 14 This is a block diagram illustrating an electronic device for data processing according to an exemplary embodiment.
[0234] This electronic device can be a server or a terminal device, and its internal structure diagram can be as follows: Figure 14As shown, this electronic device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements a data processing method.
[0235] Those skilled in the art will understand that Figure 14 The structure shown is merely a block diagram of a portion of the structure related to the present disclosure and does not constitute a limitation on the electronic device to which the present disclosure is applied. A specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0236] In an exemplary embodiment, an electronic device is also provided, including: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the data processing method as described in the embodiments of this disclosure.
[0237] In an exemplary embodiment, a computer-readable storage medium is also provided, which, when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the data processing method of the present disclosure embodiments.
[0238] In an exemplary embodiment, a computer program product is also provided, comprising a computer program stored in a readable storage medium, wherein at least one processor of a computer device reads from the readable storage medium and executes the computer program, causing the computer device to perform the data processing method of the present disclosure embodiments.
[0239] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0240] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0241] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A data processing method, characterized in that, include: In response to the first request sent by the client, determine the behavioral characteristic information corresponding to the first request; The behavioral characteristic information includes a first account identifier and behavioral characteristic values; The category of the first request is determined based on the behavioral feature information, and the processing method for the first request is determined based on the category of the first request. The processing method includes asynchronous processing or synchronous processing; When the category of the first request is the second category, the processing method for the first request is determined to be the asynchronous processing method. When the set of behavioral feature information to be processed is obtained from the first preset cache area according to the first preset time interval, the behavioral feature values in the set of behavioral feature information to be processed are aggregated according to the account identifier to obtain the total behavioral feature value. In either the asynchronous or synchronous processing mode, if it is determined that the first operation execution state is entered, a transaction message corresponding to the first operation is generated. Send the transaction message to the message broker; The first operation is performed based on the behavioral characteristic information, and the execution result of the first operation is determined; Based on the execution result, a first request response is sent to the client, and a rollback message or an execution success message is sent to the message middleware; the rollback message is used to instruct the message middleware to delete the transaction message, and the execution success message is used to instruct the message middleware to push the behavior feature information to the behavior feature information recording module.
2. The data processing method according to claim 1, characterized in that, The step of determining the processing method for the first request based on its category includes: When the category of the first request is the first category, the processing method for the first request is determined to be the synchronous processing method; The determination to enter the first operation execution state includes: Upon receiving the behavioral characteristic information sent by the first request receiving module, it is determined to enter the first operation execution state.
3. The data processing method according to claim 2, characterized in that, The step of performing the first operation based on the behavioral feature information includes: Based on the first account identifier and the behavioral feature value, the information corresponding to the first account identifier in the local database is processed.
4. The data processing method according to claim 1, characterized in that, The determination to enter the first operation execution state includes: When a set of behavioral feature information to be processed is obtained from a first preset cache area according to a first preset time interval, it is determined to enter the first operation execution state; wherein, the set of behavioral feature information includes a preset number of behavioral feature information.
5. The data processing method according to claim 1 or 4, characterized in that, The behavioral feature values in the set of behavioral feature information to be processed are aggregated according to the first account identifier to obtain the total behavioral feature value, including: The set of behavioral feature information to be processed is divided into multiple behavioral feature information subsets; each of the multiple behavioral feature information subsets corresponds to a different account identifier; and each behavioral feature information in each behavioral feature information subset corresponds to the same account identifier. Determine the total behavioral feature value corresponding to each subset of behavioral feature information; The step of performing the first operation based on the behavioral feature information includes: Based on the first account identifier and the total behavioral feature value corresponding to the first account identifier, the information corresponding to the first account identifier in the local database is processed.
6. The data processing method according to claim 1, characterized in that, After sending the transaction message to the message middleware, the method further includes: Receive a callback message sent by the message middleware; the callback message is generated by the message middleware when it has not received the rollback message and the execution success message within a preset time after receiving the transaction message; In response to the query message, query the execution result of the first operation; When the execution result indicates that the first operation was executed successfully, the execution success message is sent to the message middleware; or, when the execution result indicates that the first operation failed, the rollback message is sent to the message middleware.
7. The data processing method according to claim 1, characterized in that, After determining the processing method for the first request based on the behavioral feature information, the method further includes: Based on the token bucket model, the behavioral feature information is sent to the message middleware or the first operation processing module.
8. The data processing method according to claim 7, characterized in that, The step of sending the behavioral feature information to the message middleware or the first operation processing module based on the token bucket model includes: Determine the number of tokens required to send the behavioral characteristic information; If the number of tokens in the current token bucket is greater than or equal to the required number of tokens, the behavior feature information is sent to the message middleware or the first operation processing module; or, if the number of tokens in the current token bucket is less than the required number of tokens, the behavior feature information is cached in a second preset cache area; a preset number of behavior feature information is read from the second preset cache area according to a second preset time interval, and the preset number of behavior feature information is sent to the message middleware or the first operation processing module.
9. The data processing method according to claim 1, characterized in that, The first request includes an idempotency identifier; the idempotency identifier is generated by the client; the behavioral feature information includes a behavioral feature identifier; The step of responding to a first request sent by the client and determining the behavioral characteristic information corresponding to the first request includes: In response to the first request sent by the client, the corresponding behavioral feature identifier is obtained based on the idempotency identifier carried in the first request.
10. The data processing method according to claim 9, characterized in that, The step of obtaining the corresponding behavioral feature identifier based on the idempotency identifier carried in the first request includes: Obtain the mapping relationship between idempotent identifiers and behavioral feature identifiers; the mapping relationship includes multiple idempotent identifiers and multiple behavioral feature identifiers, and the multiple idempotent identifiers and the multiple behavioral feature identifiers correspond one-to-one; If it is determined that the idempotent identifier carried in the first request exists among the plurality of idempotent identifiers, then the corresponding behavioral feature identifier is determined from the mapping relationship; or, if it is determined that the idempotent identifier carried in the first request does not exist among the plurality of idempotent identifiers, then the corresponding behavioral feature identifier is generated by the behavioral feature identifier generation module.
11. The data processing method according to claim 10, characterized in that, The generation of corresponding behavioral feature identifiers through the behavioral feature identifier generation module includes: The legitimacy of the first account corresponding to the first request is determined by the behavior feature identification generation module; the legitimacy includes the behavior operation frequency and / or risk level of the first account; the behavior operation frequency represents the number of times the first account initiates the first request within a preset time period; the risk level is determined according to preset judgment rules. If the first account is determined to be legitimate, the behavior feature generation module generates a corresponding behavior feature identifier.
12. A data processing apparatus, characterized in that, include: The first request receiving module is configured to execute a response to a first request sent by the client and determine the behavioral feature information corresponding to the first request. The behavioral characteristic information includes a first account identifier and behavioral characteristic values; The first request receiving module is further configured to determine the category of the first request based on the behavioral feature information, and determine the processing method for the first request based on the category of the first request; the processing method includes an asynchronous processing method or a synchronous processing method. The first operation processing module is configured to determine the processing method for the first request as the asynchronous processing method when the category of the first request is the second category, and when obtaining the set of behavioral feature information to be processed from the first preset cache area according to the first preset time interval, aggregate the behavioral feature values in the set of behavioral feature information to be processed according to the first account identifier to obtain the total behavioral feature value. The first operation processing module is also configured to, under the asynchronous processing mode or the synchronous processing mode, generate a transaction message corresponding to the first operation if it is determined to enter the first operation execution state; The first operation processing module is also configured to send the transaction message to the message middleware; The first operation processing module is further configured to perform the first operation based on the behavioral feature information and determine the execution result of the first operation; The first operation processing module is further configured to send a first request response to the client based on the execution result, and send a rollback message or an execution success message to the message middleware; the rollback message is used to instruct the message middleware to delete the transaction message, and the execution success message is used to instruct the message middleware to push the behavior feature information to the behavior feature information recording module.
13. The data processing apparatus according to claim 12, characterized in that, The first request receiving module is also configured to execute: When the category of the first request is the first category, the processing method for the first request is determined to be the synchronous processing method; The first operation processing module is further configured to determine to enter the first operation execution state when it receives behavioral feature information sent by the first request receiving module.
14. The data processing apparatus according to claim 13, characterized in that, The first operation processing module is further configured to process the information corresponding to the first account identifier in the local database based on the first account identifier and the behavioral feature value.
15. The data processing apparatus according to claim 12, characterized in that, The first operation processing module is further configured to determine to enter the first operation execution state when it obtains a set of behavioral feature information to be processed from a first preset cache area according to a first preset time interval; wherein the set of behavioral feature information includes a preset number of behavioral feature information.
16. The data processing apparatus according to claim 15, characterized in that, The first operation processing module is also configured to execute: The set of behavioral feature information to be processed is divided into multiple behavioral feature information subsets; each subset of behavioral feature information corresponds to a different account identifier; each behavioral feature information in each subset of behavioral feature information corresponds to the same account identifier; the total behavioral feature value corresponding to each subset of behavioral feature information is determined. The first operation processing module is configured to process the information corresponding to the first account identifier in the local database based on the first account identifier and the total behavioral feature value corresponding to the first account identifier.
17. The data processing apparatus according to claim 12, characterized in that, The first operation processing module is further configured to receive a callback message sent by the message middleware; the callback message is generated by the message middleware when it does not receive the rollback message and the execution success message within a preset time after receiving the transaction message; The first operation processing module is further configured to respond to the query message and query the execution result of the first operation; The first operation processing module is further configured to send the execution success message to the message middleware when the execution result indicates that the first operation was executed successfully; or to send the rollback message to the message middleware when the execution result indicates that the first operation failed.
18. The data processing apparatus according to claim 15, characterized in that, The first request receiving module is further configured to execute a token bucket model-based method to send the behavioral feature information to the message middleware or the first operation processing module.
19. The data processing apparatus according to claim 18, characterized in that, The first request receiving module is further configured to determine the number of tokens required to send the behavior feature information; if the number of tokens in the current token bucket is greater than or equal to the required number of tokens, send the behavior feature information to the message middleware; or; if the number of tokens in the current token bucket is less than the required number of tokens, cache the behavior feature information in a second preset cache area. According to the second preset time interval, a preset number of behavioral feature information is read from the second preset cache area, and the preset number of behavioral feature information is sent to the message middleware.
20. The data processing apparatus according to claim 12, characterized in that, The first request includes an idempotency identifier; the idempotency identifier is generated by the client; the behavioral feature information includes a behavioral feature identifier; The first request receiving module is further configured to execute a response to a first request sent by the client and obtain a corresponding behavioral feature identifier based on the idempotency identifier carried in the first request.
21. The data processing apparatus according to claim 20, characterized in that, The first request receiving module is further configured to perform an operation to obtain a mapping relationship between idempotent identifiers and behavioral feature identifiers; the mapping relationship includes multiple idempotent identifiers and multiple behavioral feature identifiers, with each of the multiple idempotent identifiers corresponding to one another; if it is determined that the idempotent identifier carried in the first request exists among the multiple idempotent identifiers, then the corresponding behavioral feature identifier is determined from the mapping relationship; or; if it is determined that the idempotent identifier carried in the first request does not exist among the multiple idempotent identifiers, then the corresponding behavioral feature identifier is generated by the behavioral feature identifier generation module.
22. The data processing apparatus according to claim 21, characterized in that, It also includes the behavior feature identifier generation module; The behavior feature identifier generation module is configured to determine the legitimacy of the first account corresponding to the first request; the legitimacy includes the behavior operation frequency and / or risk level of the first account; the behavior operation frequency represents the number of times the first account initiates the first request within a preset time; the risk level is determined according to a preset judgment rule; and if the first account is determined to be legitimate, a corresponding behavior feature identifier is generated.
23. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the data processing method as described in any one of claims 1 to 11.
24. A computer-readable storage medium, characterized in that, When the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device is enabled to perform the data processing method as described in any one of claims 1 to 11.
25. A computer program product, characterized in that, The computer program product includes a computer program stored in a readable storage medium, wherein at least one processor of a computer device reads from the readable storage medium and executes the computer program, causing the computer device to perform the data processing method as described in any one of claims 1 to 11.
Citation Information
Patent Citations
A device and method for processing database transactions
CN102279855A
Transaction and message consistency implementation method and device, equipment and storage medium
CN113971075A