Connection method of server, server, storage medium and electronic device
By connecting IoT devices in stages and configuring priorities based on device attributes, the problem of excessive instantaneous pressure after server updates and restarts was solved, improving server stability and device connection success rate.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GREE ELECTRIC APPLIANCE INC OF ZHUHAI
- Filing Date
- 2024-09-06
- Publication Date
- 2026-07-03
AI Technical Summary
After the server was updated and restarted, the instantaneous pressure was too great, which caused the server stability to decrease and it was unable to effectively handle a large number of connection requests from IoT devices.
By obtaining the priority distribution information of the device set, the devices are connected in stages. Priority levels are configured according to attributes such as device function type, usage frequency and user priority. In each stage, different priority sets of devices are selected for reconnection, and high-priority devices are processed first.
It alleviated the instantaneous pressure on the server, improved server stability, ensured that device connection requests could be effectively handled after the update, and enhanced the user experience.
Smart Images

Figure CN119109962B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Internet of Things (IoT) technology, and more specifically, to a server connection method, as well as a server, storage medium, and electronic device. Background Technology
[0002] In related technologies, smart home devices / Internet of Things (IoT) devices refer to home management and control systems that utilize advanced information technology and Internet of Things (IoT) technology to connect traditional home devices and systems to the Internet, thereby achieving automated, intelligent, and convenient home management and control.
[0003] In related technologies, smart home devices communicate with cloud servers based on protocols. The servers will be updated and restarted according to business needs. In the short period of time after the server has been updated and restarted, there may be a large number of IoT devices requesting to connect to the server at a certain moment, which may cause the server to be under excessive pressure or even crash, affecting the stability of the server.
[0004] No efficient and accurate solution has yet been found to address the aforementioned issues in the relevant technologies. Summary of the Invention
[0005] This invention provides a server connection method, as well as a server, storage medium, and electronic device, to solve technical problems in related technologies.
[0006] According to an embodiment of the present invention, a server connection method is provided, comprising: determining that the server has completed a restart; obtaining priority distribution information of a set of devices associated with the server, wherein the set of devices includes multiple devices, and the priority distribution information is used to describe the priority level of each device; and connecting multiple devices in the set of devices in stages based on the priority distribution information.
[0007] Optionally, before determining that the server has completed its restart, the method further includes: obtaining the device attributes of each device in the device set before the server program begins the shutdown update; configuring the priority level of the corresponding device based on the device attributes; and notifying the device.
[0008] Optionally, configuring the priority level of the corresponding device based on the device attributes includes: parsing the function type of the first device based on the device attributes, wherein the function type includes gateway function and storage function; if the first device is a gateway device, configuring the first device as a first priority level; if the first device is a storage device, configuring the first device as a second priority level, wherein the first priority level is higher than the second priority level.
[0009] Optionally, configuring the priority level of the corresponding device based on the device attributes includes: parsing the usage frequency of the second device based on the device attributes; determining whether the usage frequency is greater than a preset threshold; if the usage frequency is greater than the preset threshold, configuring the second device as a third priority level; if the usage frequency is less than or equal to the preset threshold, configuring the second device as a fourth priority level, wherein the third priority level is higher than the fourth priority level.
[0010] Optionally, configuring the priority level of the corresponding device based on the device attributes includes: resolving the user priority of the user to which the third device belongs based on the device attributes; configuring the priority level of the third device based on the user priority, wherein the priority level is positively correlated with the user priority.
[0011] Optionally, before determining that the server has completed restarting, the method further includes: determining the update order of multiple microservices in the server program before the server program begins rolling updates, wherein the server program includes the multiple microservices, each microservice corresponding to a software function; determining the partition device corresponding to each microservice; configuring the priority level of each partition device according to the update order, and notifying the partition device.
[0012] Optionally, connecting multiple devices in the device set in stages based on the priority distribution information includes: selecting a first device set with a preset proportion in the device set according to the priority distribution information; sending a reconnection notification message to the first device set and monitoring the real-time proportion of successfully connected devices in the first device set; and continuing to connect to a second device set in the device set based on the real-time proportion, wherein the priority level of the devices in the second device set is lower than the priority level of the devices in the first device set.
[0013] Optionally, continuing to connect to the second device set in the device set based on the real-time ratio value includes: determining whether the real-time ratio value has reached a preset ratio value; if the real-time ratio value has not reached the preset ratio value, continuing to select the second device set in the device set in order based on the priority distribution information; and sending a reconnection notification message to the second device set.
[0014] Optionally, connecting multiple devices in the device set in stages based on the priority distribution information includes: selecting a third device set with a preset proportion in the device set according to the priority distribution information; sending a reconnection notification message to the third device set and monitoring the remaining computing power resources of the server; and continuing to connect to a fourth device set in the device set based on the remaining computing power resources, wherein the priority level of the devices in the fourth device set is lower than the priority level of the devices in the third device set.
[0015] Optionally, continuing to connect to the fourth device set in the device set based on the remaining computing power resources includes: determining whether the remaining computing power resources are greater than a preset computing power value; if the remaining computing power resources are greater than the preset computing power value, continuing to select the fourth device set in the device set in order based on the priority distribution information; and sending a reconnection notification message to the fourth device set.
[0016] According to another embodiment of the present invention, a server is provided, comprising: a first determining module, configured to determine that the server has completed restarting; a first acquiring module, configured to acquire priority distribution information of a set of devices associated with the server, wherein the set of devices includes multiple devices, and the priority distribution information is used to describe the priority level of each device; and a connecting module, configured to connect multiple devices in the set of devices in stages based on the priority distribution information.
[0017] Optionally, the device further includes: a second acquisition module, configured to acquire device attributes of each device in the device set before the determining module determines that the server has completed restarting and before the server program begins a shutdown update; and a first configuration module, configured to configure the priority level of the corresponding device based on the device attributes and notify the device.
[0018] Optionally, the first configuration module includes: a first parsing unit, configured to parse the function type of the first device based on the device attributes, wherein the function type includes gateway function and storage function; and a first configuration unit, configured to configure the first device as a first priority level if the first device is a gateway device, and to configure the first device as a second priority level if the first device is a storage device, wherein the first priority level is higher than the second priority level.
[0019] Optionally, the first configuration module includes: a second parsing unit, configured to parse the usage frequency of the second device based on the device attributes; a judging unit, configured to judge whether the usage frequency is greater than a preset threshold; and a second configuration unit, configured to configure the second device as a third priority level if the usage frequency is greater than the preset threshold, and to configure the second device as a fourth priority level if the usage frequency is less than or equal to the preset threshold, wherein the third priority level is higher than the fourth priority level.
[0020] Optionally, the first configuration module includes: a third parsing unit, configured to parse the user priority of the user to which the third device belongs based on the device attributes; and a third configuration unit, configured to configure the priority level of the third device based on the user priority, wherein the priority level is positively correlated with the user priority.
[0021] Optionally, the apparatus further includes: a second determining module, configured to determine the update order of multiple microservices in the server program before the first determining module determines that the server has completed restarting and before the server program begins rolling updates, wherein the server program includes the multiple microservices, and each microservice corresponds to a software function; a third determining module, configured to determine the partition device corresponding to each microservice; and a second configuration module, configured to configure the priority level of each partition device according to the update order and notify the partition device.
[0022] Optionally, the connection module includes: a first selection unit, configured to sequentially select a first set of devices in the device set according to a preset proportion based on the priority distribution information; a first connection unit, configured to send a reconnection notification message to the first set of devices and monitor the real-time proportion of successfully connected devices in the first set of devices; and a second connection unit, configured to continue connecting to a second set of devices in the device set based on the real-time proportion, wherein the priority level of devices in the second set of devices is lower than the priority level of devices in the first set of devices.
[0023] Optionally, the second connection unit includes: a judgment subunit, used to judge whether the real-time ratio value has reached a preset ratio value; a selection subunit, used to continue selecting a second device set in the device set in order based on the priority distribution information if the real-time ratio value has reached the preset ratio value; and a sending subunit, used to send a reconnection notification message to the second device set.
[0024] Optionally, the connection module includes: a second selection unit, configured to select a third set of devices in the device set according to a preset proportion based on the priority distribution information; a third connection unit, configured to send a reconnection notification message to the third set of devices and monitor the remaining computing power resources of the server; and a fourth connection unit, configured to continue connecting to the fourth set of devices in the device set based on the remaining computing power resources, wherein the priority level of the devices in the fourth set of devices is lower than the priority level of the devices in the third set of devices.
[0025] Optionally, the fourth connection unit includes: a judgment subunit, used to judge whether the remaining computing power resources are greater than a preset computing power value; a selection subunit, used to continue selecting a fourth device set in the device set in order based on the priority distribution information if the remaining computing power resources are greater than the preset computing power value; and a sending subunit, used to send a reconnection notification message to the fourth device set.
[0026] According to another aspect of the embodiments of this application, a storage medium is also provided, the storage medium including a stored program that executes the above steps when the program is run.
[0027] According to another aspect of the embodiments of this application, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; wherein: the memory is used to store computer programs; and the processor is used to execute the steps in the above method by running the programs stored in the memory.
[0028] According to yet another embodiment of the present invention, a storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is configured to execute the steps in any of the above-described apparatus embodiments when running.
[0029] Through the embodiments of the present invention, it is determined that the server has completed restarting; priority distribution information of the set of devices associated with the server is obtained, wherein the set of devices includes multiple devices, and the priority distribution information is used to describe the priority level of each device; based on the priority distribution information, multiple devices in the set of devices are connected in stages. By connecting multiple devices attached to the server in stages and connecting different priority sets of devices in each stage, the number of request connections responded to by the server can be maintained within a safe range that the server resources can bear. This solves the technical problem of excessive instantaneous pressure on the server after the update in related technologies, alleviates the instantaneous pressure on the server, and improves the stability of the server. Attached Figure Description
[0030] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0031] Figure 1 This is a hardware structure block diagram of a server according to an embodiment of the present invention;
[0032] Figure 2 This is a flowchart of a server connection method according to an embodiment of the present invention;
[0033] Figure 3 This is a flowchart illustrating how the server connects to devices according to priority in an embodiment of the present invention;
[0034] Figure 4 This is a structural block diagram of a server according to an embodiment of the present invention. Detailed Implementation
[0035] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of the present application can be combined with each other.
[0036] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0037] Example 1
[0038] The method embodiment provided in Embodiment 1 of this application can be executed in a server, controller, or similar device management device. Taking running on a server as an example, Figure 1 This is a hardware structure block diagram of a server according to an embodiment of the present invention. Figure 1As shown, a server may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. Optionally, the server may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the server described above. For example, the server may also include components that are more complex than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0039] The memory 104 can be used to store server programs, such as application software programs and modules, like the server program corresponding to a server connection method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the server program stored in the memory 104, thus implementing the aforementioned method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the server via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0040] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the server's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0041] This embodiment provides a method for connecting to a server. Figure 2 This is a flowchart of a server connection method according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps:
[0042] Step S202: Confirm that the server has successfully restarted;
[0043] The server in this embodiment can be various types of network servers, such as cloud servers for the Internet of Things. The connection between the server and the device is based on a communication protocol, such as MQTT (Message Queuing Telemetry Transport).
[0044] Step S204: Obtain priority distribution information of the set of devices associated with the server, wherein the set of devices includes multiple devices, and the priority distribution information is used to describe the priority level of each device;
[0045] Optionally, the device can be a terminal device, gateway device, management device, interrupt device, etc. that can be connected to the server. Terminal devices include refrigerators, air conditioners, robot vacuum cleaners, and smart speakers.
[0046] In this embodiment, priority distribution information can be stored on the server in the form of a mapping table or a priority model. The mapping table stores the priority level of each device that has been connected to the server. The priority level can be level 1, level 2, level 3, etc., or it can be represented in the form of P0, P1, P2, etc.
[0047] Step S206: Connect multiple devices in the device set in stages based on the priority distribution information;
[0048] The higher the priority level, the more important the device, and the earlier it will be connected after the server update and restart.
[0049] Through the above steps, it is confirmed that the server has restarted successfully; priority distribution information of the set of devices associated with the server is obtained, wherein the set of devices includes multiple devices, and the priority distribution information is used to describe the priority level of each device; based on the priority distribution information, multiple devices in the set of devices are connected in stages. By connecting multiple devices attached to the server in stages, and connecting different priority sets of devices in each stage, the number of request connections responded to by the server can be maintained within a safe range that the server resources can bear. This solves the technical problem of excessive instantaneous pressure on the server after the update in related technologies, alleviates the instantaneous pressure on the server, and improves the stability of the server.
[0050] In one implementation scenario of this embodiment, before determining that the server has completed restarting, the method further includes: before the server program begins the shutdown update, obtaining the device attributes of each device in the device set; configuring the priority level of the corresponding device based on the device attributes, and notifying the device.
[0051] Optionally, device attributes may include, but are not limited to, the following: function type, usage frequency, user priority, etc. When configuring the priority level of the corresponding device, one or more types of attribute information can be selected for configuration.
[0052] In the scenario of a shutdown-based update, by configuring the priority level of devices according to their attributes before the update, multiple devices in the set can be connected in stages according to the importance of their attributes after the server update restarts, ensuring that important devices connect to the server first.
[0053] In one example, configuring the priority level of the corresponding device based on the device attributes includes: resolving the function type of the first device based on the device attributes, wherein the function type includes gateway function and storage function; if the first device is a gateway device, configuring the first device to a first priority level; if the first device is a storage device, configuring the first device to a second priority level, wherein the first priority level is higher than the second priority level.
[0054] In this example, device attributes are functional attributes or network attributes. A basic priority sequence model is established through the server. Functional types include gateway functions (directly connected devices) and storage functions (non-directly connected devices, sub-devices). Real-time devices and node-type devices have higher priority than storage devices, etc. For example, gateway devices have higher priority than sub-devices.
[0055] Generate a priority model: First, establish a basic priority sequence model through the server. For example, important devices, real-time devices, and node devices have higher priority than storage devices, and gateway devices have higher priority than sub-devices.
[0056] By configuring the priority level of devices according to their function type, the priority level of gateway devices is made higher than that of storage devices. Gateway devices play a role in networking and protocol conversion in the Internet of Things network. Only after the gateway device is connected can the storage devices networked through the gateway device be connected, which improves the success rate of device connection to the server and reduces invalid reconnections.
[0057] In another example, configuring the priority level of the corresponding device based on the device attributes includes: parsing the usage frequency of the second device based on the device attributes; determining whether the usage frequency is greater than a preset threshold; if the usage frequency is greater than the preset threshold, configuring the second device as the third priority level; if the usage frequency is less than or equal to the preset threshold, configuring the second device as the fourth priority level, wherein the third priority level is higher than the fourth priority level.
[0058] Optionally, the usage frequency of the second device can be calculated by weighting device attributes such as time, geographical location, and device type. This is based on the user's actual usage, adjusting for device type, usage frequency, usage time, and geographical location. For example, the demand for cooling devices like air conditioners is higher in summer and relatively lower in spring and autumn. Therefore, in summer, air conditioners (such as underfloor heating) have a higher usage frequency and priority. Geographical location can also be considered. For instance, within a city, devices in suburban areas tend to be used more frequently outside of working hours than those in commercial areas. During non-working hours, devices in suburban areas have a higher weight and usage frequency than those in commercial areas, while during working hours, devices in suburban areas have a lower weight and usage frequency.
[0059] By configuring device priority levels based on device usage frequency, devices with high usage frequency are given higher priority than those with low usage frequency. Devices with high user frequency and probability of use are connected first, which improves the utilization rate of server access devices and shortens the offline time of high-frequency devices.
[0060] In another example, configuring the priority level of the corresponding device based on the device attributes includes: resolving the user priority of the user to which the third device belongs based on the device attributes; configuring the priority level of the third device based on the user priority, wherein the priority level is positively correlated with the user priority.
[0061] Optionally, by analyzing user accounts logged into devices, user priority can be personalized based on user habits, user type, etc. For example, users with paid accounts have higher priority than ordinary users, long-term users have higher priority than new users, users who purchased high-end devices with the same functions have higher priority than users who purchased low-end devices, and users who use devices frequently have higher priority than users who use devices infrequently. The higher the user priority, the greater the impact of whether the device connects to the server on the user.
[0062] Alternatively, multiple priorities can be considered, with the server prioritization strategy as follows: Function Type > Usage Frequency > User Priority. If there is a conflict in priority levels across different dimensions, the priority dimension that appears earlier in the priority strategy should be prioritized.
[0063] By configuring the priority level of devices based on the user priority of the user to which the device belongs, devices owned by users with higher user priority are given higher priority than devices owned by users with lower user priority. Devices that have a greater impact on users are connected first, thus ensuring a better user experience.
[0064] In another implementation scenario of this embodiment, before determining that the server has completed restarting, the method further includes: determining the update order of multiple microservices in the server program before the server program starts rolling updates, wherein the server program includes the multiple microservices, each microservice corresponding to a software function; determining the partition device corresponding to each microservice; configuring the priority level of each partition device according to the update order, and notifying the partition device.
[0065] Optionally, microservices also have different priorities. For example, some microservices are prerequisites for other microservices (such as microservice registry centers, inspection centers, etc.), enabling them to detect anomalies in started microservices immediately and respond with corresponding handling strategies. When updating multiple microservices in the server program, they will be updated sequentially according to priority to ensure server robustness. More important microservices will be updated first, meaning they will be updated earlier and restarted sooner.
[0066] In a scenario of rolling server updates, the server is divided into different blocks. This can be understood as the program that needs to be updated containing multiple microservices. These microservices also have a certain priority order, which is reflected in the update order. Devices with higher priority microservices form a partition, i.e. partition devices. When a device that depends on a partition receives an update notification, it can adjust its connection strategy. It can prioritize processing connection requests from devices that request higher priority microservices, while devices with lower priority will either postpone processing or switch to a backup server or other partitions.
[0067] In one example, after the server program completes its rolling update, a server cluster, through several central servers, proxies requests to edge servers for further processing. High-priority microservices, such as the nginx proxy service in the centralized server (i.e., the "centralized partition"), are updated and restarted first. Only when there are spare resources are the requests processed by the edge servers (partitions).
[0068] By configuring device priority levels according to the update order of microservices in rolling update scenarios, devices with important microservices and those that are updated first have higher priority than devices with microservices that are updated later. This allows for priority startup and connection of partition devices for important microservices, ensuring server robustness.
[0069] In one embodiment of this example, connecting multiple devices in the device set in stages based on the priority distribution information includes: selecting a first device set with a preset proportion in the device set according to the priority distribution information; sending a reconnection notification message to the first device set and monitoring the real-time proportion of successfully connected devices in the first device set; and continuing to connect to a second device set in the device set based on the real-time proportion, wherein the priority level of the devices in the second device set is lower than the priority level of the devices in the first device set.
[0070] In the first phase, the highest priority first device set is selected in the first phase of the system. The preset ratio (e.g., 50%) refers to the ratio of the number of devices in the first device set to the total number of devices. This is used to control the instantaneous pressure on the server in each phase. After the first device set is successfully connected, only devices with lower priority remain. These devices can then be connected to the second device set with lower priority in the next phase. By connecting multiple devices in phases according to priority, the resource pressure on the server is distributed, and the stability of the server is improved.
[0071] Optionally, continuing to connect to the second device set in the device set based on the real-time ratio value includes: determining whether the real-time ratio value has reached a preset ratio value; if the real-time ratio value has not reached the preset ratio value, continuing to select the second device set in the device set in order based on the priority distribution information; and sending a reconnection notification message to the second device set.
[0072] After the server update, based on the previously generated priority model hierarchy, devices at different levels are reconnected in a certain proportion. Furthermore, after a period of connection, the device priorities are dynamically adjusted (i.e., once the reconnection rate of first-priority devices exceeds XX%, certain second-priority devices can continue to connect in the next stage. For example, if over 80% of important or real-time devices in the first-priority category have successfully connected, but only 30% of second-priority devices have successfully connected, the priority of a particular time and region can be increased to account for a larger proportion of "reconnections").
[0073] The strategy of dynamically adjusting priorities based on actual conditions: If the number of connections to the first set of devices at the first priority level (such as centralized devices like gateways) has exceeded a certain threshold, and this does not affect the user's main user experience, then some second-priority devices at the second priority level (such as air conditioners or voice speakers used in summer) that are frequently used by users can be connected, and the priorities can be dynamically adjusted based on usage.
[0074] In this embodiment, when the real-time success rate of high-priority connections reaches a preset rate, the next stage of connection is initiated, connecting a second set of lower-priority devices. This approach ensures the number of high-priority devices connected while distributing load across the server.
[0075] In one embodiment of this example, connecting multiple devices in the device set in stages based on the priority distribution information includes: selecting a third device set with a preset proportion in the device set according to the priority distribution information; sending a reconnection notification message to the third device set and monitoring the remaining computing power resources of the server; and continuing to connect to a fourth device set in the device set based on the remaining computing power resources, wherein the priority level of the devices in the fourth device set is lower than the priority level of the devices in the third device set.
[0076] Optionally, the server's computing resources include the utilization rate of resources such as CPU, GPU, and memory. The more remaining computing resources a server has, the more connections it can process instantly and the greater the pressure it can withstand.
[0077] After the server connects to the third set of devices, it begins to monitor the server's remaining computing resources. If the remaining computing resources allow, it can start the next stage to continue connecting to the fourth set of devices with lower priority. By connecting multiple devices in stages according to priority, the resource pressure on the server is distributed and the server's stability is improved.
[0078] Optionally, continuing to connect to the fourth device set in the device set based on the remaining computing power resources includes: determining whether the remaining computing power resources are greater than a preset computing power value; if the remaining computing power resources are greater than the preset computing power value, continuing to select the fourth device set in the device set in order based on the priority distribution information; and sending a reconnection notification message to the fourth device set.
[0079] By managing server resources, during device connection processes, middleware can monitor the server's remaining computing power. If server resources are sufficient, or when handling devices with certain priorities, the peak connection times can be dynamically adjusted, forming a scalable connection strategy. For example, assuming there are devices A and B, with device A having higher priority, the server's strategy during connection to device A might prioritize ensuring successful connection (e.g., QoS 2 in the MQTT protocol), while device B only requires QoS 0. Therefore, device A will consume more resources during connection than device B. After subsequent priority adjustments, more connections can be opened when connecting a large number of devices B, maintaining server resources at a high performance level.
[0080] This implementation method enables flexible use of server computing resources. Assuming that the server resources used to connect to A are twice that of B, in order to ensure the stability of the A connection, after the A connection with extremely high priority is completed, more resources can be freed up for B to use, that is, more connections can be opened to ensure a peak server capacity.
[0081] In this embodiment, when the server's remaining computing power resources exceed a preset computing power value, the server releases the computing power resources and initiates the next stage of connection, connecting to the fourth set of devices with lower priority. This improves the utilization rate of server resources and reduces the connection waiting time of low-priority devices.
[0082] Figure 3 This is a flowchart of a server connecting devices according to priority in an embodiment of the present invention, including: before the update, obtaining user usage habits and server (microservice) update time, generating a secondary priority, and at the same time, combining device attributes such as device priority type to generate a primary priority; if the server is performing a shutdown update, notifications are sent according to priority order, and the priority strategy is dynamically adjusted based on the restart result (notifying devices to reconnect in order of priority); if it is a rolling update, notifications are sent in partitions according to the update speed of different microservices in the program, and finally, after the update is completed, a partitioned overall notification is sent to inform all devices that the update has been completed.
[0083] Overall notification: After all priorities / partitions have been updated, publish a server status update message via MQTT to inform all devices that the server update is complete.
[0084] The solution in this embodiment adjusts the priority of devices that need to be reconnected when the server program is updated (divided into rolling updates and shutdown updates). At each stage, higher-level devices are connected first to ensure the user experience. At the same time, the number of response requests is kept within the range that the server resources can bear, thus alleviating the instantaneous pressure on the server.
[0085] This embodiment implements a data analysis-based dynamic priority adjustment strategy, which can dynamically adjust the priority of devices that need to reconnect when the server program restarts or updates. When server resources are sufficient, it prioritizes connecting to servers with higher priority, thereby alleviating instantaneous server pressure and ensuring user needs.
[0086] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0087] Example 2
[0088] This embodiment also provides a server, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. The term "module" as used below can refer to a combination of software and hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementations, or a combination of software and hardware, are also contemplated.
[0089] Figure 4 This is a structural block diagram of a server according to an embodiment of the present invention, such as... Figure 4 As shown, it includes:
[0090] The first determining module 40 is used to determine that the server has completed the restart process;
[0091] The first acquisition module 42 is used to acquire priority distribution information of a set of devices associated with the server, wherein the set of devices includes multiple devices, and the priority distribution information is used to describe the priority level of each device;
[0092] The connection module 44 is used to connect multiple devices in the device set in stages based on the priority distribution information.
[0093] Optionally, the device further includes: a second acquisition module, configured to acquire device attributes of each device in the device set before the determining module determines that the server has completed restarting and before the server program begins a shutdown update; and a first configuration module, configured to configure the priority level of the corresponding device based on the device attributes and notify the device.
[0094] Optionally, the first configuration module includes: a first parsing unit, configured to parse the function type of the first device based on the device attributes, wherein the function type includes gateway function and storage function; and a first configuration unit, configured to configure the first device as a first priority level if the first device is a gateway device, and to configure the first device as a second priority level if the first device is a storage device, wherein the first priority level is higher than the second priority level.
[0095] Optionally, the first configuration module includes: a second parsing unit, configured to parse the usage frequency of the second device based on the device attributes; a judging unit, configured to judge whether the usage frequency is greater than a preset threshold; and a second configuration unit, configured to configure the second device as a third priority level if the usage frequency is greater than the preset threshold, and to configure the second device as a fourth priority level if the usage frequency is less than or equal to the preset threshold, wherein the third priority level is higher than the fourth priority level.
[0096] Optionally, the first configuration module includes: a third parsing unit, configured to parse the user priority of the user to which the third device belongs based on the device attributes; and a third configuration unit, configured to configure the priority level of the third device based on the user priority, wherein the priority level is positively correlated with the user priority.
[0097] Optionally, the apparatus further includes: a second determining module, configured to determine the update order of multiple microservices in the server program before the first determining module determines that the server has completed restarting and before the server program begins rolling updates, wherein the server program includes the multiple microservices, and each microservice corresponds to a software function; a third determining module, configured to determine the partition device corresponding to each microservice; and a second configuration module, configured to configure the priority level of each partition device according to the update order and notify the partition device.
[0098] Optionally, the connection module includes: a first selection unit, configured to sequentially select a first set of devices in the device set according to a preset proportion based on the priority distribution information; a first connection unit, configured to send a reconnection notification message to the first set of devices and monitor the real-time proportion of successfully connected devices in the first set of devices; and a second connection unit, configured to continue connecting to a second set of devices in the device set based on the real-time proportion, wherein the priority level of devices in the second set of devices is lower than the priority level of devices in the first set of devices.
[0099] Optionally, the second connection unit includes: a judgment subunit, used to judge whether the real-time ratio value has reached a preset ratio value; a selection subunit, used to continue selecting a second device set in the device set in order based on the priority distribution information if the real-time ratio value has reached the preset ratio value; and a sending subunit, used to send a reconnection notification message to the second device set.
[0100] Optionally, the connection module includes: a second selection unit, configured to select a third set of devices in the device set according to a preset proportion based on the priority distribution information; a third connection unit, configured to send a reconnection notification message to the third set of devices and monitor the remaining computing power resources of the server; and a fourth connection unit, configured to continue connecting to the fourth set of devices in the device set based on the remaining computing power resources, wherein the priority level of the devices in the fourth set of devices is lower than the priority level of the devices in the third set of devices.
[0101] Optionally, the fourth connection unit includes: a judgment subunit, used to judge whether the remaining computing power resources are greater than a preset computing power value; a selection subunit, used to continue selecting a fourth device set in the device set in order based on the priority distribution information if the remaining computing power resources are greater than the preset computing power value; and a sending subunit, used to send a reconnection notification message to the fourth device set.
[0102] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.
[0103] Example 3
[0104] Embodiments of the present invention also provide a storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.
[0105] Optionally, in this embodiment, the storage medium can be configured to store a computer program for execution:
[0106] S1, confirming that the server has successfully restarted;
[0107] S2, Obtain priority distribution information of the device set associated with the server, wherein the device set includes multiple devices, and the priority distribution information is used to describe the priority level of each device;
[0108] S3, connect multiple devices in the device set in stages based on the priority distribution information.
[0109] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0110] Embodiments of the present invention also provide an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.
[0111] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0112] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0113] S1, confirming that the server has successfully restarted;
[0114] S2, Obtain priority distribution information of the device set associated with the server, wherein the device set includes multiple devices, and the priority distribution information is used to describe the priority level of each device;
[0115] S3, connect multiple devices in the device set in stages based on the priority distribution information.
[0116] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0117] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0118] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0119] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of units or modules may be electrical or other forms.
[0120] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0121] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0122] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, controller, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0123] The above are merely preferred embodiments of this application. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A connection method of a server, characterized by, include: The server has been confirmed to have restarted successfully. Obtain priority distribution information of the set of devices associated with the server, wherein the set of devices includes multiple devices, and the priority distribution information is used to describe the priority level of each device; Multiple devices in the device set are connected in stages based on the priority distribution information; Before confirming that the server has restarted completely, the method further includes: determining the update order of multiple microservices in the server program before the server program begins rolling updates, wherein the server program includes multiple microservices, each microservice corresponding to a software function; updating the multiple microservices in the server program in order of priority; determining the partition device corresponding to each microservice; configuring the priority level of each partition device according to the update order, and notifying the partition device so that the partition device can adjust its own connection strategy; The step of connecting multiple devices in the device set in stages based on the priority distribution information includes: selecting a first device set with a preset proportion in the device set according to the priority distribution information; sending a reconnection notification message to the first device set and monitoring the real-time proportion of successfully connected devices in the first device set; and continuing to connect to a second device set in the device set based on the real-time proportion, wherein the priority level of the devices in the second device set is lower than the priority level of the devices in the first device set.
2. The method according to claim 1, characterized in that, Before confirming that the server has completed its restart, the method further includes: Before the server program begins the shutdown update, obtain the device attributes of each device in the device set; Configure the priority level of the corresponding device based on the device attributes, and notify the device.
3. The method according to claim 2, characterized in that, Configuring the priority level of the corresponding device based on the aforementioned device attributes includes: The function type of the first device is parsed based on the device attributes, wherein the function type includes gateway function and storage function; If the first device is a gateway device, the first device is configured to a first priority level; if the first device is a storage device, the first device is configured to a second priority level, wherein the first priority level is higher than the second priority level.
4. The method according to claim 2, characterized in that, Configuring the priority level of the corresponding device based on the aforementioned device attributes includes: The usage frequency of the second device is analyzed based on the device attributes. Determine whether the usage frequency is greater than a preset threshold; If the usage frequency is greater than a preset threshold, the second device is configured as the third priority level; if the usage frequency is less than or equal to the preset threshold, the second device is configured as the fourth priority level, wherein the third priority level is higher than the fourth priority level.
5. The method according to claim 2, characterized in that, Configuring the priority level of the corresponding device based on the aforementioned device attributes includes: Based on the device attributes, the user priority of the user to whom the third device belongs is determined; The priority level of the third device is configured based on the user priority, wherein the priority level is positively correlated with the user priority.
6. The method according to claim 1, characterized in that, Continuing to connect to the second set of devices in the device set based on the real-time ratio value includes: Determine whether the real-time ratio value has reached the preset ratio value; If the real-time ratio value does not reach the preset ratio value, the second set of devices is selected sequentially from the set of devices based on the priority distribution information. Send a reconnection notification message to the second set of devices.
7. The method according to claim 1, characterized in that, Connecting multiple devices in the device set in stages based on the priority distribution information includes: Based on the priority distribution information, a third set of devices is selected in sequence from the set of devices at a predetermined ratio; Send a reconnection notification message to the third set of devices and monitor the remaining computing power resources of the server; Based on the remaining computing power resources, continue to connect to the fourth device set in the device set, wherein the priority level of the devices in the fourth device set is lower than the priority level of the devices in the third device set.
8. The method according to claim 7, characterized in that, Continuing to connect to the fourth device set in the device set based on the remaining computing resources includes: Determine whether the remaining computing power resources are greater than the preset computing power value; If the remaining computing power resources are greater than the preset computing power value, the fourth set of devices will be selected sequentially from the set of devices based on the priority distribution information. Send a reconnection notification message to the fourth set of devices.
9. A server, characterized in that, include: The first determination module is used to determine that the server has completed the restart process; The first acquisition module is used to acquire priority distribution information of a set of devices associated with the server, wherein the set of devices includes multiple devices, and the priority distribution information is used to describe the priority level of each device; The connection module is used to connect multiple devices in the device set in stages based on the priority distribution information; The server device further includes: a second determining module, configured to determine the update order of multiple microservices in the server program before the first determining module determines that the server has completed restarting and before the server program begins rolling updates, wherein the server program includes the multiple microservices, each microservice corresponding to a software function, and when updating the multiple microservices in the server program, the microservices are updated sequentially according to priority; a third determining module, configured to determine the partition device corresponding to each microservice; and a second configuration module, configured to configure the priority level of each partition device according to the update order and notify the partition device. The connection module includes: a first selection unit, configured to select a first set of devices in the device set in sequence according to a preset proportion based on the priority distribution information; a first connection unit, configured to send a reconnection notification message to the first set of devices and monitor the real-time proportion of successful connections in the first set of devices; and a second connection unit, configured to continue connecting to a second set of devices in the device set based on the real-time proportion, wherein the priority level of the devices in the second set of devices is lower than the priority level of the devices in the first set of devices.
10. A storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to execute the steps of the server connection method according to any one of claims 1 to 8 when it runs.
11. An electronic device comprising a processor, a communication interface, a memory, and a communication bus, wherein, The processor, communication interface, and memory communicate with each other via a communication bus; among which: Memory, used to store computer programs; A processor for executing the steps of the server connection method according to any one of claims 1 to 8 by running a program stored in memory.