Data processing method, server and storage medium
By using service information lists and allocation rules in the service cluster to determine the executors, and using sorting and prompt information to coordinate the processing order, the problem of determining processing services in a multi-service environment is solved, and the processing efficiency and performance of the service cluster are improved.
Patent Information
- Application Number
- CN202211607484.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-14
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2042-12-14
AI Technical Summary
In a high availability scenario, when multiple services are running simultaneously, it is difficult to effectively determine the only service to handle the information to be processed.
Through the pre-stored service information list and allocation rules, the executor of the information to be processed is determined from the service cluster, and the sequence of preparers is established using sorting rules. Completion prompt information is sent to coordinate the processing order between services, and the service information list is updated in time to adapt to address changes.
It achieves the effective determination of processing services from multiple services, improves the overall performance and coordination capabilities of the service cluster, and ensures that the information to be processed is processed in a timely manner.
Smart Images

Figure CN115988060B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data processing method, a server, and a storage medium. Background Art
[0002] In a high-availability scenario, multiple services with the same content are often deployed and run simultaneously.
[0003] In the related art, when multiple services are running at the same time, since the functions of each service are usually the same, when each service receives information to be processed at the same time, such as a message or a task, often only a single service is required to process the information to be processed. That is, in the related art, it is necessary to effectively determine a service from multiple services to process the information to be processed. Summary of the Invention
[0004] The embodiments of the present application provide a data processing method, a server, and a storage medium, which aim to solve the problem in related technologies of effectively determining a service that processes information to be processed from multiple services.
[0005] In a first aspect, an embodiment of the present application provides a data processing method, the method comprising:
[0006] When the target service receives the information to be processed, it determines the executor of the information to be processed from the service cluster where the target service is located according to the pre-stored service information list and the pre-determined allocation rules;
[0007] If the target service is an executor, the pending information is processed.
[0008] In some embodiments, after determining the executor of the information to be processed, the method further includes:
[0009] According to a predetermined sorting rule, a preparer sequence of information to be processed is determined, wherein preparers in the preparer sequence are services in the service cluster except the executor, and each preparer in the preparer sequence has a corresponding processing order.
[0010] In some embodiments, after processing the information to be processed, the method further includes:
[0011] A completion prompt message is sent to each preparer in the preparer sequence, where the completion prompt message is used to indicate that the information to be processed has been processed.
[0012] In some embodiments, sending a completion reminder message to each preparer in the preparer sequence includes:
[0013] The completion prompt information is sent to the first preparer in the preparer sequence to trigger each preparer in the preparer sequence to pass the completion prompt information to the next preparer in the corresponding processing order.
[0014] In some embodiments, the method further comprises:
[0015] If the target service is a preparer, determining an expected information reception time for the target service, wherein the expected information reception time is adapted to a processing order corresponding to the target service in the preparer sequence;
[0016] If the completion prompt message is not received when the expected message receiving time arrives, the pending message is processed;
[0017] If the target service receives the completion prompt message before the expected information receiving time, the completion prompt message is sent to the next preparer in the corresponding processing order in the preparer sequence.
[0018] In some embodiments, sending a completion prompt message to the next preparer in the preparer sequence in the corresponding processing order includes:
[0019] If the next preparer has an abnormality, the preparer with the abnormality will be recorded as an abnormal preparer, and a completion prompt message will be sent to the next preparer of the abnormal preparer.
[0020] In some embodiments, the method further comprises:
[0021] When a change in the address of the target service is detected, an update notification message is sent to each other service in the service cluster, where the other services are services in the service cluster other than the target service;
[0022] When receiving the update approval information returned by each other service, an update instruction is sent to the management service for managing the service cluster, wherein the update instruction is used to instruct the management service to send the new service information list to each service in the service cluster.
[0023] In some embodiments, the method further comprises:
[0024] When the new service information list sent by the management service is received, the service information list stored in the target service is switched to the new service information list.
[0025] In a second aspect, an embodiment of the present application provides a data processing device, the device comprising:
[0026] An information receiving unit, configured to, when a target service receives information to be processed, determine an executor of the information to be processed from the service cluster where the target service is located according to a pre-stored service information list and a pre-determined allocation rule;
[0027] The information processing unit is configured to process the information to be processed if the target service is an executor.
[0028] In some embodiments, the information receiving unit, after determining the executor of the information to be processed, further includes: determining a sequence of preparers for the information to be processed according to a predetermined sorting rule, wherein the preparers in the preparer sequence are services in the service cluster other than the executor, and each preparer in the preparer sequence corresponds to a processing order.
[0029] In some embodiments, after processing the information to be processed, the information processing unit further includes: sending a completion prompt message to each preparer in the preparer sequence, where the completion prompt message is used to indicate that the information to be processed has been processed.
[0030] In some embodiments, in the information processing unit, a completion prompt message is sent to each preparer in the preparer sequence, including: sending a completion prompt message to the first preparer in the preparer sequence to trigger each preparer in the preparer sequence to pass the completion prompt message to the next preparer in the corresponding processing order.
[0031] In some embodiments, the apparatus further includes a time determination unit, a first determination unit, and a second determination unit.
[0032] a time determination unit, configured to determine an expected information reception time of the target service if the target service is a preparer, wherein the expected information reception time is adapted to a processing order corresponding to the target service in a preparer sequence;
[0033] a first determining unit, configured to process the information to be processed if no completion prompt information is received when the expected information reception time arrives;
[0034] The second determining unit is configured to send the completion prompt information to the next preparer in the preparer sequence with the corresponding processing order if the expected information receiving time has not arrived when the target service receives the completion prompt information.
[0035] In some embodiments, in the second judgment unit, a completion prompt message is sent to the next preparer in the corresponding processing order in the preparer sequence, including: if there is an abnormality in the next preparer, the preparer with the abnormality is recorded as an abnormal preparer, and a completion prompt message is sent to the next preparer of the abnormal preparer.
[0036] In some embodiments, the device further includes a notification sending unit and an instruction sending unit.
[0037] a notification sending unit, configured to send update notification information to other services in the service cluster when detecting that the address of the target service has changed, wherein the other services are services in the service cluster other than the target service;
[0038] The instruction sending unit is configured to send an update instruction to the management service for managing the service cluster when receiving update approval information returned by each other service, wherein the update instruction is configured to instruct the management service to send a new service information list to each service in the service cluster.
[0039] In some embodiments, the device further includes an information updating unit configured to switch the service information list stored in the target service to the new service information list upon receiving a new service information list sent by the management service.
[0040] In a third aspect, an embodiment of the present application provides a server comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the above-mentioned data processing methods when executing the computer program.
[0041] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of any of the above-mentioned data processing methods.
[0042] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when running on a server, enables the server to execute any of the above-mentioned data processing methods.
[0043] Compared with the related art, the beneficial effect of the embodiment of the present application is that when each service in the service cluster receives information to be processed, it can respectively use a pre-stored service information list and a pre-determined allocation rule to determine the executor of the information to be processed from the service cluster, so that the executor jointly determined by each service processes the information to be processed, and it can be achieved that the service that processes the information to be processed can be effectively determined from multiple services.
[0044] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0046] Figure 1 This is a flow chart of a data processing method provided in one embodiment of the present application;
[0047] Figure 2 This is a schematic diagram of the effect of circular sorting provided by an embodiment of the present application;
[0048] Figure 3 is a flowchart of a data processing method provided by another embodiment of the present application;
[0049] Figure 4 is a flowchart of a data processing method provided by another embodiment of the present application;
[0050] Figure 5 is a structural diagram of a data processing device provided in one embodiment of the present application;
[0051] Figure 6 It is a structural diagram of a server provided in one embodiment of the present application. DETAILED DESCRIPTION
[0052] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obscuring the description of the present application with unnecessary detail.
[0053] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.
[0054] It will also be understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0055] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0056] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0057] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0058] In order to illustrate the technical solution of the present application, the following examples are provided for illustration.
[0059] Continue reading Figure 1 , an embodiment of the present application provides a data processing method, which may include the following steps 101 to 102.
[0060] Step 101 : When a target service receives information to be processed, it determines an executor of the information to be processed from the service cluster where the target service is located according to a pre-stored service information list and a pre-determined allocation rule.
[0061] The target service can be any service in a service cluster. In practice, services in a service cluster are typically replicas. In microservices, a service can typically be deployed as multiple replicas, which enables high availability and disaster recovery for the entire service.
[0062] The information to be processed may be a message or a task. As an example, the information to be processed may be a message queue (MQ) message.
[0063] The executor is usually a service for processing the information to be processed.
[0064] The service information list typically corresponds to a service cluster, and a service information in the service information list typically corresponds to a service in the service cluster. The service information in the service information list is used to describe the corresponding service. In actual applications, the service information may include, but is not limited to, the service number, service name, and service address.
[0065] Among them, the above-mentioned allocation rules are usually predetermined rules for selecting executors. As an example, the above-mentioned allocation rule can be to select the service with the same modulus value as the corresponding service number and the information to be processed as the executor. As another example, the above-mentioned allocation rule can also be to select the service that has been selected the least number of times as the executor. Among them, the modulus value of the above-mentioned information to be processed can be the value obtained by taking the modulus of the information to be processed and the target value, or it can be the value obtained by taking the modulus of the information identifier of the information to be processed and the target value. The above-mentioned target value is the total number of services in the service cluster. For example, the modulus value of the above-mentioned information to be processed can be ID%m, wherein ID is the information identifier of the information to be processed, % is the modulus symbol, and m is the total number of services in the service cluster.
[0066] In this embodiment, the execution subject of the above-mentioned data processing method is generally the above-mentioned target service. In actual applications, each service in the service cluster can be implemented as a server. It should be noted that the server can be hardware or software. When the server is hardware, it can be implemented as a device cluster consisting of multiple devices, or it can be implemented as a single device. When the server is software, it can be implemented as multiple software or software modules for providing distributed services, or it can be implemented as a single software or software module. No specific limitations are given here.
[0067] In practice, each service in a service cluster can usually receive information to be processed. When receiving information to be processed, each service in the service cluster can determine an executor from the service cluster based on the service information list and allocation rules stored by the service.
[0068] Step 102: If the target service is an executor, the information to be processed is processed.
[0069] Here, the target service can be any service in the service cluster. That is, for each service in the service cluster, if the service is determined as the executor, it can directly process the pending information. In practice, if the pending information is an MQ message, the processing of the pending information can include storing the MQ message in a database.
[0070] The data processing method provided in this embodiment is that when each service in the service cluster receives information to be processed, it can use a pre-stored service information list and a pre-determined allocation rule to determine the executor of the information to be processed from the service cluster, so that the executor jointly determined by each service processes the information to be processed, which can effectively determine the service that processes the information to be processed from multiple services.
[0071] In some optional implementations of this embodiment, in the above step 101, after determining the executor of the information to be processed, the following step may also be included: determining a sequence of preparers of the information to be processed according to a predetermined sorting rule.
[0072] The preparers in the preparer sequence are services in the service cluster other than the executor. Each preparer in the preparer sequence has a corresponding processing order. In actual applications, the preparers can replace the executor to process the pending information when an exception occurs in the executor.
[0073] The above-mentioned sorting rules are usually used to sort the candidates.
[0074] As an example, the above sorting rule can be to sort in ascending order of the service numbers of each preparer. For example, if there are 6 services in the service cluster, and the service numbers are 0, 1, 2, 3, 4, and 5 respectively, and if the executor is service 1, then the order of sorting in ascending order of the service numbers of each preparer can be obtained as follows: service 0 - service 2 - service 3 - service 4 - service 5.
[0075] As another example, the above-mentioned sorting rule may also be to sort the service numbers of the preparers in a cyclical order from small to large. Figure 2 This is a schematic diagram of the effect of the circular sorting provided in the embodiment of the present application. Figure 2 As shown, there are a total of 6 services in the service cluster, and the service numbers are 0, 1, 2, 3, 4, and 5. If the executor is service 1, then the service numbers of the preparers are sorted in ascending order, and the processing order of the preparers is: service 2 - service 3 - service 4 - service 5 - service 0.
[0076] In actual applications, after the preparers are sorted using the above sorting rules, each preparer can have a corresponding processing order.
[0077] In some optional implementations of this embodiment, in the above step 102, after processing the information to be processed, it may also include: sending a completion prompt message to each preparer in the preparer sequence.
[0078] The completion prompt message indicates that the pending information has been processed. In practice, the completion prompt message can be "1," "ok," or "(ID, ok)," where ID is the identifier of the pending information. If there are multiple pending information, the completion prompt message "(ID, ok)" can help the preparer who receives the completion prompt message accurately distinguish the pending information that has been processed.
[0079] Here, when the target service is the executor and the processing of the pending information is completed, a completion prompt message is sent to each preparer in the preparer sequence, so that each preparer can be informed of the processing status of the pending information in a timely manner, which helps to better coordinate the processing work between the various services.
[0080] In some implementations, when the target service completes processing the information to be processed, it may send completion prompt information to each preparer, so as to send the completion prompt information to each preparer.
[0081] In some implementations, when the target service completes processing the information to be processed, it can also send a completion prompt message to each preparer in the preparer sequence in the following manner: send a completion prompt message to the first preparer in the preparer sequence to trigger each preparer in the preparer sequence to pass the completion prompt message to the next preparer in the corresponding processing order.
[0082] Here, if the target service is the executor and has completed processing the pending information, it will only send a completion notification message to the first Preparer in the Preparer sequence. After receiving the completion notification message, the first Preparer will pass it on to the next Preparer, and so on, thus achieving the goal of passing the completion notification message to each Preparer.
[0083] It should be pointed out that by sending the completion prompt information to each preparer by passing the completion prompt information between each preparer, it can be achieved that each service only needs to send information once, which can avoid the situation where the service performance is reduced due to excessive concurrency of a certain service. That is, sending the completion prompt information to each preparer by information transmission can ensure the performance of each service, thereby improving the overall service performance of the service cluster.
[0084] Continue to refer Figure 3 , Figure 3 This is a flow chart of another data processing method provided in an embodiment of the present application. Figure 3 The data processing method shown may include the following steps 301 to 305.
[0085] Step 301: When a target service receives information to be processed, it determines an executor of the information to be processed from the service cluster where the target service is located according to a pre-stored service information list and a pre-determined allocation rule.
[0086] Step 302: If the target service is an executor, the information to be processed is processed.
[0087] In this embodiment, the specific operations of step 301-step 302 are the same as those in Figure 1The operations of step 101 to step 102 in the illustrated embodiment are substantially the same and will not be described in detail herein.
[0088] Step 303: If the target service is a preparer, then determine the expected information receiving time of the target service.
[0089] The expected information receiving time is adapted to the processing order of the target service in the preparer sequence. The above-mentioned expected information receiving time is usually the time when the completion prompt information should be received.
[0090] In practice, the target service can calculate the expected information reception time using the processing sequence corresponding to the target service and a predetermined time estimation formula, wherein the time estimation formula is usually a predetermined calculation formula for calculating the expected information reception time.
[0091] As an example, the above time estimation formula can be: T1=T0+T+i×t, where T1 is the expected information reception time, T0 is the time of receiving the information to be processed, T is the time required for the executor to process the information to be processed, i is the processing order of the target service, and t is the information transmission time between services.
[0092] As another example, the above time estimation formula can also be: T1 = T0 + i × (T + t). It should be noted that since the executor or a preparer between the executor and the target service may experience anomalies, when a service before the target service fails, the pending information will usually be processed by the service after the failed service, which usually delays the process. Multiplying i by T + t can ensure that the target service waits long enough to ensure that only one service processes the pending information.
[0093] As another example, the above time estimation formula can also be: T1 = T0 + i × λ ×(T+t), where λ is the duration adjustment coefficient, λ The value of is usually greater than or equal to 1. In this example, by setting the duration adjustment coefficient, it is possible to further ensure that the target service waits long enough, thereby ensuring that only one service processes the pending information.
[0094] Step 304: If the completion prompt message is not received when the expected message receiving time arrives, the information to be processed is processed.
[0095] If the target service still hasn't received the completion notification when the expected message reception time arrives, it means that all services before the target service have experienced an exception. In this case, the target service can process the pending message. This ensures that the pending message is processed effectively, thereby improving the service performance of the entire service cluster.
[0096] Step 305: If the target service receives the completion prompt message before the expected information receiving time, the completion prompt message is sent to the next preparer in the corresponding processing order in the preparer sequence.
[0097] Here, when the target service receives the completion prompt information, if the expected information reception time has not yet arrived, at this time, the target service can pass the received completion prompt information to the next preparer. In this way, the next preparer can continue to pass the completion prompt information down. In some application scenarios, if the target service is the preparer at the end of the corresponding processing sequence, the target service does not need to pass the completion prompt information on. In some application scenarios, if the target service is the preparer at the end of the corresponding processing sequence, the target service can also send the completion prompt information to the executor to inform the executor that the information transmission is completed when the target service receives the completion prompt information. This can enable the executor to be informed of the information transmission status in a timely manner, which helps to better coordinate the processing work between the various services.
[0098] This embodiment can achieve better coordination of processing work among various services and ensure that only one service processes the information to be processed in a timely and effective manner.
[0099] In some implementations, sending a completion prompt message to the next preparer in the corresponding processing order in the preparer sequence may include: if there is an abnormality in the next preparer, recording the preparer with the abnormality as an abnormal preparer, and sending a completion prompt message to the next preparer of the abnormal preparer.
[0100] In practice, after a target service sends a completion notification message to its next preserver, if the target service does not receive a response from the next preserver within a preset time interval, it is generally considered that the next preserver has experienced an anomaly. In this case, the target service can send the completion notification message to the next preserver of the anomaly preserver, thereby ensuring that the completion notification message is passed to each preserver. This ensures that even if a service experiences an anomaly, orderly operation between services can still be maintained, helping to improve the service performance of the entire service cluster. The preset time interval is typically a pre-determined interval. In actual applications, services typically respond very quickly upon receiving a completion notification message; that is, the value of the preset time interval is typically very small. Furthermore, upon receiving a completion notification message, services can typically pass the received completion notification message to the next preserver very quickly. In other words, if a service successfully receives the completion notification message, and if it is not the last preserver, it is generally considered that the service can successfully pass the completion notification message to the next preserver.
[0101] In actual applications, for each service in the service cluster, the service may correspond to a service log. Each time the service performs an action, a log record for recording the action will usually be written to the corresponding service log, thereby achieving timely updates to the service log. For example, when the service receives information to be processed, a corresponding log record may be written to the service log. When the service sends information to other services, such as the completion prompt information mentioned above, a corresponding log record may be written to the service log. When the service receives information, such as the completion prompt information mentioned above, a corresponding log record may be written to the service log. It should be pointed out that a service log is maintained for each service, and the service logs of each service can assist staff in troubleshooting, such as duplicate processing troubleshooting, missed processing troubleshooting, etc., so as to make timely repairs and adjustments to the functions of the entire service cluster.
[0102] Continue to refer Figure 4 , Figure 4 A flow chart of another data processing method provided in an embodiment of the present application. Figure 4 The data processing method shown may include the following steps 401 to 402.
[0103] Step 401: When it is detected that the address of the target service has changed, update notification information is sent to other services in the service cluster.
[0104] Among them, other services are services in the service cluster except the target service. The above target service can be any service in the service cluster.
[0105] The update notification information is typically used to notify other services to prepare to update the address corresponding to the target service. For example, the update notification information can be implemented as an (a, known) instruction, which is used to notify other services to prepare to update the address corresponding to the target service a, where a is the identification information of the target service. For another example, the update notification information can be implemented as an a-prepare instruction, which is used to notify other services to prepare to update the address corresponding to the target service a.
[0106] In practice, the address of each service in a service cluster may change. When the address of a service changes, it is usually necessary to notify the other services in the cluster of the changed address to ensure effective communication between the services in the cluster.
[0107] Here, the target service can detect whether the address has changed in a variety of ways. As an example, the target service can store the last used address. If the current address is inconsistent with the last used address, the address is considered to have changed. Conversely, if the current address is consistent with the last used address, the address is considered to have not changed. As another example, the target service can compare the current address with the address of the target service recorded in the service information list. If the current address is inconsistent with the recorded address, the address is considered to have changed. Conversely, if the current address is consistent with the recorded address, the address is considered to have not changed.
[0108] When detecting that an address change occurs, the target service may send update notification information to other services to notify them to prepare to update the address corresponding to the target service.
[0109] Step 402: Upon receiving the update approval information returned by each other service, an update instruction is sent to the management service for managing the service cluster.
[0110] The update instruction is used to instruct the management service to send the new service information list to each service in the service cluster.
[0111] The update approval information is generally information indicating approval of the update. As an example, the update approval information can be implemented as "yes" or "ok." This embodiment does not limit the specific implementation form of the update approval information.
[0112] In practice, the above management services can be implemented as a registration center. The registration center is usually the core component for service-oriented management, mainly used to store service information, such as service name and service address.
[0113] In actual applications, when the address of any service changes, the management service can promptly learn the new effective address of the target service and use the new effective address to update the service information list maintained by the management service to obtain the above new service information list.
[0114] Here, upon receiving update approval information from each of the other services, the target service can send an update instruction to the management service. Upon receiving the update instruction, the management service can send the new service information list to each of the services. Upon receiving the new service information list from the management service, each service can use it to update its own stored service information list.
[0115] In some optional implementations, the data processing method may further include the following step: upon receiving a new service information list sent by the management service, switching the service information list stored in the target service to the new service information list.
[0116] Here, when the target service receives the new service information list sent by the management service, it can use the new service information list to update the service information list stored in itself. In this way, the target service can effectively communicate with each service in the service cluster based on the new service information list.
[0117] In some application scenarios, the data processing method of this embodiment can be implemented as the following steps 1 to 5.
[0118] Step 1: Determine the number of services in the service cluster.
[0119] Here, when the service numbers of the services are 0, 1, 2...n respectively, the number of services in the service cluster is m=n+1. Figure 2 For example, if n is 5, then m is 6.
[0120] Step 2: Receive a subscription message, and the unique identifier of the subscription message is ID, and determine the executor.
[0121] The executor is usually a service for processing the information to be processed.
[0122] Here, the subscription message is information to be processed. The unique identifier of the subscription message is the information identifier of the information to be processed.
[0123] Here, the performer can be determined by the following method: h=ID%m, where h is the performer's ID. Figure 2 For example, if the unique identifier of the subscription message is ID with a value of 001, the determined executor may be service 1.
[0124] Step three: Identify the candidates.
[0125] The preparer can replace the executor in processing pending information when an exception occurs in the executor. Here, all services in the service cluster except the executor can be designated as preparers. Each preparer has a corresponding processing order.
[0126] Specifically, the service numbers of the preparers can be sorted in ascending order. Figure 2 For example, when the executor is service 1, the service numbers of the preparers are sorted in ascending order, and the processing order of the preparers is: service 2 - service 3 - service 4 - service 5 - service 0.
[0127] Step 4: The executor processes the subscription message and sends the (ID, ok) command to the next service when the processing is complete. If the command fails to be sent due to an exception in the next service, the command will be sent to the next service.
[0128] The (ID, ok) instruction is an implementation form of the above completion prompt information.
[0129] Combine Figure 2 For example, after service 1 completes processing the pending information, it can send a completion prompt message to service 2. If the completion prompt message is not successfully sent to service 2 due to an exception in service 2, service 1 will postpone sending the completion prompt message to service 3.
[0130] Step 5, the preparer k in ( λ ×(k-h+m)%m)×(T+t) time, the (ID, ok) instruction is sent to the next numbered service. If not received, the preparer k processes the subscription message and sends the (ID, ok) instruction to the next numbered service when the processing is completed. If the sending fails, the sending is postponed in the same way as step four.
[0131] Where k is the number of a preparer. T is the time required for the service to process the pending information, and t is the time it takes for the information to be transmitted between services. λ is the duration adjustment coefficient, λ The value of is usually greater than or equal to 1.
[0132] Combine Figure 2 , if the preparer is service 3, then ( λ ×(k-h+m)%m)×(T+t)=2 λ (T+t), that is, if service 3 is in 2 λ If the completion prompt message is received within (T+t) time, the completion prompt message is sent to service 4. λIf no completion notification message is received within (T+t), it indicates that an exception has occurred in any of the services preceding Service 3. Service 3 then processes the pending information. After processing the pending information, Service 3 sends a completion notification message to Service 4. If Service 3 fails to send the completion notification message to Service 4, Service 3 can defer sending the completion notification message to Service 5, following Step 4 above, and so on.
[0133] Corresponding to the data processing method of the above embodiment, Figure 5 A structural block diagram of a data processing device 500 provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0134] Reference Figure 5 , the data processing device 500 may include an information receiving unit 501 and an information processing unit 502.
[0135] The information receiving unit 501 is configured to determine, when a target service receives information to be processed, an executor of the information to be processed from the service cluster where the target service is located based on a pre-stored service information list and a pre-determined allocation rule;
[0136] The information processing unit 502 is configured to process the information to be processed if the target service is an executor.
[0137] In some embodiments, in the information receiving unit 501, after determining the executor of the information to be processed, it also includes: determining a sequence of preparers for the information to be processed according to a predetermined sorting rule, wherein the preparers in the preparer sequence are services in the service cluster other than the executor, and each preparer in the preparer sequence corresponds to a processing order.
[0138] In some embodiments, after processing the information to be processed, the information processing unit 502 further includes: sending a completion prompt message to each preparer in the preparer sequence, where the completion prompt message is used to indicate that the information to be processed has been processed.
[0139] In some embodiments, the information processing unit 502 sends a completion prompt message to each preparer in the preparer sequence, including: sending a completion prompt message to the first preparer in the preparer sequence to trigger each preparer in the preparer sequence to pass the completion prompt message to the next preparer in the corresponding processing order.
[0140] In some embodiments, the apparatus further includes a time determination unit, a first determination unit, and a second determination unit.
[0141] a time determination unit, configured to determine an expected information reception time of the target service if the target service is a preparer, wherein the expected information reception time is adapted to a processing order corresponding to the target service in a preparer sequence;
[0142] a first determining unit, configured to process the information to be processed if no completion prompt information is received when the expected information reception time arrives;
[0143] The second determining unit is configured to send the completion prompt information to the next preparer in the preparer sequence with the corresponding processing order if the expected information receiving time has not arrived when the target service receives the completion prompt information.
[0144] In some embodiments, in the second judgment unit, a completion prompt message is sent to the next preparer in the corresponding processing order in the preparer sequence, including: if there is an abnormality in the next preparer, the preparer with the abnormality is recorded as an abnormal preparer, and a completion prompt message is sent to the next preparer of the abnormal preparer.
[0145] In some embodiments, the device further includes a notification sending unit and an instruction sending unit.
[0146] a notification sending unit, configured to send update notification information to other services in the service cluster when detecting that the address of the target service has changed, wherein the other services are services in the service cluster other than the target service;
[0147] The instruction sending unit is configured to send an update instruction to the management service for managing the service cluster when receiving update approval information returned by each other service, wherein the update instruction is configured to instruct the management service to send a new service information list to each service in the service cluster.
[0148] In some embodiments, the device further includes an information updating unit configured to switch the service information list stored in the target service to the new service information list upon receiving a new service information list sent by the management service.
[0149] The device provided in this embodiment can, when each service in the service cluster receives information to be processed, respectively use a pre-stored service information list and a pre-determined allocation rule to determine the executor of the information to be processed from the service cluster, so that the executor jointly determined by each service processes the information to be processed, thereby effectively determining the service that processes the information to be processed from multiple services.
[0150] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the first embodiment of the method of this application. Their specific functions and technical effects can be found in the method embodiment section and will not be repeated here.
[0151] Figure 6 This is a schematic diagram of the structure of the server 600 provided in one embodiment of the present application. Figure 6 As shown, the server 600 of this embodiment includes: at least one processor 601 ( Figure 6 Only one processor is shown in the figure), memory 602, and a computer program 603 stored in memory 602 and executable on at least one processor 601, such as a data processing program. When the processor 601 executes the computer program 603, the steps in any of the above-mentioned method embodiments are implemented. When the processor 601 executes the computer program 603, the steps in the above-mentioned data processing method embodiments are implemented. When the processor 601 executes the computer program 603, the functions of the modules / units in the above-mentioned device embodiments are implemented, such as Figure 5 The functions of the information receiving unit 501 and the information processing unit 502 are shown.
[0152] Exemplarily, computer program 603 may be divided into one or more modules / units, one or more of which are stored in memory 602 and executed by processor 601 to implement the present application. One or more modules / units may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of computer program 603 in server 600. For example, computer program 603 may be divided into an information receiving unit and an information processing unit. The specific functions of each unit have been described in the above embodiments and will not be repeated here.
[0153] The server 600 may be a computing device such as a server, a desktop computer, a tablet computer, a cloud server, or a mobile terminal. The server 600 may include, but is not limited to, a processor 601 and a memory 602. It will be understood by those skilled in the art that Figure 6 This is only an example of the server 600 and does not constitute a limitation on the server 600. The server 600 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the server may also include input and output devices, network access devices, buses, etc.
[0154] The processor 601 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0155] Memory 602 can be an internal storage unit of server 600, such as a hard drive or memory of server 600. Memory 602 can also be an external storage device of server 600, such as a plug-in hard drive, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash memory card, etc. equipped on server 600. Furthermore, memory 602 can include both an internal storage unit of server 600 and an external storage device. Memory 602 is used to store computer programs and other programs and data required by the server. Memory 602 can also be used to temporarily store data that has been output or is about to be output.
[0156] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0157] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0158] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0159] In the embodiments provided in this application, it should be understood that the disclosed devices / servers and methods can be implemented in other ways. For example, the device / server embodiments described above are merely schematic. For example, the division of modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0160] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0161] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0162] If the integrated module is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, it can implement the steps of the above-mentioned various method embodiments. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0163] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.
Claims
1. A data processing method, characterized in that: The method comprises: When a target service receives information to be processed, an executor of the information to be processed is determined from the service cluster where the target service is located, based on a pre-stored service information list and a predetermined allocation rule. The target service is any service in the service cluster, and the executor is a service used to process the information to be processed. The service information in the service information list includes a service number, a service name, and a service address. The allocation rule is to select a service with the same service number as the modulus value of the information to be processed as the executor. If the target service is an executor, processing the information to be processed; After processing the information to be processed, sending the completion prompt information to the first preparer in the preparer sequence, so as to trigger each preparer in the preparer sequence to pass the completion prompt information to the next preparer in the corresponding processing order; The method further comprises: If the target service is a preparer, determining an expected information reception time for the target service, wherein the expected information reception time is adapted to a processing order corresponding to the target service in the preparer sequence; If the completion prompt message is not received when the expected information reception time arrives, processing the information to be processed; If the target service receives the completion prompt message before the expected information receiving time, the completion prompt message is sent to the next preparer in the preparer sequence with the corresponding processing order.
2. The data processing method according to claim 1, wherein: After determining the executor of the information to be processed, the method further includes: According to a predetermined sorting rule, a preparer sequence of the information to be processed is determined, wherein the preparers in the preparer sequence are services in the service cluster except the executor, and each preparer in the preparer sequence corresponds to a processing order.
3. The data processing method according to claim 1, wherein: The sending of the completion prompt information to the next preparer in the preparer sequence with the corresponding processing order adjacent thereto includes: If the next preparer has an abnormality, the preparer with the abnormality is recorded as an abnormal preparer, and the completion prompt information is sent to the next preparer of the abnormal preparer.
4. The data processing method according to claim 1, wherein: The method further comprises: When detecting that the address of the target service has changed, sending update notification information to each other service in the service cluster, wherein the other services are services in the service cluster other than the target service; Upon receiving the update approval information returned by each other service, an update instruction is sent to the management service for managing the service cluster, wherein the update instruction is used to instruct the management service to send a new service information list to each service in the service cluster.
5. The data processing method according to any one of claims 1 to 4, characterized in that: The method further comprises: When a new service information list sent by the management service is received, the service information list stored in the target service is switched to the new service information list.
6. A server comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.
7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Service data processing method and device, storage medium and electronic device
CN110365748A
Document transcoding method and device, dispatch server and storage medium
CN112035405A
Server cluster load balancing control method and system based on cloud service
CN112231075A
Request processing method of server cluster, medium and electronic equipment
CN113794764A