UPF high availability method and device based on Redis, equipment and medium
By adopting a high availability method based on Redis in the UPF system, using lock acquisition policy and service instance switching mechanism, the problem that UPF system is difficult to ensure high availability when facing burst traffic shocks or failures is solved, and more efficient and reliable service recovery is achieved.
Patent Information
- Application Number
- CN202510009022.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-03
- Publication Date
- 2025-06-06
- Estimated Expiration
- 2045-01-03
AI Technical Summary
In 5G networks, when UPF systems face burst traffic shocks or software and hardware failures, it is difficult to ensure high availability and rapid recovery of services. In particular, traditional relational databases store session information, it is difficult to cope with large-scale concurrent requests, affecting overall performance.
Using Redis-based high availability method, we can use the lock acquisition policy, service instances to compete to acquire locks, and switch active and backup instances according to the lock status to achieve high availability of services.
Improves the efficiency and reliability of the UPF system, ensures that services can be quickly restored in emergencies, and avoids system crashes caused by single point of failure.
Smart Images

Figure CN120111543A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of high-availability storage technology, and in particular to a Redis-based UPF high-availability method, device, equipment and medium. Background Art
[0002] With the development of 5G networks, the requirements for key infrastructure such as UPF are getting higher and higher. UPF (User Plane Function) is a key component in the 5G core network architecture and is defined in the 3GPP standard. It is mainly responsible for handling the transmission of user data, routing selection, and the execution of related policies to ensure that the mobile network can efficiently provide users with Internet connections and other data services. Especially in the face of sudden traffic shocks or software and hardware failures, how to ensure the high availability of the system and quickly restore services has become a major challenge. At present, the more common deployment method of UPF is "one master and one backup". Usually only the primary node is working, and the backup node is idle. It uses traditional relational databases to store session information, which makes it difficult to cope with large-scale concurrent requests and affects overall performance. Summary of the invention
[0003] In view of this, the present invention provides a Redis-based UPF high-availability method, apparatus, device and medium to improve the efficiency and reliability of UPF.
[0004] In the first aspect, the present invention provides a high-availability method for implementing UPF based on Redis, the method comprising: determining a lock acquisition strategy; the lock acquisition strategy includes a lock period, a lock competition rule and a preset number of locks; obtaining the lock corresponding to each service instance from the Redis server according to the lock competition rule; marking the service instances that have obtained a preset number of locks as active instances, and assigning corresponding business processing tasks, and marking the service instances that have not obtained a preset number of standby instances as standby instances; each active instance updates the lock status to the Redis server according to a specified period; if the active instance exceeds the lock period, switching the standby instance to a new active instance.
[0005] The method of realizing UPF high availability based on Redis provided by the present invention realizes high availability of services by defining lock acquisition policies, competing for service instances to acquire locks, and switching active and standby instances according to lock status, thereby improving the efficiency and reliability of UPF.
[0006] In an optional implementation, the lock acquisition strategy further includes a lock name, and the method further includes: based on the lock name, assigning a corresponding unique identifier to the lock of the Redis server.
[0007] In an optional implementation, the lock corresponding to each service instance is obtained from the Redis server according to the lock competition rules, including: setting a preset acquisition time for lock acquisition; if the service instance fails to successfully acquire the lock corresponding to the candidate service instance within the preset acquisition time, then stopping the operation of acquiring the lock corresponding to the candidate service instance.
[0008] In an optional implementation, after allocating the corresponding business processing task, the method further includes: serializing the session data of the business processing task and sending it to the Redis server.
[0009] In an optional implementation, the method further includes: the standby instance subscribing to a specific channel of the Redis server; based on the specific channel, the standby instance receiving and saving the deserialized session data.
[0010] In an optional implementation, if the active instance exceeds the lock period, the standby instance is switched to be the new active instance, including: if the active instance fails to send a refresh request within the lock period, the lock corresponding to the active instance is released and downgraded to a new standby instance; a target instance is selected in the standby instance, and the lock corresponding to the target instance is obtained from the Redis server to switch the target instance to the new active instance.
[0011] In an optional embodiment, the method further includes: if the active instance is marked as an internal abnormal state, restarting the active instance and downgrading the active instance to a new standby instance; if the active instance stops after receiving an external instruction, downgrading the active instance to a new standby instance.
[0012] In the second aspect, the present invention provides a high-availability device for implementing UPF based on Redis, and the device includes: a strategy determination module, which is used to determine the lock acquisition strategy; the lock acquisition strategy includes a lock period, a lock competition rule and a preset number of locks; a lock acquisition module, which is used to obtain the locks corresponding to each service instance from the Redis server according to the lock competition rule; an instance marking module, which is used to mark the service instances that have obtained a preset number of locks as active instances, and assign corresponding business processing tasks, and mark the service instances that have not obtained a preset number of standby instances as standby instances; each active instance updates the lock status to the Redis server according to a specified period; an instance switching module, which is used to switch the standby instance to a new active instance if the active instance exceeds the lock period.
[0013] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, computer instructions being stored in the memory, and the processor executing the computer instructions to execute the high availability method for implementing UPF based on Redis according to the first aspect or any corresponding embodiment thereof.
[0014] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the high-availability method for implementing UPF based on Redis according to the above-mentioned first aspect or any corresponding embodiment thereof.
[0015] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the high availability method for implementing UPF based on Redis according to the above-mentioned first aspect or any corresponding embodiment. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0017] Figure 1 It is a flowchart of a method for implementing high availability of UPF based on Redis according to an embodiment of the present invention;
[0018] Figure 2 is a flowchart of a serialization / deserialization method based on Redis according to an optional embodiment of the present invention;
[0019] Figure 3 is a schematic diagram of a service instance contention lock process according to an optional embodiment of the present invention;
[0020] Figure 4 is a schematic diagram of a single UPF service instance switching process according to an optional embodiment of the present invention;
[0021] Figure 5 is a structural block diagram of a high-availability device for implementing UPF based on Redis according to an embodiment of the present invention;
[0022] Figure 6 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are 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 those skilled in the art without creative work are within the scope of protection of the present invention.
[0024] Redis (Remote Dictionary Server) is an open source memory data structure storage system, widely used in database, cache and message middleware scenarios. Redis distributed lock is a mechanism to achieve mutual exclusive access in distributed systems. Mutually exclusive access is achieved through specific Redis commands (such as SETNX), ensuring that only one client can acquire the lock at the same time. The lock value usually contains the client's unique identifier to ensure that only the client holding the lock can release the lock. To avoid deadlock, the lock usually sets an automatic expiration time. After the timeout, Redis will automatically delete the lock and release resources. In UPF, Redis distributed locks can be applied to multiple scenarios to ensure data consistency and service reliability.
[0025] According to an embodiment of the present invention, an embodiment of a high-availability method for implementing UPF based on Redis is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0026] In this embodiment, a high availability method for implementing UPF based on Redis is provided. Figure 1 : is a flow chart of a method for implementing high availability of UPF based on Redis according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0027] Step S101, determine the lock acquisition strategy; the lock acquisition strategy includes lock duration, lock competition rules and preset lock quantity.
[0028] Optionally, the lock acquisition strategy also includes a lock name, based on which a corresponding unique identifier is assigned to the lock of the Redis server.
[0029] The lock period is the validity period of the lock. During the lock period, the service instance holding the lock is considered active and authorized to process business requests. Once the lock expires, if it is not refreshed, the lock will be released. Define the rules for how service instances compete to acquire locks, including timestamp-based priority sorting, random selection, or other strategies. The number of locks pre-set on the Redis server matches the number of active service instances required by the business. Lock name, that is, assign a unique name or identifier to each lock so that the service instance can clearly specify the target when trying to acquire the lock.
[0030] Step S102: Obtain the lock corresponding to each service instance from the Redis server according to the lock competition rule.
[0031] After the service instance is started, it will try to acquire a lock according to the lock competition rules. If the service instance successfully acquires the lock, it will hold the lock until the lock expires. If the service instance fails to acquire the lock, it will enter the standby state and wait for an opportunity to try to acquire the lock again.
[0032] Step S103, mark the service instances with a preset number of locks that have obtained the lock as active instances, and assign corresponding business processing tasks, and mark the service instances with a preset number of spares that have not obtained the lock as spare instances; each active instance updates the lock status to the Redis server according to the specified period.
[0033] The preset number of locks is recorded as N. The first N service instances that successfully obtain the locks are marked as active instances and are responsible for processing business requests. Service instances that fail to obtain locks are marked as standby instances and are in standby status. Active instances need to send lock refresh requests to the Redis server at a specified period to extend the validity period of the lock and confirm their own status.
[0034] Step S104: If the active instance exceeds the lock period, the standby instance is switched to be the new active instance.
[0035] If the active instance fails to send a refresh request within the lock period, the lock will automatically expire and be released. Once the lock is released, the standby instance will have the opportunity to try to acquire the lock. The standby instance that successfully acquires the lock will become the new active instance and take over the business processing tasks originally handled by the failed instance.
[0036] The high availability method for implementing UPF based on Redis provided in this embodiment realizes high availability of services by defining lock acquisition strategies, service instances competing to acquire locks, and switching active and standby instances according to lock status, thereby improving the efficiency and reliability of UPF.
[0037] In an optional implementation, the process of step S102 includes the following steps:
[0038] Step S1021, setting a preset acquisition time for lock acquisition.
[0039] The preset acquisition time is used to limit the time a service instance spends trying to acquire a lock. If a service instance fails to successfully acquire a lock within the preset time, it will stop trying, thus avoiding occupying system resources indefinitely. The preset acquisition time can be fixed (such as 30 seconds, 1 minute, etc.) or dynamic (adjusted according to factors such as system load and network conditions).
[0040] Step S1022: If the service instance fails to successfully acquire the lock corresponding to the candidate service instance within the preset acquisition time, the operation of acquiring the lock corresponding to the candidate service instance is stopped.
[0041] When the service instance starts trying to acquire the lock, the timer starts. If the service instance fails to successfully acquire the lock within the preset acquisition time (that is, the lock has been acquired by another instance or the acquisition fails due to other reasons), the lock acquisition operation of the service instance will be stopped. After stopping the operation, the service instance can enter the standby state and wait for an opportunity to try to acquire the lock again, or perform other tasks.
[0042] This implementation stops invalid lock acquisition attempts, releases system resources, and allows other service instances or processes to have a chance to acquire locks, thereby improving the overall performance and efficiency of the system.
[0043] In an optional implementation, after the corresponding business processing tasks are assigned in step S103, Figure 2 is a flow chart of a serialization / deserialization method based on Redis according to an optional embodiment of the present invention, such as Figure 2 As shown, the process includes the following steps:
[0044] Step S201, serialize the session data of the business processing task and send it to the Redis server.
[0045] When an active service instance processes a business request, it generates corresponding session data. The session data is serialized in a certain format and can be transmitted and stored on the network. For example, the protobuf (Protocol Buffers) format is chosen for serialization. After each session-related operation request (such as create, modify, delete) is processed by the service instance, the latest session data is serialized in protobuf format and sent to Redis.
[0046] Protobuf is an efficient binary serialization format that can significantly reduce the size of data, thereby speeding up data transmission and reducing storage space usage. When an active service instance processes a business request, it generates session data. Use the protobuf library to serialize this session data into a binary format. Send the serialized data to the Redis server for storage.
[0047] Step S202: The standby instance subscribes to a specific channel of the Redis server.
[0048] The standby service instance reads a specific channel of the Redis server to receive session data update messages sent by the active service instance in real time. After the standby instance is started, it connects to the Redis server and subscribes to a specific channel. This channel is where the active instance publishes session data update messages. After subscribing to the channel, the standby instance will be able to receive session data sent by the active instance in real time.
[0049] Step S203: Based on the specific channel, the standby instance receives and saves the deserialized session data.
[0050] Use the deserialization technology corresponding to the serialization technology to deserialize these binary session data into the original data format. Save the deserialized data to the local memory so that the service can be quickly restored when needed.
[0051] By subscribing to a specific channel and deserializing session data, the standby instance can receive session data update messages sent by the active instance in real time and quickly resume service when taking over tasks of the active instance, thereby ensuring data consistency and synchronization.
[0052] In an optional implementation, the process of step S104 includes the following steps:
[0053] Step S1041: If the active instance fails to send a refresh request within the lock period, the lock corresponding to the active instance is released and the active instance is downgraded to a new standby instance.
[0054] Monitor whether each active instance has sent a refresh request to Redis within the lock period. If an active instance fails to send a refresh request within the specified time, it is considered that the instance has failed or failed.
[0055] By releasing the lock corresponding to the failed active instance, the standby instance has the opportunity to acquire the lock and take over the business processing tasks originally handled by the failed instance. The failed active instance is downgraded to a new standby instance, which has the opportunity to become the active instance again after the fault is resolved.
[0056] Step S1042: Select a target instance in the standby instance, and obtain a lock corresponding to the target instance from the Redis server to switch the target instance to a new active instance.
[0057] Select a target instance from the standby instances and try to obtain the lock corresponding to the target instance from the Redis server. If the acquisition is successful, the target instance will become the new active instance and take over the business processing tasks originally handled by the failed active instance.
[0058] Figure 3This is a schematic diagram of the service instance competition lock process according to an optional embodiment of the present invention. N service instances successfully obtain the lock, and regularly send refresh requests to refresh the expiration time. M standby instances periodically try to obtain the lock. Whenever a standby instance successfully obtains the lock that originally belonged to a service instance, it means that the standby instance has been officially promoted to a new service instance, restores the session-related data of the previous service instance from Redis, and begins to bear the workload. At the same time, the service instance that originally held the lock but had problems will automatically be downgraded to a standby instance after restarting, and continue to wait for the next opportunity to take over.
[0059] In this implementation, by acquiring the lock corresponding to the failed active instance, the standby instance can take over its tasks to ensure the stability of the service.
[0060] In an optional implementation, if the active instance is marked as being in an internal abnormal state, restarting the active instance and downgrading the active instance to a new standby instance;
[0061] If the active instance stops after receiving an external instruction, the active instance is downgraded to a new standby instance.
[0062] The system monitors the operating status of active instances in real time through a self-diagnosis mechanism.
[0063] If an active instance is found to have an internal abnormal state (such as memory overflow, routing abnormality, DPDK MBUF abnormality, etc.), it will be marked as an abnormal state. After detecting that an active instance has an internal abnormal state, the restart mechanism is triggered immediately. During the restart process, the active instance is marked as a new standby instance. After the restart is complete, the instance will wait as a standby instance for an opportunity to try to acquire the lock again and become an active instance.
[0064] The active instance may receive a stop command from the system administrator or an external system. The stop command is an abnormal termination of the service instance due to external reasons (such as a system crash). The lock held by the active instance in Redis will expire naturally because it is not refreshed in time. After receiving the stop command, the active instance immediately stops processing business requests. The active instance is marked as a new standby instance.
[0065] This implementation prevents abnormal instances from continuing to process business requests, thereby avoiding possible data corruption or service interruption and ensuring the stability and reliability of the system.
[0066] Figure 4 is a schematic diagram of a single UPF service instance switching process according to an optional embodiment of the present invention, such as Figure 4As shown in the figure, at the beginning of system startup, UPF will start N+M instances, where N represents the number of active service instances set in the configuration, and M represents the number of additional standby instances. All these instances will be connected to the same Redis to coordinate and manage the state of the lock and the backup of session data. Each instance attempts to obtain one of the locks (a total of N locks are set), and an expiration time is set when each lock is obtained. The first N instances that successfully obtain the lock are designated as active service instances, and the remaining M instances are used as standby. In order to maintain its "active" state, each service instance needs to send a lock refresh request to Redis regularly to extend the validity period of the lock it holds. This process not only proves that the instance is still operating normally, but also confirms its own health status. If a service instance fails to update its lock in time, it will be considered to have failed or failed, and the lock will automatically expire. If a fault is found, the system will take corresponding measures, such as releasing the lock, retrying to obtain the lock, etc., to restore the normal state of the service.
[0067] Optionally, the UPF instance status switch can be proactively notified to management personnel in real time via email, text messages, and various mobile apps, allowing relevant personnel to locate and analyze the cause of the instance switch and resolve the problem in a timely manner.
[0068] In summary, the present invention ensures that the service can be quickly restored when the active instance fails through the backup instance and automatic switching mechanism. By acquiring locks through competition, business processing tasks are reasonably allocated to avoid overloading of some instances while other instances are idle. By regularly updating the lock status and fault detection mechanism, instance failures can be discovered and handled in a timely manner, and dynamic management and fault transfer of service instances can be effectively achieved, thereby greatly improving the reliability and response speed of the system and ensuring the stability and reliability of the system.
[0069] In this embodiment, a high-availability device for implementing UPF based on Redis is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0070] This embodiment provides a high-availability device for implementing UPF based on Redis, such as Figure 5 As shown, including:
[0071] The strategy determination module 501 is used to determine the lock acquisition strategy; the lock acquisition strategy includes the lock period, lock competition rules and the preset lock quantity;
[0072] The lock acquisition module 502 is used to acquire the lock corresponding to each service instance from the Redis server according to the lock competition rule;
[0073] The instance marking module 503 is used to mark the service instances with a preset number of locks that have obtained the lock as active instances and assign corresponding business processing tasks, and mark the service instances with a preset number of spares that have not obtained the lock as spare instances; each active instance updates the lock status to the Redis server according to a specified period;
[0074] The instance switching module 504 is used to switch the standby instance to a new active instance if the active instance exceeds the lock period.
[0075] In an optional implementation, the policy determination module 501 is used to:
[0076] The lock acquisition strategy also includes a lock name; based on the lock name, a corresponding unique identifier is assigned to the lock of the Redis server.
[0077] In an optional implementation, the lock acquisition module 502 includes:
[0078] A first lock acquisition unit, used to set a preset acquisition time for lock acquisition;
[0079] The second lock acquisition unit is configured to stop executing the operation of acquiring the lock corresponding to the candidate service instance if the service instance fails to successfully acquire the lock corresponding to the candidate service instance within a preset acquisition time.
[0080] In an optional implementation, the instance marking module 503 is used to:
[0081] The session data of the business processing task is serialized and sent to the Redis server.
[0082] In an optional implementation, the device further includes a deserialization module, and the deserialization module includes:
[0083] The first deserialization unit is used for the standby instance to subscribe to a specific channel of the Redis server;
[0084] The second deserialization unit is used for receiving and saving the deserialized session data by the standby instance based on a specific channel.
[0085] In an optional implementation, the instance switching module 504 includes:
[0086] A first instance switching unit, configured to release a lock corresponding to the active instance and downgrade it to a new standby instance if the active instance fails to send a refresh request within the lock period;
[0087] The second instance switching unit is used to select a target instance from the standby instance and obtain a lock corresponding to the target instance from the Redis server to switch the target instance to a new active instance.
[0088] In an optional implementation, the instance switching module 504 further includes:
[0089] an instance restart unit, configured to restart the active instance and downgrade the active instance to a new standby instance if the active instance is marked as being in an internal abnormal state;
[0090] The instance downgrading unit is used to downgrade the active instance to a new standby instance if the active instance stops after receiving an external instruction.
[0091] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0092] The high-availability device for implementing UPF based on Redis in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0093] The embodiment of the present invention also provides a computer device having the above Figure 5 The high-availability device shown implements UPF based on Redis.
[0094] See also Figure 6 , Figure 6 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 6 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 10 is taken as an example.
[0095] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0096] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0097] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0098] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0099] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.
[0100] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the computer device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.
[0101] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0102] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0103] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A high availability method for implementing UPF based on Redis, characterized in that: The method comprises: Determine a lock acquisition strategy; the lock acquisition strategy includes a lock period, lock competition rules, and a preset number of locks; Obtain the lock corresponding to each service instance from the Redis server according to the lock competition rule; Marking a preset number of service instances that have obtained locks as active instances and assigning corresponding business processing tasks, and marking a preset number of service instances that have not obtained locks as standby instances; each active instance updates the lock status to the Redis server according to a specified period; If the active instance exceeds the lock period, the standby instance is switched to become a new active instance.
2. The method according to claim 1, characterized in that The lock acquisition strategy also includes a lock name, and the method further includes: Based on the lock name, a corresponding unique identifier is assigned to the lock of the Redis server.
3. The method according to claim 1 or 2, characterized in that: The acquiring locks corresponding to each service instance from the Redis server according to the lock competition rule includes: Set the preset acquisition time for lock acquisition; If the service instance fails to successfully acquire the lock corresponding to the candidate service instance within the preset acquisition time, the operation of acquiring the lock corresponding to the candidate service instance is stopped.
4. The method according to claim 1, characterized in that: After allocating the corresponding business processing tasks, the method further includes: The session data of the business processing task is serialized and sent to the Redis server.
5. The method according to claim 4, characterized in that The method further comprises: The standby instance subscribes to a specific channel of the Redis server; Based on the specific channel, the standby instance receives and saves the deserialized session data.
6. The method according to claim 1, characterized in that If the active instance exceeds the lock period, switching the standby instance to a new active instance includes: If the active instance fails to send a refresh request within the lock period, the lock corresponding to the active instance is released and the active instance is downgraded to a new standby instance; A target instance is selected in the standby instance, and a lock corresponding to the target instance is obtained from the Redis server to switch the target instance to a new active instance.
7. The method according to claim 6, characterized in that The method further comprises: If the active instance is marked as being in an internal abnormal state, restarting the active instance and downgrading the active instance to a new standby instance; If the active instance stops after receiving an external instruction, the active instance is downgraded to a new standby instance.
8. A high-availability device for implementing UPF based on Redis, characterized in that: The device comprises: A strategy determination module, used to determine a lock acquisition strategy; the lock acquisition strategy includes a lock period, a lock competition rule, and a preset number of locks; A lock acquisition module is used to acquire the lock corresponding to each service instance from the Redis server according to the lock competition rule; An instance marking module is used to mark a preset number of service instances that have obtained locks as active instances and assign corresponding business processing tasks, and mark a preset number of service instances that have not obtained locks as standby instances; each active instance updates the lock status to the Redis server according to a specified period; The instance switching module is used to switch the standby instance to a new active instance if the active instance exceeds the lock period.
9. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the high-availability method for implementing UPF based on Redis as described in any one of claims 1 to 7 by executing the computer instructions.
10. 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 high-availability method for implementing UPF based on Redis according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for deadlock monitoring for application programming interface
CN107291558A
Data caching method and device, server and computer readable storage medium
CN113590661A
Method for processing high-concurrency batch tasks and related products
CN115220891A
Data persistence method and device and storage medium
CN115437549A
Data extraction method and device, program product and medium
CN118626539A
Cited By
Method, system and device for UPF network element to directly read and write Redis database
CN120730347A