Method and system for generating self-increasing message ID (Identity) in message pushing system
By assigning unique digital ID and cluster ID in the message push system, and increasing the ID locally on the client, combining monitoring and adjustment step size, master-slip number segment switching and cluster change processing, the uniqueness and incrementality of message ID generation are solved, and efficient, real-time and reliable message ID generation is achieved.
Patent Information
- Application Number
- CN202510080822.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-05-02
AI Technical Summary
In the message push system, it is difficult for the prior art to effectively generate a unique incremental message ID, which makes it difficult to guarantee the orderliness and traceability of messages, and there is a risk of single point of failure and ID loss.
By registering and assigning unique digital IDs and cluster IDs, the client stores and increments the IDs locally, combining monitoring and adjustment step size, master-slip number segment switching and cluster change processing to ensure the uniqueness and incrementality of the ID.
It realizes efficient, real-time and reliable generation of message IDs, avoids the risks of ID exhaustion and service interruption, and ensures system stability and continuity.
Smart Images

Figure CN119922159A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of information technology, and specifically relates to a method and system for generating a self-incrementing message ID in a message push system. Background Art
[0002] In the field of message push, network unreliability makes clients mainly pull messages through message IDs. Using UUID as a unique ID makes it difficult to track unpulled messages due to disorder. Therefore, generating a unique incremental message ID becomes a key step to ensure the stability and reliability of the message push system.
[0003] In the message push system, generating a unique self-incrementing ID is the key to ensuring the orderliness and traceability of messages. Redis's INCR command can efficiently implement this function. It ensures the atomicity of the operation and is suitable for generating unique self-incrementing IDs. By combining timestamps and machine identifiers, the uniqueness and information richness of the ID can be further improved. However, this method is highly dependent on Redis and has the risk of single point failure. Redis is based on memory operations, and restarting may cause ID loss. Although enabling persistence can alleviate this problem, it will seriously affect performance.
[0004] Another way to generate a unique ID is to use the Snowflake algorithm, which generates a 64-bit integer ID that includes a timestamp, machine ID, and serial number, ensuring the global uniqueness and incrementality of the ID. This algorithm performs well in a distributed environment, but it is strongly dependent on the machine clock. Clock dialback can lead to duplicate ID generation, which may cause service unavailability. Summary of the invention
[0005] The purpose of the present invention is to provide a method and system for generating a self-incrementing message ID in a message push system, so as to solve the problems raised in the above background technology.
[0006] In order to achieve the above object, the present invention provides the following technical solution: a method for generating a self-incrementing message ID in a message push system, and the specific use steps of the method are as follows:
[0007] S1: User registration and cluster ID allocation: Users register with the push system and receive a 9-digit unique digital ID and a fixed 5-digit cluster ID;
[0008] S2: Configure the message ID acquisition strategy: The administrator configures the client message ID step size, which is determined by combining historical data and real-time window sliding evaluation;
[0009] S3: Client local storage and ID accumulation: When the client starts, it obtains the cluster's maximum ID and stores it locally. Then it increments the 9-digit ID locally to generate a new message.
[0010] S4: Monitoring and adjusting the step size: The client monitors the ID generation rate. When the ID is less than 10% of the step size, it requests a new number segment and step size from the cluster.
[0011] S5: Use primary and backup number segments to ensure smoothness: The client uses primary and backup number segments to switch to avoid request peaks when the number segments are exhausted, ensuring smooth operation of the system;
[0012] S6: Processing cluster changes and upgrades: When a cluster changes, the client updates the cluster ID, retrieves the maximum ID value of the new cluster, and updates the local storage;
[0013] S7: Generation and sending of message ID: When the Client sends a message, it combines the user ID, cluster ID, 0 upgrade bit and incrementing digital ID to generate a message ID and send it.
[0014] Preferably, the user registration and cluster ID allocation in S1 means that when a user registers an account in the push system, the system will immediately assign a unique 9-digit user ID to the user to identify the user. At the same time, if the system supports multi-cluster deployment, the system will also assign a fixed 5-digit string cluster ID to the user based on the cluster in which the user is actually located. This cluster ID remains unchanged throughout the user's entire usage cycle.
[0015] Preferably, configuring the message ID acquisition strategy in S2 means that the system administrator or a professional configuration tool is responsible for setting the maximum step value of the message ID for the client. This setting is based on scientific evaluation. The evaluation process comprehensively considers historical data, especially the average message ID generation rate of the previous day, and combines the real-time window sliding evaluation method, that is, by analyzing the average request rate in the current time window to obtain a more accurate step value.
[0016] Preferably, the specific steps of using the client local storage and ID accumulation in S3 are:
[0017] Step 1: Request the maximum ID when starting or updating the cluster ID: When the client starts for the first time or receives a new cluster ID, it will actively send a request to the target cluster to obtain the maximum message ID value corresponding to the current user ID;
[0018] Step 2: Locally store the maximum ID value: Once the maximum message ID value is received from the cluster, the client will immediately store this value in local memory;
[0019] Step 3: Generate new messages by accumulating local IDs: When generating new messages, the client starts from the maximum ID value stored locally and increments it by one number each time (usually a 9-digit auto-incremental number) as the ID of the new message. This process is completed entirely on the client locally without relying on the response of the cluster, further improving the real-time and reliability of message generation.
[0020] Preferably, the monitoring and adjustment step in S4 refers to the Client monitoring and adjusting its own message ID generation rate in real time, and dynamically managing it according to the preset step value. When it is monitored that the current number of remaining IDs has dropped to 10% or less of the configured step value, the Client will actively initiate a request to the cluster to obtain new number segment resources, that is, update the maximum ID value and step parameters.
[0021] Preferably, the specific steps of using the primary and backup number segments in S5 to ensure smoothness are as follows:
[0022] Step 1: Obtain and back up the new number segment: The client requests and obtains the new number segment from the cluster and stores it as the backup number segment.
[0023] Step 2: Use the current primary number segment: Continue to generate message IDs and use the current primary number segment resources;
[0024] Step 3: Switch to the new primary number segment: When the primary number segment resources are exhausted, the Client seamlessly switches to the previously backed-up new number segment and continues to use it as the new primary number segment.
[0025] Preferably, the specific steps for processing cluster changes and upgrades in S6 are as follows:
[0026] Step 1: Update cluster information: The Client detects cluster changes and first updates the cluster connection information;
[0027] Step 2: Request the maximum ID of the new cluster: Using the new cluster connection information, the client sends a request to the new cluster to obtain the new maximum ID value;
[0028] Step 3: Update local storage: The client updates the new maximum ID value obtained to the local storage to continue generating message IDs.
[0029] Preferably, the generation and sending of the message ID in S7 means that when a message needs to be sent to a user, the Client will generate a complete message ID based on a series of parameters, including the current user ID, cluster ID, a fixed upgrade bit, and an incremented digital ID obtained from local storage. The Client will combine these parameters to form a unique message ID. Subsequently, the Client will package the generated message ID together with the message content and send it to the target user or system through the communication channel.
[0030] Preferably, based on the above method, the system includes a server module and a client module; the server module adopts a KV storage cluster architecture based on the Raft protocol, which can flexibly have one or more nodes and dynamically expand according to the number of concurrent tasks. At the same time, the client module acts as a server for generating an ID, and uses the cluster architecture to generate a unique ID.
[0031] The beneficial effects of the present invention are as follows:
[0032] The present invention realizes the refined management of users and clusters through the unique digital ID and cluster ID assigned when the user registers. Secondly, the administrator can scientifically configure the message ID acquisition strategy, combine historical data and real-time evaluation to ensure the rationality and efficiency of ID generation. The Client local storage and ID accumulation mechanism further improve the real-time and reliability of message generation. At the same time, measures such as monitoring and adjusting the step size and using the primary and backup number segments to ensure smoothness effectively avoid the risks of ID exhaustion and service interruption. In addition, the method for handling cluster changes and upgrade bits ensures the stability and continuity of the system when the cluster changes. Finally, the method supports the KV storage cluster architecture based on the Raft protocol, has good performance and scalability, and provides a strong guarantee for the efficient operation of the message push system. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 It is a schematic diagram of the overall use process of the present invention;
[0034] Figure 2 It is a schematic diagram of the push flow of the present invention. DETAILED DESCRIPTION
[0035] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0036] like Figure 1 to Figure 2As shown, the embodiment of the present invention provides a method for generating a self-incrementing message ID in a message push system, and the specific steps of using the method are as follows:
[0037] S1: User registration and cluster ID allocation: Users register with the push system and receive a 9-digit unique digital ID and a fixed 5-digit cluster ID (allocated by cluster);
[0038] S2: Configure the message ID acquisition strategy: The administrator configures the client message ID step size, which is determined by combining historical data and real-time window sliding evaluation;
[0039] S3: Client local storage and ID accumulation: When the client starts, it obtains the cluster's maximum ID and stores it locally. Then it increments the 9-digit ID locally to generate a new message.
[0040] S4: Monitoring and adjusting the step size: The client monitors the ID generation rate. When the ID is less than 10% of the step size, it requests a new number segment and step size from the cluster.
[0041] S5: Use primary and backup number segments to ensure smoothness: The client uses primary and backup number segments to switch to avoid request peaks when the number segments are exhausted, ensuring smooth operation of the system;
[0042] S6: Processing cluster changes and upgrades: When the cluster changes, the client updates the cluster ID, retrieves the maximum ID value of the new cluster, and updates the local storage;
[0043] S7: Generation and sending of message ID: When the Client sends a message, it combines the user ID, cluster ID, 0 upgrade bit and incrementing digital ID to generate a message ID and send it.
[0044] Each step of the above content has been carefully designed, from ID allocation during user registration to the message ID acquisition strategy configured by the administrator to the local storage and ID accumulation of the client. The client can monitor the ID generation rate in real time and dynamically adjust the step size. At the same time, the primary and backup number segments are switched to avoid request peaks and ensure the smoothness of the system. When the cluster changes, the client can also update information in a timely manner to ensure the continuity of message delivery. Finally, the client can accurately generate and send message IDs, improving the overall performance of the system and user experience.
[0045] Among them, the user registration and cluster ID allocation in S1 means that when a user registers an account in the push system, the system will immediately assign a unique 9-digit user ID to the user to identify the user. At the same time, if the system supports multi-cluster deployment, the system will also assign a fixed 5-digit string cluster ID to the user based on the cluster where the user is actually located. This cluster ID remains unchanged throughout the user's entire usage cycle, which not only helps the system to manage users more finely, but also ensures the consistency and continuity of user data between clusters.
[0046] By assigning a unique 9-digit user ID to the user, the system can accurately identify the user, improving the accuracy and security of user management. Secondly, if the system supports multi-cluster deployment, assigning a fixed 5-digit string cluster ID to the user will not only help the system to manage the user more finely, but also ensure the consistency and continuity of the user's data between clusters. This mechanism not only improves the scalability and flexibility of the system, but also optimizes the user experience, allowing users to enjoy more stable and reliable services.
[0047] The configuration of the message ID acquisition strategy in S2 refers to the system administrator or professional configuration tool being responsible for setting the maximum step value of the message ID for the client. This setting is based on scientific evaluation. The evaluation process comprehensively considers historical data, especially the average message ID generation rate of the previous day, and combines the real-time window sliding evaluation method, that is, by analyzing the average request rate in the current time window to obtain a more accurate step value. This setting method is intended to ensure that the client can generate message IDs efficiently and stably.
[0048] The above content can be used to set a reasonable maximum step value for message IDs through scientific evaluation by system administrators or professional configuration tools. This setting is not only based on in-depth analysis of historical data, especially the average message ID generation rate of the previous day, but also combines the real-time window sliding evaluation method to obtain a more accurate step value. Such a strategy not only optimizes resource allocation and avoids waste and shortage of IDs, but also improves the response speed and stability of the system. At the same time, it also reduces the operational difficulty of system administrators, making the management of message IDs more efficient and reliable.
[0049] The specific steps of using the client local storage and ID accumulation in S3 are as follows:
[0050] Step 1: Request the maximum ID when starting and updating the cluster ID: When the client starts for the first time or receives a new cluster ID, it will actively send a request to the target cluster to obtain the maximum message ID value corresponding to the current user ID. This step ensures that the client can generate message IDs starting from the latest and valid ID range.
[0051] Step 2: Locally store the maximum ID value: Once the maximum message ID value is received from the cluster, the client will immediately store this value in local memory. This design eliminates the need for the client to frequently request IDs from the cluster, thereby reducing network communication overhead and improving the efficiency of message generation.
[0052] Step 3: Generate new messages by accumulating local IDs: When generating new messages, the client starts from the maximum ID value stored locally and increments it by one number each time (usually a 9-digit auto-incremental number) as the ID of the new message. This process is completed entirely on the client locally without relying on the response of the cluster, further improving the real-time and reliability of message generation.
[0053] In the above, by requesting the maximum ID when starting and updating the cluster ID, the client can ensure that the message ID is generated from the valid ID range, avoiding ID conflicts. Secondly, the maximum ID value is stored in the local memory, which reduces the number of cluster requests, reduces network communication overhead, and improves efficiency. Finally, the client completes the ID accumulation and generates new messages locally without relying on cluster responses, which improves the real-time and reliability of message generation. This series of steps not only optimizes system performance, but also enhances user experience and ensures efficient and accurate message delivery.
[0054] Among them, the monitoring and adjustment step in S4 refers to the Client monitoring and adjusting its own message ID generation rate in real time, and dynamically managing it according to the preset step value. When it is monitored that the current number of remaining IDs has dropped to 10% or less of the configured step value, the Client will actively initiate a request to the cluster to obtain new number segment resources, that is, update the maximum ID value and step parameters to ensure the continuity and efficiency of ID supply, thereby maintaining stable system operation and efficient data processing capabilities.
[0055] The specific steps of using the primary and backup number segments in S5 to ensure smoothness are as follows:
[0056] Step 1: Obtain and back up the new number segment: The client requests and obtains the new number segment from the cluster and stores it as the backup number segment.
[0057] Step 2: Use the current primary number segment: Continue to generate message IDs and use the current primary number segment resources;
[0058] Step 3: Switch to the new primary number segment: When the primary number segment resources are exhausted, the Client seamlessly switches to the previously backed-up new number segment and continues to use it as the new primary number segment.
[0059] The above specific steps of using primary and backup number segments to ensure smoothness bring significant advantages to the system. First, by obtaining and backing up new number segments in advance, the system can prevent service interruptions caused by number segment exhaustion, improving the stability and reliability of the system. Secondly, during the use of the current primary number segment, the system can continuously generate message IDs to ensure business continuity. Finally, when the primary number segment is exhausted, the system can seamlessly switch to the new backup number segment, avoiding service interruptions and delays, and ensuring smooth message delivery. This series of steps not only optimizes the performance of the system, but also improves the user experience.
[0060] The specific steps for processing cluster changes and upgrades in S6 are as follows:
[0061] Step 1: Update cluster information: When the client detects a cluster change (such as migration to a new cluster), it first updates the cluster connection information;
[0062] Step 2: Request the maximum ID of the new cluster: Using the new cluster connection information, the client sends a request to the new cluster to obtain the new maximum ID value;
[0063] Step 3: Update local storage: The client updates the new maximum ID value obtained to the local storage to continue generating message IDs.
[0064] The specific steps for handling cluster changes and upgrades bring significant advantages. First, by updating cluster information in a timely manner, the client can quickly adapt to the new cluster environment and ensure the continuity of message delivery. Secondly, requesting the maximum ID value from the new cluster not only avoids ID conflicts, but also ensures the uniqueness of the message ID. Finally, updating the maximum ID value in the local storage allows the client to continue to generate message IDs seamlessly without interrupting the service. This series of steps not only improves the flexibility and reliability of the system, but also optimizes the user experience and ensures efficient and accurate message delivery.
[0065] The generation and sending of the message ID in S7 means that when a message needs to be sent to a user, the client will generate a complete message ID based on a series of parameters, including the current user ID, cluster ID, a fixed upgrade bit (whose value is always 0), and an incremental digital ID obtained from local storage. The client will combine these parameters to form a unique message ID. Subsequently, the client will package the generated message ID with the message content and send it to the target user or system through the communication channel. In this way, each message can be accurately tracked and located to ensure the reliability and effectiveness of message delivery.
[0066] By combining the user ID, cluster ID, fixed upgrade bit and incremental digital ID, the Client can generate a unique message ID, which greatly improves the message recognition and tracking ability. At the same time, the message ID is packaged and sent together with the message content, so that the target user or system can easily receive and accurately identify each message. This mechanism not only ensures the reliability and effectiveness of message delivery, but also improves the overall operation efficiency and user experience of the system. In addition, it also facilitates subsequent message management and analysis, which helps to further optimize system performance and user services.
[0067] Among them, the server module and the client module; the server module adopts a KV storage cluster architecture based on the Raft protocol, which can flexibly have one or more nodes and dynamically expand according to the number of concurrent tasks. This design enables the system to efficiently handle concurrent tasks and improves overall performance. At the same time, the client module, as a server for generating IDs, can generate a unique ID using the cluster architecture. This architecture not only ensures the uniqueness of the ID, but also enables the system to remain stable and efficient in the face of large-scale concurrent requests, providing strong support for business development.
[0068] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0069] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for generating a self-incrementing message ID in a message push system, characterized in that: The specific implementation steps of this method are as follows: S1: User registration and cluster ID allocation: Users register with the push system and receive a 9-digit unique digital ID and a fixed 5-digit cluster ID; S2: Configure the message ID acquisition strategy: The administrator configures the client message ID step size, which is determined by combining historical data and real-time window sliding evaluation; S3: Client local storage and ID accumulation: When the client starts, it obtains the cluster's maximum ID and stores it locally. Then it increments the 9-digit ID locally to generate a new message. S4: Monitoring and adjusting the step size: The client monitors the ID generation rate. When the ID is less than 10% of the step size, it requests a new number segment and step size from the cluster. S5: Use primary and backup number segments to ensure smoothness: The client uses primary and backup number segments to switch to avoid request peaks when the number segments are exhausted, ensuring smooth operation of the system; S6: Processing cluster changes and upgrades: When a cluster changes, the client updates the cluster ID, retrieves the maximum ID value of the new cluster, and updates the local storage; S7: Generation and sending of message ID: When the Client sends a message, it combines the user ID, cluster ID, 0 upgrade bit and incrementing digital ID to generate a message ID and send it.
2. The method for generating a self-incrementing message ID in a message push system according to claim 1, characterized in that: The user registration and cluster ID allocation in S1 means that when a user registers an account in the push system, the system will immediately assign a unique 9-digit user ID to the user to identify the user. At the same time, if the system supports multi-cluster deployment, the system will also assign a fixed 5-digit string cluster ID to the user based on the cluster the user is actually in. This cluster ID remains unchanged throughout the user's entire usage cycle.
3. The method for generating a self-incrementing message ID in a message push system according to claim 1, characterized in that: Configuring the message ID acquisition strategy in S2 means that the system administrator or professional configuration tool is responsible for setting the maximum step value of the message ID for the client. This setting is based on scientific evaluation. The evaluation process comprehensively considers historical data, especially the average message ID generation rate of the previous day, and combines the real-time window sliding evaluation method, that is, by analyzing the average request rate in the current time window to obtain a more accurate step value.
4. The method for generating a self-incrementing message ID in a message push system according to claim 1, characterized in that: The specific steps for using client local storage and ID accumulation in S3 are as follows: Step 1: Request the maximum ID when starting or updating the cluster ID: When the client starts for the first time or receives a new cluster ID, it will actively send a request to the target cluster to obtain the maximum message ID value corresponding to the current user ID; Step 2: Locally store the maximum ID value: Once the maximum message ID value is received from the cluster, the client will immediately store this value in local memory; Step 3: Generate new messages by accumulating local IDs: When generating new messages, the client starts from the maximum ID value stored locally and increments it by one number each time as the ID of the new message. This process is completed entirely on the client locally without relying on the response of the cluster, further improving the real-time and reliability of message generation.
5. The method for generating a self-incrementing message ID in a message push system according to claim 1, characterized in that: The monitoring and adjustment step in S4 refers to the Client monitoring and adjusting its own message ID generation rate in real time, and dynamically managing it according to the preset step value. When it is monitored that the current number of remaining IDs has dropped to 10% or less of the configured step value, the Client will actively initiate a request to the cluster to obtain new number segment resources, that is, update the maximum ID value and step parameters.
6. The method for generating a self-incrementing message ID in a message push system according to claim 1, characterized in that: The specific steps of using the primary and backup number segments in S5 to ensure smoothness are as follows: Step 1: Obtain and back up the new number segment: The client requests and obtains the new number segment from the cluster and stores it as the backup number segment. Step 2: Use the current primary number segment: Continue to generate message IDs and use the current primary number segment resources; Step 3: Switch to the new primary number segment: When the primary number segment resources are exhausted, the Client seamlessly switches to the previously backed-up new number segment and continues to use it as the new primary number segment.
7. The method for generating a self-incrementing message ID in a message push system according to claim 1, characterized in that: The specific steps for processing cluster changes and upgrades in S6 are as follows: Step 1: Update cluster information: The Client detects cluster changes and first updates the cluster connection information; Step 2: Request the maximum ID of the new cluster: Using the new cluster connection information, the client sends a request to the new cluster to obtain the new maximum ID value; Step 3: Update local storage: The client updates the new maximum ID value obtained to the local storage to continue generating message IDs.
8. The method for generating a self-incrementing message ID in a message push system according to claim 1, characterized in that: The generation and sending of the message ID in S7 means that when a message needs to be sent to a user, the Client will generate a complete message ID based on a series of parameters. These parameters include the current user ID, cluster ID, a fixed upgrade bit, and an incrementing digital ID obtained from local storage. The Client will combine these parameters to form a unique message ID. Subsequently, the Client will package the generated message ID together with the message content and send it to the target user or system through the communication channel.
9. A system for generating a self-incrementing message ID in a message push system, characterized in that: Based on any method described in claims 1-8, the system includes a server module and a client module; the server module adopts a KV storage cluster architecture based on the Raft protocol, which can flexibly have one or more nodes and dynamically expand according to the number of concurrent tasks. At the same time, the client module acts as a server for generating an ID, and uses the cluster architecture to generate a unique ID.