Instant messaging system session caching method, computer device, medium and product

Through hash calculation and memory caching technology, the performance bottleneck problem of the instant messaging system under high concurrency is solved, the uniform distribution and rapid response of session information are achieved, and the system stability and user experience are improved.

CN120710967APending Publication Date: 2025-09-26BEIJING VRV SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510762768.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-09
Publication Date
2025-09-26

AI Technical Summary

Technical Problem

In high-concurrency instant messaging systems, frequent database read and write operations lead to performance bottlenecks, affecting message sending and receiving and cloud push, resulting in delays and untimely push, and reducing user experience.

Method used

The target chat service node is determined through hash calculation, and session information is cached in the database and memory to achieve uniform distribution of sessions. Memory caching technology is used to speed up data access and ensure data persistence and consistency.

Benefits of technology

It improves the overall processing capacity of the system, reduces response time, ensures fast access and stability of data, and improves user satisfaction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120710967A_ABST
    Figure CN120710967A_ABST
Patent Text Reader

Abstract

The invention discloses an instant messaging system session caching method, a computer device, a medium and a product. The method comprises the following steps: receiving a session initiation request; when the session initiation request is first initiation of a target session, session information is created, hash calculation is performed on an ID of the session information, a target chat service node is determined according to an obtained hash value, and then the session initiation request is sent to the target chat service node; obtaining associated session information and all session member information of the session initiation request through a target chat service node, and caching the information in a database and a target memory; otherwise, determining the target ID of the session information corresponding to the session initiation request, querying the corresponding associated session information and all session member information from the database according to the target ID, and loading the information into the target memory for caching. According to the method, quick response can be carried out according to different requests, efficient and quick session caching is carried out, and the performance balance of data storage and read-write of the instant messaging system is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of instant messaging technology, and in particular to an instant messaging system session caching method, computer device, medium, and product. Background Art

[0002] In today's era of highly developed digital communications, instant messaging (IM) systems have become a crucial tool for daily communication and internal corporate communications. During the operation of IM systems, various data types, such as session information, session user information, read messages, and user device information, are typically stored in databases or file systems.

[0003] Taking the group chat scenario as an example, when a user sends a message within the group, the system needs to perform a series of query operations, including querying the group information to determine the basic attributes of the group, querying the group members to clarify the recipients of the message, filtering the group members' confidentiality levels to ensure the safe flow of sensitive information, and querying the mute settings to determine whether the message can be sent normally. In the single chat scenario, each time a message is sent, the system also needs to query the blacklist to avoid sending messages to blocked users, and query the note name to optimize the message display effect. In addition, for notification push of offline devices, the system needs to query whether the device is offline each time, and further query the user's cloud push related settings to decide whether to push the message and what push method to use.

[0004] However, with the rapid growth in the number of instant messaging users and the significant increase in the frequency of message interactions, the system faces the daunting challenge of high concurrency. High concurrency, coupled with frequent read and write operations to databases and file systems, results in poor performance. This directly impacts core functions such as message sending and receiving, as well as cloud push notifications. This leads to issues such as message delays and untimely push notifications, severely reducing the user experience and overall system efficiency. Summary of the Invention

[0005] In view of this, the embodiments of the present disclosure provide an instant messaging system session caching method, computer device, medium, and product, which can solve the performance bottleneck problem of instant messaging system data storage and reading and writing under high concurrency in the prior art.

[0006] In a first aspect, an embodiment of the present disclosure provides a method for caching a session in an instant messaging system, comprising: Receive a session initiation request; Determine whether the session initiation request is the first initiation of a target session. If so, create session information for the target session, perform a hash calculation on the ID of the session information, and determine a target chat service node based on the obtained hash value; In response to the determined target chat service node, sending the session initiation request to the target chat service node; Obtaining the associated session information of the session initiation request and all session member information through the target chat service node, and caching them in a database and a target memory; If the session initiation request is not the first initiation of the target session, determine the target ID of the session information corresponding to the session initiation request, query the corresponding associated session information and all session member information from the database according to the target ID, and load them into the target memory for caching.

[0007] In a second aspect, the present disclosure also provides an instant messaging system session cache system, including: A request receiving module, used for receiving a session initiation request; a target chat service node determination module, configured to determine whether the session initiation request is the first initiation of a target session; if so, create session information for the target session, perform a hash calculation on the ID of the session information, and determine the target chat service node based on the obtained hash value; a routing module, configured to send the session initiation request to the target chat service node in response to the determined target chat service node; A first cache module is used to obtain the associated session information of the session initiation request and all session member information through the target chat service node, and cache them in a database and a target memory; The second cache module is used to determine the target ID of the session information corresponding to the session initiation request if the session initiation request is not the first initiation of the target session, query the corresponding associated session information and all session member information from the database according to the target ID, and load them into the target memory for caching.

[0008] In a third aspect, the embodiments of the present disclosure further provide a computer device that adopts the following technical solution: The computer device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor. The instructions are executed by the at least one processor to enable the at least one processor to execute any of the instant messaging system session caching methods described above.

[0009] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute any of the instant messaging system session caching methods described above.

[0010] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, comprising a computer program / instruction, which implements the steps of any of the above methods when executed by a processor.

[0011] The instant messaging system session caching method disclosed in the present application creates session information for the target session, performs a hash calculation on the ID of the session information, determines a target chat service node based on the hash value, and sends the session initiation request to the target chat service node in response to the determined target chat service node. The target chat service node obtains the associated session information and all session member information of the session initiation request and caches the information in a database and a target memory. If the session initiation request is not the first initiation of the target session, the target ID of the session information corresponding to the session initiation request is determined, and the corresponding associated session information and all session member information are retrieved from a database based on the target ID and loaded into the target memory for caching. A hash calculation is used to achieve uniform distribution of sessions and avoid uneven node load. A memory caching technique is used to accelerate data access, reduce response time, and improve the overall processing capability of the system. The session information is cached in the database to ensure data persistence, preventing data loss even in the event of a system failure. Furthermore, a caching mechanism ensures data consistency between the memory and the database. The fast response time and stable system performance ensure smooth and convenient user experience when using the instant messaging system, improving user satisfaction.

[0012] The above description is only an overview of the technical solution of the present disclosure. In order to more clearly understand the technical means of the present disclosure, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present disclosure more obvious and easy to understand, the following specifically cites preferred embodiments and describes them in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0014] Figure 1 A flowchart of a method for caching a session in an instant messaging system according to an embodiment of the present disclosure is provided.

[0015] Figure 2 A flowchart of a method for determining a target chat service node provided by an embodiment of the present disclosure is provided.

[0016] Figure 3A flowchart of a caching method provided by an embodiment of the present disclosure when a session initiation request is a request to change group member information.

[0017] Figure 4 A flowchart of a method for obtaining more information provided by an embodiment of the present disclosure.

[0018] Figure 5 A flowchart of a caching method when the ID of session information does not exist in the initial memory provided by an embodiment of the present disclosure.

[0019] Figure 6 A flowchart of a database and target memory caching method provided in an embodiment of the present disclosure.

[0020] Figure 7 A flowchart of a caching method provided by an embodiment of the present disclosure when the type of session initiation request is a single chat initiation request and it is the first initiation of a target session.

[0021] Figure 8 A schematic diagram of a group chat session pipeline method provided by an embodiment of the present disclosure when the type of the session initiation request is a group chat related type. Figure 9 A schematic diagram of caching session information for groups and group member changes provided in an embodiment of the present disclosure.

[0022] Figure 10 A schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0023] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.

[0024] Reference Figure 1 , the present application discloses a session caching method for an instant messaging system, comprising: S100: Receive a session initiation request.

[0025] The session initiation request includes the session initiator ID and the session recipient ID; the type of the session initiation request is a single chat initiation request, a group chat initiation request, a group member addition request, a group member withdrawal request, or a group member information change request.

[0026] In this embodiment, when the session initiation request is a single chat initiation request, the ID of the session information is p2p_{minUserID}_{maxUserID}, p2p is a point-to-point single chat session, {minUserId} is the ID of the two participating chat users with the smaller value, and {maxUserId} is the ID of the two participating chat users with the larger value; when the session initiation request is a group chat initiation request, the ID of the session information is g_{groupID}_{maxUserID}.i}; where groupID i The group ID that initiates the request, that is, the unique identifier of the group; when the session initiation request is a request to add a group member, the ID of the session information is g_{groupID j}; where groupID j The group ID of the initiator of the member adding request; when the session initiation request is a group member leaving request, the session information ID is g_{groupID k}; where groupID k The group ID of the initiator of the member's withdrawal request; when the session initiation request is a request to change group member information, the session information ID is g_{groupID p}; where groupID p The group ID that initiates the member information change request.

[0027] Specifically, when a user clicks "New Group Chat" on the instant messaging application interface or initiates a one-to-one chat with a contact, the application client will generate a session initiation request and send the request to the system's entry server; when the entry server receives this request, this step is completed. This step is the starting point of the entire session creation process and clarifies the system's triggering conditions. By receiving the request, the system can perceive the user's operation intention and thus start the subsequent session processing process.

[0028] S200, determining whether the session initiation request is the first initiation of a target session. If so, creating session information for the target session, performing a hash calculation on the ID of the session information, and determining a target chat service node based on the obtained hash value.

[0029] In this step, after receiving a session initiation request, the system first checks whether a record of the target session already exists in the database. If not, it is considered a first-time initiation. The system then generates unique session information for the target session, including a session ID, creation time, and session type. The session ID is a string. For example, for a new group chat session, the session ID can be a 32-bit random string automatically generated by the system. This session ID is then hashed, assuming the MD5 hash algorithm is used, to produce a fixed-length hash value. The system can pre-number multiple chat service nodes and take the hash value modulo the number of nodes. The node corresponding to the result is the target chat service node. For example, if there are five chat service nodes and the hash value modulo 5 is 3, then the chat service node numbered 3 is the target node.

[0030] Determining whether it is the first initiation can avoid duplicate creation of session information and improve system efficiency. Determining the target chat service node through hash calculation can achieve uniform distribution of sessions, avoid excessive load on a certain node, and improve the overall performance and stability of the system.

[0031] When the session initiation request type is a single chat initiation request, the session information includes one or more of the following: the single chat session ID, the single chat session ID hash value, the single chat session type, the single chat session last message ID, the single chat session name, the single chat mute status, and the single chat session user list.

[0032] When the type of the session initiation request is a group chat initiation request, the session information includes one or more of the group chat session ID, the group chat session ID hash value, the group chat session type, the group chat session last message ID, the group chat session name, the group chat muted status, the group chat group confidentiality level, and the group chat session user list.

[0033] S300: In response to the determined target chat service node, a session initiation request is sent to the target chat service node.

[0034] Specifically, after determining the target chat service node, the entry server forwards the session initiation request to that node. This can be accomplished using a network communication protocol, such as TCP. The entry server establishes a connection with the target chat service node and sends the request data encapsulated in a TCP packet. For example, the entry server queries the system's node mapping table to find the IP address and port number of the target chat service node. It then establishes a TCP connection and sends the request. This ensures that the session initiation request accurately reaches the node responsible for handling the session, ensuring correct request distribution and ensuring the normal operation of the system.

[0035] S400: Acquire the associated session information of the session initiation request and all session member information through the target chat service node, and cache them in the database and the target memory.

[0036] Caching information in the database can achieve data persistence and prevent data loss; while caching in memory can speed up data access and avoid reading data from the disk or database every time a session is processed, greatly shortening response time, reducing the response time of subsequent operations, and improving user experience.

[0037] S500: If the session initiation request is not the first initiation of the target session, determine the target ID of the session information corresponding to the session initiation request, query the corresponding associated session information and all session member information from the database according to the target ID, and load them into the target memory for caching.

[0038] For sessions that are not initiated for the first time, information is directly queried and cached from the database, avoiding repeated creation and calculation, improving the processing efficiency of the system, and memory cache can also speed up subsequent access to this information.

[0039] The instant messaging system session caching method disclosed in the present application creates session information for the target session, performs a hash calculation on the ID of the session information, determines a target chat service node based on the hash value, and sends the session initiation request to the target chat service node in response to the determined target chat service node. The target chat service node obtains the associated session information and all session member information of the session initiation request and caches the information in a database and a target memory. If the session initiation request is not the first initiation of the target session, the target ID of the session information corresponding to the session initiation request is determined, and the corresponding associated session information and all session member information are retrieved from a database based on the target ID and loaded into the target memory for caching. A hash calculation is used to achieve uniform distribution of sessions and avoid uneven node load. A memory caching technique is used to accelerate data access, reduce response time, and improve the overall processing capability of the system. The session information is cached in the database to ensure data persistence, preventing data loss even in the event of a system failure. Furthermore, a caching mechanism ensures data consistency between the memory and the database. The fast response time and stable system performance ensure smooth and convenient user experience when using the instant messaging system, improving user satisfaction.

[0040] Reference Figure 2 In S200, “performing a hash calculation on the ID of the session information and determining the target chat service node based on the obtained hash value”, the method for determining the target chat service node includes: A100 creates several virtual nodes according to the name of each service node in the instant messaging system.

[0041] In one specific embodiment, the system includes: 1) defining multiple IM service node names in the format of chat-node-n, where n is a positive integer; 2) creating N virtual nodes for each real node in the format of {chat-node-n}#VN-{0~(N-1)}. For example, for real node chat-node-3, the created virtual nodes may be VN-1, VN-2, and VN-3. In a clustered environment, a hash ring is maintained based on the service node names. The introduction of virtual nodes can more evenly distribute session requests. In a system, the processing power and load of different real nodes may vary. Directly using real nodes for hash calculations may result in some nodes being overloaded while others are underloaded. By creating virtual nodes, requests can be more evenly mapped to real nodes, improving overall system performance and stability.

[0042] A200 performs hash calculation on the name string of each virtual node and uses the calculation result as the position of the virtual node on the hash ring.

[0043] Specifically, it includes: associating the hash value with the virtual node name and caching it in an ordered data structure (such as TreeMap). In the prior art, under high concurrency, it is necessary to efficiently cache and search for the location information of the virtual node on the hash ring to ensure the accuracy and efficiency of routing. The method disclosed in this embodiment associates the hash value with the virtual node name and caches it in an ordered data structure. The ordered data structure facilitates fast search and positioning, which can improve the efficiency of the system in finding the location of the virtual node under high concurrency, thereby speeding up information routing and improving system performance. Furthermore, common hash functions such as MD5 or SHA-1 can be used to perform hash calculations on the name string of each virtual node.

[0044] Virtual nodes are mapped to a hash ring through hash calculation, providing a unified positioning method for each virtual node. In this way, when searching for the target node later, the corresponding virtual node can be quickly found according to the position on the hash ring. The positions on the hash ring are ordered, which facilitates comparison and search operations in subsequent steps, improving search efficiency.

[0045] A300 uses a preset hash function to perform hash calculation on the ID of the session information to obtain a target hash value.

[0046] Specifically, a pre-defined hash function, such as MD5 or SHA-1, can be used to calculate the session ID. Assuming the session ID is a 32-bit random string, the hash calculation yields a fixed-length hash value, which is converted to an integer. This integer serves as the target hash value. Hashing the session ID maps different session information to different locations on the hash ring. Due to the characteristics of hash functions, even if the session IDs are very similar, their hash values ​​can vary significantly, ensuring uniform distribution of session information on the hash ring. This helps improve the system's load balancing capabilities and prevents certain nodes from processing an excessive number of session requests.

[0047] A400, find the first virtual node on the hash ring that is not less than the target hash value and record it as the target virtual node.

[0048] This search method ensures that each session information can be assigned to a suitable virtual node, thereby ensuring the reasonable routing of session requests.

[0049] A500, determining the real node corresponding to the target virtual node, and using the real node as the target chat service node corresponding to the ID of the session information.

[0050] Among them, the target chat service node is the cache landing node, which ultimately routes the session request to the real chat service node so that the request can be actually processed; through the mapping relationship between virtual nodes and real nodes, the request can be accurately delivered to the appropriate node while ensuring load balancing, thereby improving the processing efficiency and reliability of the system.

[0051] A600: If no virtual node with a hash value not less than the target hash value is found on the hash ring, the real node corresponding to the first virtual node on the hash ring is used as the target chat service node corresponding to the ID of the session information.

[0052] This processing method ensures that no matter where the target hash value is located on the hash ring, the corresponding cache landing node can be found, forming a complete routing mechanism. In special circumstances (such as failing to find a virtual node with a hash value not less than the target hash value), it can also provide a reasonable solution to improve the system's fault tolerance.

[0053] In a cluster environment, no matter where the caller comes from, the same consistent hashing algorithm is used to calculate the cache drop point, and the cache drop point can be calculated quickly.

[0054] The method disclosed in this embodiment distributes data evenly on each service node by creating virtual nodes and hash rings, thereby achieving load balancing, avoiding the situation where some nodes are overloaded while other nodes are idle, and improving the overall performance of the system; the use of the consistent hashing algorithm means that only a small amount of data needs to be migrated when a service node is added or deleted, reducing the impact on the system and improving the stability and scalability of the system; it can quickly and accurately find the cache landing node corresponding to the target information, improve the access efficiency of the cache, and thereby improve the response speed and performance of the entire instant messaging system.

[0055] In the prior art, when there is high concurrency, it is necessary to efficiently route information to the appropriate node for processing. Traditional routing methods may lead to unbalanced node load or poor performance. The method disclosed in this embodiment creates a virtual node, hashes the virtual node name and determines its position on the hash ring, hashes the target information, finds the appropriate virtual node on the hash ring, and then determines the corresponding real node as the cache landing node. This routing method of the consistent hash algorithm can minimize the amount of data migration when the system adds or reduces nodes, ensuring the stability and efficiency of the system and avoiding performance problems caused by unbalanced node load.

[0056] Reference Figure 3 When the session initiation request is a request to change group member information, the caching method for "determining the target ID of the session information corresponding to the session initiation request, querying the corresponding associated session information and all session member information from the database according to the target ID, and loading them into the target memory for caching" in S500, that is, when the session initiation request is a request to change group member information, includes: B100, in response to the group member information change request, calls the event notification middleware to monitor and obtain the change information.

[0057] When a user initiates a group member information change request in an instant messaging system, such as removing a member from a group chat or adding a new member, the system receives the request and invokes the event notification middleware, which begins listening for relevant change events. Once group member information changes, it captures detailed information, such as the ID of the removed member and the information of the newly added member. The event notification middleware efficiently captures and transmits change information, separating information acquisition from business processing, making the system architecture clearer and more flexible. Furthermore, the middleware's asynchronous nature improves system responsiveness, avoids blocking when processing change requests, and enables the system to handle multiple requests simultaneously.

[0058] Specific reference Figure 4 , the methods for obtaining change information include: B110, in response to the group member information change request, encapsulates the change event into a message and sends it to the specified topic of Kafka.

[0059] Imagine a user in an instant messaging system initiates a group membership change request to add user "Alice" to the group "TechTalk." Upon receiving this request, the system encapsulates this change event (adding "Alice" to the "TechTalk" group) into a message. This message may include key information such as the change type (adding a member), the group ID (the unique identifier for "TechTalk"), and the member ID (the unique identifier for "Alice"). This encapsulated message is then sent to a pre-defined Kafka topic, such as "GroupMemberChange." Encapsulating change events into messages and sending them to a Kafka topic decouples the system component initiating the change request (the producer) from the component processing the change information (the consumer). Producers simply send messages to the topic without worrying about who consumes them. Consumers simply subscribe to messages from the topic, independent of a specific producer.

[0060] B120 obtains the change information by subscribing to the server in the chat service cluster that subscribes to the corresponding topic message in Kafka.

[0061] Servers in the chat service cluster subscribe to the "GroupMemberChange" topic in Kafka. When new group member information change messages are sent to this topic, subscribed servers receive these messages. For example, after receiving a message adding "Alice" to the "TechTalk" group, a server can update the group member information in its local cache or database based on the information in the message. Multiple servers in the chat service cluster can simultaneously subscribe to Kafka topics, enabling distributed processing of change information. Each server can independently process received messages, improving the system's overall processing power and concurrency.

[0062] B200, updates the cache information in the database according to the change information.

[0063] For example, if the change is to remove user A from group G, the system will use this information to find group G's member information records in the corresponding table in the database and delete user A's related records. If a new member, user B, is added to group G, user B's related records in group G will be inserted into the database to ensure that the group member information in the database is up to date. The database is a persistent cache of data, and timely updating of cached information in the database ensures data consistency and integrity. This ensures that accurate group member information can be obtained in subsequent queries and operations, avoiding errors caused by data inconsistencies.

[0064] B300, randomly selects the target memory corresponding to a node from all the nodes in the instant messaging system and records it as the initial memory.

[0065] There are multiple nodes in an instant messaging system, each with its own memory for caching data. The system randomly selects one of these nodes, such as node N3, whose corresponding memory is the initial memory. Randomly selecting the initial memory prevents all change information from being concentrated on a single node, achieving a certain degree of load balancing. This allows each node to participate in the cache update process, preventing a single node from becoming a performance bottleneck due to processing too many cache update requests.

[0066] B400: Determine whether the session information ID corresponding to the group member information change request exists in the initial memory. If so, update the cache information in the initial memory according to the change information.

[0067] The selected initial memory is searched for the session information ID of the group involved in the group member information change request. For example, if the group member information of Group G changes, the initial memory is checked to see if Group G's session information ID exists. If so, the cached data in the initial memory is updated based on the previously acquired change information (such as removing User A or adding User B) to ensure that the group member information in the initial memory is consistent with the database. By checking the initial memory for the corresponding session information ID, unnecessary cache updates can be avoided. If the initial memory does not contain relevant information, no update is required, reducing the system's processing overhead. At the same time, timely updating the cached data in the initial memory can improve the response speed to subsequent queries for the group information.

[0068] B500, if not, calls the server in the chat service cluster that subscribes to the corresponding topic message in the event notification middleware to send a broadcast call request and change information to other nodes in the cluster; other node servers that receive the broadcast call request update the cache data in the corresponding target memory according to the change information.

[0069] If the session ID corresponding to the group member information change request doesn't exist in the initial memory, the system calls a server in the chat service cluster that has subscribed to the change topic message, such as server S1. Server S1 then sends a broadcast call request to other nodes in the cluster (such as S2, S3, and S4), along with the change information (for example, removing user A or adding user B). Upon receiving the broadcast call request, the other nodes update their cached data in target memory based on the change information. This broadcast call ensures that cached data in target memory is updated promptly on all nodes in the cluster. This ensures that users, regardless of which node they access group member information from, always receive the latest content, improving system consistency and availability.

[0070] The solution disclosed in this embodiment ensures data consistency across the entire system through steps such as Kafka messaging, database updates, and cache synchronization. Both the database and the local cache of each node can promptly reflect the latest changes. By leveraging Kafka's decoupling and broadcast call mechanism, the system can easily expand server nodes while still ensuring normal system operation when some nodes fail. Through caching mechanisms and asynchronous message processing, the system's query efficiency and processing speed are improved, providing users with a better user experience. This synchronization method can effectively resolve data consistency issues when programs are deployed in a cluster environment using memory cache.

[0071] In the prior art, when session information changes under high concurrency, timely synchronization of information is required. Traditional information synchronization methods can lead to data inconsistencies and performance issues. The method disclosed in this embodiment encapsulates change events into messages and sends them to a designated Kafka topic. Servers subscribed to the topic messages obtain the change information, first modifying the corresponding information in the database, then updating the local session cache data as needed, and simultaneously broadcasting the change information to other nodes in the cluster. Kafka is a high-performance message queue that can efficiently process large numbers of messages. This method ensures timely synchronization of information changes, avoids data inconsistencies, reduces frequent reads and writes to the database, and improves system performance.

[0072] Reference Figure 5 When the session information ID does not exist in the initial memory, the cache method also includes: C100 determines the group ID from the change information, performs hash calculation on the group ID using a preset hash function, and obtains a target hash value.

[0073] Suppose the change adds user "Bob" to the group "MusicLovers." The group ID, such as "G007," is extracted from this change. Then, using a pre-defined hash function (such as MurmurHash), "G007" is hashed to a fixed-length target hash value, assuming the result is "123456789." Hashing maps the group ID to a uniform range of hash values, facilitating subsequent lookups on the hash ring. After hashing, different group IDs are evenly distributed on the hash ring, providing a basis for subsequent node selection, preventing data from concentrating on a few nodes and achieving load balancing.

[0074] C200, find the first virtual node on the hash ring that is not less than the target hash value and record it as the target virtual node.

[0075] The hash ring is a virtual ring with many virtual nodes distributed on it. These virtual nodes correspond to real nodes in the system. Suppose the hash values ​​of the virtual nodes on the hash ring are "100000000," "150000000," "2000000000," and so on. Since the target hash value is "123456789," the first virtual node with a hash value not less than "150000000" is the target virtual node. By searching the target virtual node on the hash ring, the cache location can be determined based on the hash value. This method makes the cache more evenly distributed. When system nodes change, only the cache location of some data needs to be adjusted, reducing the overhead of data migration.

[0076] C300, determining the real node corresponding to the target virtual node, taking the real node as the target chat service node corresponding to the ID of the session information, and updating the cache information in the target cache corresponding to the target chat service node according to the change information.

[0077] Each virtual node corresponds to a real chat service node. Assuming the target virtual node "150000000" corresponds to node "S003," node "S003" is used as the cache location for the "MusicLovers" group session information. The group member information in the target cache corresponding to node "S003" is then updated based on the change information, adding the relevant record to the cache. This step identifies the specific cache node and ensures that the change information is accurately updated in the corresponding cache. Subsequent queries for group member information can quickly locate the node that cached the information, improving query efficiency.

[0078] C400, if no virtual node with a hash value not less than the target is found on the hash ring, the real node corresponding to the first virtual node on the hash ring is used as the target chat service node corresponding to the ID of the session information, and the cache information in the target cache corresponding to the target chat service node is updated according to the change information.

[0079] Suppose the virtual node hash values ​​on the hash ring are "200000000," "250000000," "3000000000," and so on, while the target hash value is "350000000." No virtual node on the hash ring can find a value equal to or greater than this value. In this case, the real node corresponding to the first virtual node on the hash ring (with a hash value of "200000000"), for example, node "S001," is used as the cache drop point for the "MusicLovers" group session information. The group member information in the target cache corresponding to node "S001" is then updated based on the change information. This approach handles edge cases, ensuring that a suitable cache drop point can be found regardless of the target hash value, ensuring system robustness and integrity, and preventing cache failures due to special circumstances.

[0080] The method disclosed by C100-C400 evenly distributes the session information of different groups to each real node through hash calculation and hash ring, avoiding a node becoming a performance bottleneck due to taking on too many caching tasks, and improving the overall processing capability of the system; when the system needs to add or remove nodes, it only needs to readjust the mapping relationship between some virtual nodes and real nodes without the need for large-scale data migration. This method enables the system to be easily expanded to adapt to business growth; each group's session information has a clear cache landing node, ensuring that the change information can be accurately updated to the corresponding cache, so that the cache data of each node remains consistent, improving the reliability of the system and the accuracy of the data.

[0081] Reference Figure 6 The method of S400, "obtaining the associated session information of the session initiation request and all session member information through the target chat service node and caching them in the database and target memory," is a caching method of the database and target memory, specifically including: S410: Determine the associated session information of the session initiation request, where the associated session information includes the ID of the session information, the maximum message ID of the current session, the last sending time, and the last ten message information.

[0082] Suppose a user initiates a group chat request in an instant messaging app, requesting to join a session named "Outdoor Sports Enthusiasts Group." Upon receiving this request, the system searches for information related to the session. Assume the session ID is "G001," uniquely identifying the group chat session. The maximum message ID for the current session is "M100," representing the number of the most recent message in the session. The last sent time is "2025-05-26 11:28:00." The last ten messages contain the specific content, sender, and other information for messages with IDs "M91" through "M100." Clearly associating session information provides a comprehensive and accurate data foundation for subsequent caching and use. The session ID uniquely identifies the session, facilitating system management and search. The maximum message ID helps quickly locate the latest message, facilitating message synchronization and updates. The last sent time allows users to understand the session's activity level. The last ten messages allow new users to quickly understand recent discussions.

[0083] S420: Cache the session information ID, the maximum message ID of the current session, the last sending time, and all session member information into a database.

[0084] The session ID uniquely identifies the session and distinguishes different sessions in the database. It is crucial for subsequent queries and associated operations. The maximum message ID of the current session helps track the latest status of messages in the session and serves as a crucial reference when synchronizing messages or retrieving the latest messages. The last sent time reflects the session's activity level, facilitating operations such as sorting and filtering sessions, such as displaying the most recently active sessions. All session member information, including basic member information, is a crucial component of the session and is crucial for managing session participants and permissions.

[0085] S430: Cache the session information ID, the maximum message ID of the current session, the last sending time, the last ten messages, and all session member information into the target memory.

[0086] In S430, in addition to the information stored in the aforementioned database, the last ten messages are also stored in the target memory. The primary purpose of target memory (e.g., cache) is to provide fast response and improve system performance, storing frequently accessed data with high timeliness requirements. The last ten messages represent the most recent messages that users are most interested in when entering a session. Storing this information in memory allows the latest messages to be quickly presented when users access the session, reducing wait time and improving the user experience.

[0087] Furthermore, a method for determining the session type corresponding to the session initiation request specifically includes: S101: Obtaining a session ID associated with an information sending request.

[0088] In instant messaging systems, when a user initiates a message request, it typically carries key information, including the associated session ID. For example, if user A wants to send a message to user B, after user A clicks the send button, the client encapsulates the message request with the associated session ID (e.g., p2p_A_B) and transmits it to the server. Upon receiving this message request, the server parses the request packet and extracts the associated session ID. Similarly, if user A sends a message in group G1, the associated session ID carried in the message request is g_G1, and the server retrieves this ID in the same manner.

[0089] The associated session ID is key information for identifying a session. Obtaining it allows the system to directly locate a specific session, avoiding interference from other irrelevant information when processing information sending requests, making subsequent processing more targeted. Performing subsequent operations based on the associated session ID can simplify the complex information sending request processing process into a series of operations centered around the ID, thereby improving processing efficiency.

[0090] S102, when the associated session ID includes two IDs, determining the session type as a single chat session; When the associated session IDs include at least three IDs, the session type is determined to be a group chat session.

[0091] When the associated session ID obtained contains two IDs, it can be determined to be a single chat session. For example, if the associated session ID is p2p_A_B, where A and B represent the IDs of two users, this indicates a single chat session between A and B. Once the system recognizes that the IDs consist of two user identifiers, it will mark the session type corresponding to the information sent as a single chat session. If the associated session ID contains at least three IDs, it is determined to be a group chat session. Determining the session type based on the number of IDs contained in the associated session ID is a simple and intuitive method that does not require complex logic or extensive calculations. It can accurately distinguish between single and group chat sessions in a short time, improving system processing speed. This determination method does not rely on specific business rules or additional identification information and is applicable as long as the associated session ID is designed to include user identifiers, making it highly versatile and adaptable.

[0092] In this embodiment, accurately distinguishing between single chat and group chat session types is the basis for subsequent information processing. Different types of sessions may differ in message delivery, permission management, notification mechanisms, etc. Determining the session type in this way can ensure that the system processes information sending requests according to the correct rules and avoids information processing errors caused by incorrect session type judgment. The processing methods and resource requirements of single chat and group chat sessions are different. The system can reasonably allocate resources based on the determined session type. For example, for group chat sessions, more bandwidth and computing resources are required to process message broadcasting and synchronization, while for single chat sessions, relatively fewer are required. This can improve the utilization efficiency of system resources and reduce operating costs. Accurate session type judgment can ensure that messages are delivered and processed in the expected manner. Users can obtain a smooth and accurate communication experience in both single chat and group chat, and will not encounter problems such as message sending errors or notification anomalies, thereby improving user satisfaction with the instant messaging system.

[0093] In existing technologies, under high concurrency, the system needs to accurately distinguish between individual and group chat sessions to correctly process messages. Frequent database queries to determine session types can affect performance. The solution disclosed in this embodiment obtains the session ID associated with the message sending request and determines the session type based on the number of IDs. This method is simple and direct, and the session ID information cached in memory can be quickly retrieved, eliminating the need for frequent database queries. This improves the efficiency of session type determination and thus enhances overall system performance.

[0094] Reference Figure 7 When the session initiation request type is a single chat initiation request and it is the first initiation of the target session, the caching method includes: 1) The caller creates session information for the target session based on the received chat session initiation request between users U1 and U2. The created session information includes a single chat session with the ID p2p_U1_U2, where U1 is the smaller ID of the two participating chat users and U2 is the larger ID of the two participating chat users. Consistent hash routing is performed based on the session information ID to the server's S1 node (i.e., chat service 1). Specifically, a hash calculation is performed on the session information ID, and the target chat service node, i.e., S1, is determined based on the obtained hash value. In response to the determined target chat service node, a session initiation request is sent to the target chat service node, i.e., S1. 2) Obtain the associated session information and all session member information of the session initiation request through the target chat service node, and cache them in the database and target memory respectively. Specifically, store the p2p_U1_U2 session information, U1 session member information, and U2 session member information in the database, and cache the p2p_U1_U2 session information, U1 session member information, and U2 session member information through CaffeineCache.

[0095] Reference Figure 8 When the type of session initiation request is group chat related, the group chat session pipeline method includes: 1) Based on the received session initiation request from `U1` to create group `G1`, the caller creates session information for the target session. This session information is a group chat session with an ID of `g_G1`. Consistent hash routing is performed based on the session information ID to the server's S2 node (i.e., chat service 2). Specifically, a hash calculation is performed on the session information ID, and the target chat service node, i.e., S2, is determined based on the hash value. In response to the determined target chat service node, the caller sends the session initiation request to the target chat service node, i.e., S2. 2) Obtain the associated session information and all session member information of the session initiation request through the target chat service node, and cache them in the database and target memory respectively. Specifically, store the `g_G1` session information and U1 session member information in the database, and cache the `g_G1` session information and U1 session member information through CaffeineCache; after the task of caching the data in the database and target memory is completed, feedback on the completion of group chat creation can be fed back to the caller.

[0096] 3) When the received session initiation request is a session initiation request for `Un` to join group `G1`, since the group already exists, it means that this request is not the first initiation of the target session; the ID of the session information corresponding to this request is `g_G1`, then it is routed to the server's S2 node (i.e., chat service 2) based on the consistent hash of `g_G1`; the specific caching tasks include: caching the `Un` session member information in the database, determining the target ID of the session information corresponding to the session initiation request (i.e., `g_G1`), querying the database for the corresponding associated session information and all session member information (including the `Un` session member information), and loading them into the target memory for caching; after the task of caching the data in the database and the target memory is completed, feedback can be given to the caller indicating that the group member addition is complete.

[0097] 4) When the received session initiation request is a session initiation request for `Un` to exit group `G1`, since the group already exists, it means that this request is not the first initiation of the target session; the ID of the session information corresponding to the request is `g_G1`, then it is routed to the server's S2 node (i.e., chat service 2) based on the consistent hash of `g_G1`; the specific caching tasks include: deleting the `Un` session member information from the database, determining the target ID of the session information corresponding to the session initiation request (i.e., `g_G1`), querying the corresponding associated session information and all session member information (excluding the `Un` session member information) from the database, and loading them into the target memory for caching, or querying the corresponding associated session information from the database and loading them into the target memory for caching, and deleting the `Un` session member information from the target memory; after the task of caching the data in the database and the target memory is completed, feedback on the completion of group member deletion can be sent to the caller.

[0098] Reference Figure 9 ,The figure shows a schematic diagram of caching session information when groups and ,group members change.

[0099] 1) The caller initiates a request based on the received group `G1` signal and the session indicating the group member information change, pushing the change event to Kafka. This means encapsulating the change event into a message and sending it to the specified Kafka topic. 2) Calling the event notification middleware (preferably Kafka in this embodiment) to monitor and obtain the change information from the servers in the chat service cluster that subscribe to the corresponding topic message in Kafka, that is, one of the servers in the chat service cluster consumes the change event; 3) Update the cached information in the database according to the change information. For example, when the change information is to modify the `G1` session information or session member information, the cached information in the database is updated accordingly; 4) Then, a target memory corresponding to a node is randomly selected from all nodes in the instant messaging system and recorded as the initial memory. If the node corresponding to the initial memory is S1, it is determined whether the session information ID corresponding to the group member information change request exists in the memory corresponding to S1. If so, the cached information in the initial memory is updated according to the change information; 5) If not, the server in the chat service cluster that calls the corresponding topic message in the subscription event notification middleware sends a broadcast call request and change information to other nodes in the cluster; the other node servers that receive the broadcast call request update the cached data in the corresponding target memory according to the change information. For example, after node S2 receives the broadcast information, it determines whether the session information ID corresponding to the group member information change request exists in the memory corresponding to S2. If so, the cached information in the initial memory is updated according to the change information.

[0100] In this application, by introducing an efficient caching mechanism, the speed of message sending and receiving is improved, and the real-time notification function is realized, allowing users to receive new messages in a timely manner. The session and session user are used as basic data to complete the message sending related actions, effectively simplifying the message sending process and improving operational efficiency.

[0101] Initially, there's only one service node, chat-node-1, in the environment. All calls are routed to this node, eliminating node selection. This node maintains two types of session caches: group session caches (e.g., g_1, g_2, g_n) and peer-to-peer session caches (e.g., p2p_1_2, p2p_1_3, p2p_n_m). It also monitors the addition and removal of service nodes.

[0102] When chat-node-2 is added, the hash ring and cache placement need to be recalculated. The hash ring is a distributed hashing algorithm used to determine which node should cache data. After the recalculation, some session cache data originally on chat-node-1 may no longer belong to that node. Therefore, chat-node-1 will clear these session caches that do not belong to it, such as g_3, g_4, g_5, p2p_2_3, p2p_3_4, etc. These cleared session caches will be allocated to the new node chat-node-2 for caching. At the same time, the new node chat-node-2 will also begin to monitor the addition and deletion of service nodes.

[0103] When chat-node-3 is added again, the hash ring and cache placement also need to be recalculated. The existing chat-node-1 and chat-node-2 nodes will recalculate the currently cached session data and clear any session cache data that does not belong to their nodes. For example, chat-node-1 will delete sessions such as g_2 and p2p_1_3, and chat-node-2 will delete sessions such as g_5 and p2p_3_4. These cleared session caches will be assigned to the new node, chat-node-3. The new node, chat-node-3, will also begin monitoring the addition and deletion of service nodes.

[0104] When the node chat-node-2 is deleted, according to the characteristics of the Hash ring, the cache on the remaining nodes will not be reduced but will only be expanded. This is because the session cache originally cached on chat-node-2 will be redistributed to other nodes according to the new Hash ring, while the cache data originally on chat-node-1 and chat-node-3 will not be affected. Therefore, there is no need to refresh the old cache. You only need to continue to monitor the addition and deletion of service nodes.

[0105] The entire process achieves dynamic allocation and management of session cache by dynamically adjusting nodes and recalculating the Hash ring, ensuring efficient handling of session cache migration and caching when nodes change, improving the scalability and stability of the system; at the same time, by utilizing the characteristics of the Hash ring, unnecessary cache refresh operations are avoided when nodes are deleted, reducing system overhead.

[0106] This embodiment also includes a user cache expiration policy. Specifically, the user cache expiration policy includes a default active time of 12 hours and a default maximum cache time of 72 hours, which can be modified through the configuration file. This solution provides flexibility, allowing administrators or developers to adjust these two time parameters based on actual needs. They can change the default active time and maximum cache time by editing the corresponding settings in the configuration file to adapt to different business scenarios and performance requirements.

[0107] In a second aspect, the present application discloses an instant messaging system session caching system, which is used to execute the instant messaging system session caching method disclosed in the first aspect of the present application, including: A request receiving module, used for receiving a session initiation request; A target chat service node determination module is used to determine whether the session initiation request is the first initiation of the target session. If so, it creates session information for the target session, performs a hash calculation on the ID of the session information, and determines the target chat service node based on the hash value obtained; a routing module, configured to send the session initiation request to the target chat service node in response to the determined target chat service node; A first cache module is used to obtain the associated session information of the session initiation request and all session member information through the target chat service node, and cache them in the database and the target memory; The second cache module is used to determine the target ID of the session information corresponding to the session initiation request if the session initiation request is not the first initiation of the target session, query the corresponding associated session information and all session member information from the database according to the target ID, and load them into the target memory for caching.

[0108] A computer device according to an embodiment of the present disclosure includes a memory and a processor. The memory is used to store non-transitory computer-readable instructions. Specifically, the memory may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory. The non-volatile memory may include, for example, read-only memory (ROM), a hard disk, flash memory, etc.

[0109] The processor can be a central processing unit (CPU) or other form of processing unit with data processing capabilities and / or instruction execution capabilities, and can control other components in the computer device to perform desired functions. In one embodiment of the present disclosure, the processor is used to execute the computer-readable instructions stored in the memory, causing the computer device to execute all or part of the steps of the instant messaging system session caching method described in each embodiment of the present disclosure.

[0110] Those skilled in the art should understand that in order to solve the technical problem of how to obtain a good user experience, this embodiment may also include well-known structures such as a communication bus and an interface, and these well-known structures should also be included in the scope of protection of this disclosure.

[0111] like Figure 10 The present invention provides a schematic diagram of the structure of a computer device according to an embodiment of the present invention. Figure 10 The computer device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.

[0112] like Figure 10 As shown, a computer device may include a processor (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in a read-only memory (ROM) or programs loaded from a storage device into a random access memory (RAM). The RAM also stores various programs and data required for the operation of the computer device. The processor, ROM, and RAM are connected to each other via a bus. An input / output (I / O) interface is also connected to the bus.

[0113] Typically, the following devices can be connected to the I / O interface: input devices such as sensors or visual information acquisition devices; output devices such as display screens; storage devices such as tapes and hard disks; and communication devices. The communication device can allow the computer device to communicate with other devices (such as edge computing devices) wirelessly or by wire to exchange data. Figure 10 A computer device having various devices is shown, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.

[0114] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processor, all or part of the steps of the instant messaging system session caching method of the embodiment of the present disclosure are executed.

[0115] For detailed description of this embodiment, please refer to the corresponding description in the aforementioned embodiments, which will not be repeated here.

[0116] According to the computer-readable storage medium of the embodiment of the present disclosure, non-transitory computer-readable instructions are stored thereon. When the non-transitory computer-readable instructions are executed by a processor, all or part of the steps of the instant messaging system session caching method of each embodiment of the present disclosure are executed.

[0117] The above-mentioned computer-readable storage media include, but are not limited to, optical storage media (e.g., CD-ROMs and DVDs), magneto-optical storage media (e.g., MOs), magnetic storage media (e.g., magnetic tapes or mobile hard disks), media with built-in rewritable non-volatile memory (e.g., memory cards), and media with built-in ROM (e.g., ROM cartridges).

[0118] For detailed description of this embodiment, please refer to the corresponding description in the aforementioned embodiments, which will not be repeated here.

[0119] The basic principles of the present disclosure have been described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, and effects mentioned in this disclosure are merely illustrative and not restrictive, and should not be construed as necessarily possessed by each embodiment of the present disclosure. Furthermore, the specific details disclosed above are provided for illustrative purposes and to facilitate understanding, rather than as limitations. These details do not limit the present disclosure to necessarily being implemented using these specific details.

[0120] In the present disclosure, relational terms such as first and second, etc. are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. The block diagrams of the devices, devices, equipment, and systems involved in the present disclosure are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, devices, equipment, and systems can be connected, arranged, or configured in any manner. Words such as "including," "comprising," "having," and the like are open-ended words, meaning "including but not limited to," and can be used interchangeably therewith. The words "or" and "and" used herein refer to the words "and / or" and can be used interchangeably therewith, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to," and can be used interchangeably therewith.

[0121] Additionally, as used herein, "or" used in a list of items beginning with "at least one" indicates a separate list, so that, for example, a list of "at least one of A, B, or C" means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word "exemplary" does not mean that the example described is preferred or better than other examples.

[0122] It should also be noted that in the system and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.

[0123] Various changes, substitutions, and modifications may be made to the technology described herein without departing from the teachings defined by the appended claims. Moreover, the scope of the claims of this disclosure is not limited to the specific aspects of the processes, machines, manufactures, compositions of things, means, methods, and actions described above. Currently existing or later developed processes, machines, manufactures, compositions of things, means, methods, or actions that perform substantially the same function or achieve substantially the same results as the corresponding aspects described herein may be utilized. Accordingly, the appended claims include within their scope such processes, machines, manufactures, compositions of things, means, methods, or actions.

[0124] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but rather to be accorded the widest scope consistent with the principles and novel features disclosed herein.

[0125] The above description has been provided for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although a number of example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.

Claims

1. A method for caching a session in an instant messaging system, characterized in that: include: Receive a session initiation request; Determine whether the session initiation request is the first initiation of a target session. If so, create session information for the target session, perform a hash calculation on the ID of the session information, and determine a target chat service node based on the obtained hash value; In response to the determined target chat service node, sending the session initiation request to the target chat service node; Obtaining the associated session information of the session initiation request and all session member information through the target chat service node, and caching them in a database and a target memory; If the session initiation request is not the first initiation of the target session, determine the target ID of the session information corresponding to the session initiation request, query the corresponding associated session information and all session member information from the database according to the target ID, and load them into the target memory for caching.

2. The instant messaging system session caching method according to claim 1, characterized in that: The performing hash calculation on the ID of the session information and determining the target chat service node according to the obtained hash value includes: Create several virtual nodes according to the name of each service node in the instant messaging system; Performing hash calculation on the name string of each virtual node, and using the calculation result as the position of the virtual node on the hash ring; Perform hash calculation on the session information ID using a preset hash function to obtain a target hash value; Find the first virtual node on the hash ring that has a hash value no less than the target hash value, and record it as the target virtual node; Determine the real node corresponding to the target virtual node, and use the real node as the target chat service node corresponding to the ID of the session information; If no virtual node with a value not less than the target hash value is found on the hash ring, the real node corresponding to the first virtual node on the hash ring is used as the target chat service node corresponding to the ID of the session information.

3. The instant messaging system session caching method according to claim 2, characterized in that: The session initiation request includes a session initiator ID and a session recipient ID; The session initiation request is a single chat initiation request, a group chat initiation request, a group member addition request, a group member withdrawal request, or a group member information change request.

4. The instant messaging system session caching method according to claim 3, characterized in that: When the session initiation request is a request to change group member information, determining a target ID of the session information corresponding to the session initiation request, querying the corresponding associated session information and all session member information from a database according to the target ID, and loading the information into a target memory for caching, includes: In response to the group member information change request, calling the event notification middleware to monitor and obtain the change information; Update the cache information in the database according to the change information; Randomly select a target memory corresponding to a node from all nodes in the instant messaging system and record it as the initial memory; Determine whether the session information ID corresponding to the group member information change request exists in the initial memory, and if so, update the cache information in the initial memory according to the change information; If not, the server in the chat service cluster that calls the corresponding topic message in the subscription event notification middleware sends a broadcast call request and change information to other nodes in the cluster; other node servers that receive the broadcast call request update the cache data in the corresponding target memory according to the change information.

5. The instant messaging system session caching method according to claim 4, characterized in that: In response to the group member information change request, calling the event notification middleware to monitor and obtain the change information includes: In response to the group member information change request, encapsulate the change event into a message and send it to the specified topic of Kafka; The change information is obtained by subscribing to the corresponding topic message in Kafka to the server in the chat service cluster.

6. The instant messaging system session caching method according to claim 4, characterized in that: When the ID of the session information does not exist in the initial memory, the method further includes: Determine a group ID from the change information, and perform hash calculation on the group ID using a preset hash function to obtain a target hash value; Find the first virtual node on the hash ring that has a hash value no less than the target hash value, and record it as the target virtual node; Determine a real node corresponding to the target virtual node, use the real node as the target chat service node corresponding to the ID of the session information, and update cache information in a target cache corresponding to the target chat service node according to the change information; If no virtual node with a hash value not less than the target hash value is found on the hash ring, the real node corresponding to the first virtual node on the hash ring is used as the target chat service node corresponding to the ID of the session information, and the cache information in the target cache corresponding to the target chat service node is updated according to the change information.

7. The instant messaging system session caching method according to claim 3, characterized in that: The step of obtaining the associated session information of the session initiation request and all session member information through the target chat service node and caching them in a database and a target memory includes: Determine the associated session information of the session initiation request, wherein the associated session information includes the session information ID, the maximum message ID of the current session, the last sending time, and the last ten message information; Cache the session information ID, the maximum message ID of the current session, the last sending time, and all session member information into the database; The session information ID, the maximum message ID of the current session, the last sending time, the last ten messages, and all session member information are cached in the target memory.

8. A computer device, characterized in that: The computer device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the instant messaging system session caching method according to any one of claims 1 to 7.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the instant messaging system session caching method according to any one of claims 1 to 7.

10. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.