Resource expansion method and device, equipment and storage medium
By automatically monitoring the use of server resources and triggering capacity expansion operations based on preset conditions, the problems of inefficient resource expansion and lack of automatic decision-making capabilities in the existing technology are solved, and more efficient resource expansion and more accurate resource demand prediction are achieved.
Patent Information
- Application Number
- CN202510308214.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-17
- Publication Date
- 2025-04-15
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, the lack of automatic decision-making capabilities leads to inefficient resource expansion and the inability to dynamically expand according to the actual needs of the server, which easily leads to waste or insufficient resources.
After performing the Nth resource expansion, obtain the attribute status of the server, determine whether the resource expansion trigger condition is reached, and calculate whether the time interval reaches the resource expansion cycle, and automatically decide whether the N+1st resource expansion is performed.
The automatic decision-making ability of the service system is realized, the efficiency of resource expansion is improved, and the resource expansion is ensured based on the actual needs of the server, avoiding waste or insufficient resources.
Smart Images

Figure CN119829399A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a resource expansion method, device, equipment and storage medium. Background Art
[0002] With the development of the Internet, the number of Internet users continues to increase, and the requirements for the stability of Internet services continue to increase. The stability of websites has an increasingly greater impact on the stability of users. How to improve the stability of website services is an unavoidable problem.
[0003] In the related technologies, one of the ways to improve the stability of website services is to perform resource expansion and high-availability processing. The traditional processing method is to manually perform resource expansion and high-availability service deployment through manual methods.
[0004] However, as the size of server clusters increases, the requirements for operation and maintenance personnel become increasingly higher, and there is a lack of automatic decision-making capabilities and inefficient resource expansion plans. Summary of the invention
[0005] In order to solve the above technical problems, the present application provides a resource expansion method, device, equipment and storage medium to realize the automatic decision-making capability of the service system and improve the efficiency of resource expansion.
[0006] In a first aspect, the present application provides a resource expansion method, the method comprising: after executing the Nth resource expansion, obtaining the attribute status of the server, the attribute status is used to reflect the resource usage of the server, N is greater than or equal to 1; judging whether the attribute status of the server reaches the resource expansion trigger condition; when the attribute status of the server reaches the resource expansion trigger condition, obtaining the time interval between the current time point and the time point of the Nth execution of the resource expansion operation; judging whether the time interval reaches the resource expansion cycle, the resource expansion cycle is the average time interval of the previous N resource expansions; when the time interval reaches the resource expansion cycle, performing the N+1th resource expansion on the server.
[0007] In a second aspect, the present application provides a resource expansion device, which includes: an attribute status acquisition module, which is used to acquire the attribute status of the server after executing the Nth resource expansion, the attribute status is used to reflect the resource usage of the server, and N is greater than or equal to 1; a trigger condition judgment module, which is used to judge whether the attribute status of the server reaches the resource expansion trigger condition; a time interval acquisition module, which is used to acquire the time interval between the current time point and the time point of the Nth execution of the resource expansion operation when the attribute status of the server reaches the resource expansion trigger condition; a time interval judgment module, which is used to judge whether the time interval reaches the resource expansion cycle, and the resource expansion cycle is the average time interval of the previous N resource expansions; a resource expansion module, which is used to perform the N+1th resource expansion on the server when the time interval reaches the resource expansion cycle.
[0008] In a third aspect, the present application provides a resource expansion device, which includes: one or more processors; a storage device for storing one or more programs; when the one or more programs are executed by one or more processors, the one or more processors implement the resource expansion method as described in the first aspect above.
[0009] In a fourth aspect, the present application provides a storage medium, which may be a computer-readable storage medium, storing a computer program thereon, which, when executed by a processor, implements the resource expansion method in the first aspect described above.
[0010] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the resource expansion method as described in any one of the above-mentioned first aspects is implemented.
[0011] An embodiment of the present application provides a resource expansion method, apparatus, device and storage medium, the method comprising: after executing the Nth resource expansion, obtaining an attribute state reflecting the resource usage of the server, and determining whether the attribute state reaches the resource expansion trigger condition; when the attribute state of the server reaches the resource expansion trigger condition, obtaining the time interval between the current time point and the time point when the resource expansion operation is executed for the Nth time; determining whether the time interval reaches the average time interval of the previous N resource expansions; when the time interval reaches the average time interval, executing the N+1th resource expansion on the server.
[0012] Compared with the prior art, the technical solution provided by the embodiments of the present application has the following advantages: 1) By automatically monitoring server resource usage and triggering capacity expansion operations based on preset conditions, the need for manual intervention is reduced, the service system's automatic decision-making capabilities are realized, and the efficiency of resource expansion is improved.
[0013] 2) Resource expansion is triggered when the resource usage of the server reaches the trigger condition. That is, resource expansion is triggered based on the actual needs of the server, rather than according to a fixed schedule, to prevent resource waste or resource shortage.
[0014] 3) Use the average time interval of the previous N resource expansions to decide whether to perform the N+1th expansion. Based on historical data, it can more accurately predict future resource requirements and make more reasonable expansion decisions.
[0015] 4) A time interval check mechanism is introduced to ensure that there is enough time difference between two capacity expansions, which can avoid unnecessary frequent capacity expansions caused by short-term load peaks and help stabilize system performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0018] Figure 1 A schematic diagram of a process flow of a resource expansion method provided in an embodiment of the present application; Figure 2 A flowchart of another resource expansion method provided in an embodiment of the present application; Figure 3 A flowchart of another resource expansion method provided in an embodiment of the present application; Figure 4 A schematic diagram of the structure of a resource expansion device provided in an embodiment of the present application; Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0019] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0020] In the following description, many specific details are set forth to facilitate a full understanding of the present application, but the present application may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only part of the embodiments of the present application, rather than all of the embodiments.
[0021] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0022] It should be noted that the concepts such as "first" and "second" mentioned in this application are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0023] It should be noted that the modifications of "one" and "plurality" mentioned in the present application are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0024] The resource expansion method provided by the present application is described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0025] Embodiment 1: Figure 1 This is a flow chart of a resource expansion method in an embodiment of the present application. This embodiment is applicable to the situation of expanding service resources. The method can be executed by a resource expansion device. The resource expansion device can be implemented in software and / or hardware. The resource expansion device can be configured in an electronic device.
[0026] like Figure 1 As shown, the resource expansion method provided in the embodiment of the present application mainly includes steps S101-S105.
[0027] S101. After executing the Nth resource expansion, obtain the attribute status of the server, where the attribute status is used to reflect the resource usage of the server, and N is greater than or equal to 1.
[0028] Resource expansion refers to increasing or upgrading server hardware and / or software resources to improve server performance, capacity or reliability. The attribute status of a server refers to the current characteristics and operating conditions of the server. The attribute status of a server is mainly used to reflect the resource usage of the server. Specifically, the attribute status of a server may include at least one of the following: the CPU occupancy rate of the server, the memory occupancy rate of the server, and the storage occupancy rate of the server.
[0029] The above server can be a single deployed server or any server in a server cluster.
[0030] The server CPU utilization rate refers to the proportion of time the CPU is used to execute tasks, reflecting how busy the CPU is within a given time. The server memory utilization rate refers to the ratio of used physical memory (such as RAM) on the server to the total available physical memory, reflecting the workload the server is processing, where the physical memory can be random access memory (RAM). The server storage utilization rate refers to the ratio of used space in the server storage device to the total available storage space. Server storage devices can include: hard disks, mechanical hard disks (Hard Disk Drive, HDD), solid state drives (Solid State Disk or Solid State Drive, SSD), etc.
[0031] After executing the Nth resource expansion, obtaining the attribute status of the server includes: after executing the Nth resource expansion, obtaining the attribute status of the server in real time, or after executing the Nth resource expansion, obtaining the attribute status of the server periodically.
[0032] After executing the Nth resource expansion, obtaining the attribute status of the server can be understood as starting to obtain the attribute status of the server after the previous resource expansion, so as to determine whether it is necessary to execute resource expansion again according to the attribute status of the server.
[0033] The attribute status of the server can be obtained by using a command line tool corresponding to the operating system of the server or by using the command line tool of the server. The attribute status of the server can be obtained by at least one of the following: obtaining the CPU occupancy rate of the server, obtaining the memory occupancy rate of the server, and obtaining the storage occupancy rate of the server.
[0034] For example, if the server's operating system is Linux, obtaining the server's central processing unit CPU usage may include: using the top command or the more lightweight htop to obtain a real-time updated task list that includes the CPU usage of each process. Or use the mpstat command to obtain more detailed CPU statistics. Obtaining the server's memory usage includes: using the free -m command to obtain the server's memory usage. Obtaining the server's storage usage includes: using the df -h command to view the disk space usage, including all mount points and their respective usage percentages.
[0035] S102: Determine whether the attribute status of the server reaches a resource expansion trigger condition.
[0036] Resource expansion trigger conditions refer to the conditions that trigger the resource expansion process when the attribute status of the server reaches the preset threshold or meets specific rules during the server monitoring process. Resource expansion trigger conditions are set based on server performance and service quality to ensure the stability and response speed of the service system while avoiding unnecessary waste of resources.
[0037] In a possible implementation, the attribute status of the server includes the server CPU occupancy rate, the server memory occupancy rate, and the server storage occupancy rate.
[0038] Whether the attribute status of the server meets the trigger conditions, including at least one of the following: the server CPU occupancy rate reaches a first threshold, and the duration of the server CPU occupancy rate reaching the first threshold exceeds the first duration, the first threshold is the average CPU occupancy rate of N resource expansions, and the first duration is the average duration of the CPU occupancy rate for N resource expansions; the server memory occupancy rate reaches a second threshold, and the duration of the server memory occupancy rate reaching the second threshold exceeds the second duration, the second threshold is the average memory occupancy rate of N resource expansions, and the second duration is the average duration of the memory occupancy rate for N resource expansions; the server storage occupancy rate reaches a third threshold, and the duration of the server storage occupancy rate reaching the third threshold exceeds the third duration, the third threshold is the average storage occupancy rate of N resource expansions, and the third duration is the average duration of the storage occupancy rate for N resource expansions.
[0039] The first threshold, the second threshold, and the third threshold may be the same or different, and are not specifically limited in this embodiment. For example, the first threshold, the second threshold, and the third threshold are all 90%. The first duration, the second duration, and the third duration may be the same or different, and are not specifically limited in this embodiment. For example, the first duration, the second duration, and the third duration are all 10 minutes.
[0040] In an embodiment of the present application, the attribute status of the server and the duration of each attribute status within a short time range are obtained and parsed and recorded in a database; multiple historical data of the attribute status of the server are continuously recorded, and resource expansion trigger conditions are automatically counted based on the historical data.
[0041] Recording the attribute status of the server each time the server resources are expanded can be understood as reaching the resource expansion triggering condition, triggering the attribute status of the server for the second server resource expansion. The attribute status of the server includes the server CPU occupancy rate, server memory occupancy rate, and server storage occupancy rate.
[0042] After N resource expansions are performed, the attribute states of N servers are cumulatively recorded, and an average value of the attribute states of the N servers is calculated as a trigger condition for the N+1th resource expansion.
[0043] Specifically, after executing N resource expansions, the CPU occupancy rates of N servers, the memory occupancy rates of N servers, and the storage occupancy rates of N servers are cumulatively recorded. The average value of the CPU occupancy rates of the N servers is calculated as the first threshold, and the average value of the duration of the CPU occupancy rates of the N servers is calculated as the first duration. The average value of the memory occupancy rates of the N servers is calculated as the second threshold, and the average value of the duration of the memory occupancy rates of the N servers is calculated as the second duration. The average value of the storage occupancy rates of the N servers is calculated as the third threshold, and the average value of the duration of the storage occupancy rates of the N servers is calculated as the third duration.
[0044] In the embodiment of the present application, historical data based on server attribute status is used as a benchmark condition for resource expansion judgment, which can more accurately predict future resource requirements and thus make more reasonable expansion decisions.
[0045] Determine whether the attribute status of the server meets the resource expansion trigger condition, including: determining whether the server CPU occupancy rate reaches the first threshold, and whether the duration of the server CPU occupancy rate reaching the first threshold exceeds the first duration, determining whether the server memory occupancy rate reaches the second threshold, and whether the duration of the server memory occupancy rate reaching the second threshold exceeds the second duration; determine whether the server storage occupancy rate reaches the third threshold, and whether the duration of the server storage occupancy rate reaching the third threshold exceeds the third duration. If all of the above three trigger conditions are met, it is determined that the resource expansion trigger condition is met. If any of the above three trigger conditions is not met, it is determined that the resource expansion trigger condition is not met, and return to execute step S101 to re-acquire the attribute status of the server.
[0046] Exemplarily, it is determined whether the server CPU occupancy rate reaches 90%, and whether the duration of the server CPU occupancy rate reaching 90% exceeds 10 minutes; it is determined whether the server memory occupancy rate reaches 90%, and whether the duration of the server memory occupancy rate reaching 90% exceeds 10 minutes; it is determined whether the server storage occupancy rate reaches 90%, and whether the duration of the server storage occupancy rate reaching 90% exceeds 10. If all of the above three trigger conditions are met, it is determined that the resource expansion trigger condition is met.
[0047] S103: When the attribute status of the server reaches the resource expansion triggering condition, obtain the time interval between the current time point and the time point of performing the resource expansion operation for the Nth time.
[0048] The current time point refers to the time point when the attribute status of the server is obtained, or the time point when it is determined that the attribute status of the server reaches the resource expansion trigger condition. The time point when the resource expansion operation is performed for the Nth time refers to the specific time point when the resource expansion operation is performed for the Nth time. The time interval refers to the difference between the current time point and the time point when the resource expansion operation is performed for the Nth time. For example: the current time point is 14:13 on December 20, 2024, and the time point when the resource expansion operation is performed for the Nth time is 15:10:30 on December 20, 2024, then the calculated time interval is 5 days, 3 hours and 43 minutes.
[0049] In the embodiment of the present application, it is determined in S102 that the attribute state of the server reaches the resource expansion trigger condition, that is, the server CPU occupancy rate reaches the first threshold, and the duration of the server CPU occupancy rate reaching the first threshold exceeds the first duration; the server memory occupancy rate reaches the second threshold, and the duration of the server memory occupancy rate reaching the second threshold exceeds the second duration; the server storage occupancy rate reaches the third threshold, and the duration of the server storage occupancy rate reaching the third threshold exceeds the third duration. Then, the time interval between the current time point and the time point of the Nth execution of the resource expansion operation is obtained.
[0050] For example, the server CPU occupancy rate reaches 90%, and the duration of the server CPU occupancy rate reaching 90% exceeds 10 minutes, the server memory occupancy rate reaches 90%, and the duration of the server memory occupancy rate reaching 90% exceeds 10 minutes; whether the server storage occupancy rate reaches 90%, and the duration of the server storage occupancy rate reaching 90% exceeds 10. Then, the time interval between the current time point and the time point of the Nth execution of the resource expansion operation is obtained.
[0051] S104: Determine whether the time interval reaches a resource expansion period, where the resource expansion period is an average time interval between N resource expansions.
[0052] The resource expansion cycle refers to the average time interval between resource expansion operations within a certain period of time.
[0053] After executing N resource expansions, after determining that the server's attribute status meets the resource expansion conditions, determine whether the time interval reaches the resource expansion cycle to ensure that there is enough time difference between the two expansions. This can avoid unnecessary frequent expansions caused by short-term load peaks and help stabilize system performance.
[0054] In an embodiment of the present application, a method for calculating a resource expansion cycle is provided. While accumulating and recording the attribute states of N servers, the time point of each resource expansion operation is recorded to obtain the time points of N resource expansion operations. The time interval between two adjacent resource expansion operations is calculated to obtain the time interval of N-1, and then the average value of the time interval of N-1 is calculated as the resource expansion cycle.
[0055] For example, let N be 4. A system has performed 4 resource expansion operations in the past 12 months, which occurred on: the time point of the first resource expansion operation is January 1, 2024; the time point of the second resource expansion operation is March 15, 2024; the time point of the third resource expansion operation is June 10, 2024; and the time point of the fourth resource expansion operation is September 20, 2024. The time interval from the first resource expansion operation to the second resource expansion operation is 74 days; the time interval from the second resource expansion operation to the third resource expansion operation is 87 days; the time interval from the third resource expansion operation to the fourth resource expansion operation is 102 days; the average value of the three time intervals is 263 days / 3=about 87.67 days, so 87.67 days is the judgment condition for determining whether to perform resource expansion for the fifth time, that is, 87.67 days is the resource expansion cycle.
[0056] Determine whether the time interval reaches the resource expansion cycle. If the time interval reaches the resource expansion cycle, it means that there is enough time difference between the two expansions, and resource expansion can be performed again. If the time interval does not reach the resource expansion cycle, it means that the time difference between the two expansions is small, and it is not advisable to perform expansion operations frequently.
[0057] Furthermore, if the time interval does not reach the resource expansion cycle, it indicates that the time difference between the two expansions is small, but the attribute status of the server reaches the resource expansion trigger condition, which means that there are some abnormal conditions or the business volume suddenly increases, and a message is sent to remind the administrator to check the specific situation. By sending information to remind the administrator in time, measures can be taken before the problem worsens to prevent potential problems from becoming actual failures, thereby ensuring the stability and reliability of the system. And when the attribute status of the server reaches the resource expansion trigger condition, it indicates that the server performance indicators suddenly exceed expectations. At this time, the administrator is notified immediately to intervene, which can avoid service interruption or performance degradation caused by delayed response.
[0058] S105: When the time interval reaches the resource expansion period, perform the N+1th resource expansion on the server.
[0059] If the attribute status of the server reaches the resource expansion triggering condition, and the time interval between the current time point and the time point of the Nth execution of the resource expansion operation reaches the resource expansion period, resource expansion is automatically performed.
[0060] Resource expansion includes increasing computing power (such as CPU), expanding storage space, or improving network bandwidth, etc.
[0061] The resource expansion method provided in the embodiment of the present application obtains the attribute status reflecting the resource usage of the server after executing the Nth resource expansion, and determines whether the attribute status reaches the resource expansion trigger condition; when the attribute status of the server reaches the resource expansion trigger condition, obtains the time interval between the current time point and the time point of the Nth execution of the resource expansion operation; determines whether the time interval reaches the average time interval of the previous N resource expansions; when the time interval reaches the average time interval, performs the N+1th resource expansion on the server.
[0062] Compared with the prior art, the technical solution provided by the embodiments of the present application has the following advantages: 1) By automatically monitoring server resource usage and triggering capacity expansion operations based on preset conditions, the need for manual intervention is reduced, the service system's automatic decision-making capabilities are realized, and the efficiency of resource expansion is improved.
[0063] 2) Resource expansion is triggered when the resource usage of the server reaches the trigger condition. That is, resource expansion is triggered based on the actual needs of the server, rather than according to a fixed schedule, to prevent resource waste or resource shortage.
[0064] 3) Use the average time interval of the previous N resource expansions to decide whether to perform the N+1th expansion. Based on historical data, it can more accurately predict future resource requirements and make more reasonable expansion decisions.
[0065] 4) A time interval check mechanism is introduced to ensure that there is enough time difference between two capacity expansions, which can avoid unnecessary frequent capacity expansions caused by short-term load peaks and help stabilize system performance.
[0066] Embodiment 2: Based on the above embodiments, the present application further optimizes the resource expansion method, such as Figure 2 As shown, the optimized resource expansion method provided in the embodiment of the present application mainly includes steps S201-S205.
[0067] S201. After executing the Nth resource expansion, obtain the service parallelism.
[0068] Service parallelism refers to the number of service instances or tasks that the server is executing at the same time. The above tasks can be HTTP requests, database queries, API calls, file transfers, etc. Service parallelism can directly reflect the server's concurrent processing capabilities and service load.
[0069] After the Nth resource expansion is performed, the service parallelism amount is obtained in real time or periodically for the above server.
[0070] Obtaining the service parallelism includes: installing a log collection tool in the server, using the log collection tool to collect service operation logs, and extracting the service parallelism from the service operation logs.
[0071] S202: Determine whether the service parallelism reaches a fourth threshold and whether the duration of reaching the fourth threshold exceeds a fourth duration, where the fourth threshold is the average service parallelism during N resource expansions.
[0072] The fourth threshold is the average service parallelism during N resource expansions, and the fourth duration refers to the duration of the service parallelism during N resource expansions.
[0073] After executing N resource expansions, N service parallelisms are cumulatively recorded, and an average value of the N service parallelisms is calculated as a trigger condition for the N+1th resource expansion.
[0074] Specifically, after N resource expansions are performed, the service parallelism of N servers is cumulatively recorded. The average value of the N service parallelisms is calculated as the fourth threshold, and the average value of the duration of the N service parallelisms is calculated as the fourth duration. Then, it is determined whether the service parallelism reaches the fourth threshold, and whether the duration of reaching the fourth threshold exceeds the fourth duration.
[0075] Exemplarily, determine whether the service parallelism reaches 2048, and whether the duration of the service parallelism reaching 2048 exceeds 10 minutes. If so, determine that the resource expansion trigger condition is met. If not, determine that the resource expansion trigger condition is not met, and return to step S201 to continue obtaining the service parallelism.
[0076] S203: If the service parallelism reaches a fourth threshold, and the duration of reaching the fourth threshold exceeds a fourth duration, obtain the time interval between the current time point and the time point of performing the resource expansion operation for the Nth time.
[0077] In the embodiment of the present application, when the service parallelism reaches a fourth threshold and the duration of reaching the fourth threshold exceeds a fourth duration, the time interval between the current time point and the time point of performing the resource expansion operation for the Nth time is obtained.
[0078] Exemplarily, if the service parallelism reaches 2024, and the duration of the service parallelism reaching 2024 exceeds 10 minutes, then the time interval between the current time point and the time point of performing the resource expansion operation for the Nth time is obtained.
[0079] The process of obtaining the time interval is consistent with the process of obtaining the time interval provided in the above embodiment. For details, please refer to the description in the above embodiment, and will not be repeated in the embodiments of the present application.
[0080] S204: Determine whether the time interval reaches a resource expansion period, where the resource expansion period is an average time interval between N resource expansions.
[0081] S205: When the time interval reaches the resource expansion period, perform the N+1th resource expansion on the server.
[0082] S204-S205 provided in the embodiment of the present application is the same as the execution process of S104-S105 provided in the above embodiment. For details, please refer to the description in the above embodiment, which will not be repeated in the embodiment of the present application.
[0083] In the embodiment of the present application, the service parallelism directly reflects the user's request processing capabilities and the business needs of the system. By monitoring the service parallelism, the performance of the system in responding to user requests can be directly measured. By determining whether resource expansion is needed based on the service parallelism, the user experience can be improved without being affected.
[0084] In one possible implementation, for any service, the response status of the service is obtained; if the response status of the service is unresponsive, and the duration of the unresponsiveness of the service exceeds the fifth duration, it is determined whether the server is in a running state; if the server is in a running state, the service is controlled to perform a restart operation; if the server is not in a non-running state, the server is controlled to perform a startup operation.
[0085] The response status of a service refers to the status information returned to the client when the service processes a request, which reflects the current working status of the service and the result of processing the request. It is usually expressed in HTTP status codes, status fields in custom protocols, or other forms.
[0086] The response status of the service is unresponsive, which usually means that the client failed to successfully obtain the expected response when trying to communicate with the service. Unresponsiveness includes one or more of the following: After receiving the request sent by the client, the server did not send a response to the client within the specified time. The server returned data format or content that did not meet the expectations. The server explicitly rejected the client's connection request.
[0087] For each running service in the server, while obtaining the service parallelism, obtain the response status of each service and the duration of the service in the response status from the server operation log.
[0088] If the response status of the service is unresponsive, and the duration of the unresponsiveness of the service exceeds the fifth duration, it indicates that a serious health problem has occurred in the service, which may be caused by the server or the service itself.
[0089] Therefore, it is necessary to determine whether the server is in a running state. If the server is in a running state, it indicates that the cause of the health problem of the service is the service itself, so the service is controlled to perform a restart operation to try to restore the normal operation of the service. If the server is not in a running state, it indicates that the cause of the health problem of the service is that the server itself is not in a running state, so the server needs to be started so that the service can have a chance to restart.
[0090] In this way, faults can be responded to and handled in a timely manner, shortening the time window of service unavailability and improving the overall availability of the system.
[0091] Embodiment three: Based on the above embodiments, the present application further optimizes the resource expansion method, such as Figure 3 As shown, the optimized resource expansion method provided in the embodiment of the present application mainly includes steps S301-S305.
[0092] In the above-mentioned embodiments, it is mainly introduced how to judge whether to perform resource expansion, and the embodiments of the present application mainly introduce how to perform resource expansion.
[0093] S301. Obtain the response time of the server.
[0094] The server's response time refers to the time it takes from the client sending a request to receiving a complete response. It includes network latency, server processing time, and possible queuing time.
[0095] Run the ping command and use the top command to monitor the server running status. Extract the server response time from the server running status.
[0096] S302: Determine whether the response time of the server is less than a fifth threshold value. If so, execute S303; if not, execute S304.
[0097] The fifth threshold is a preset time length (eg, 5 seconds, 10 seconds, etc.) used to determine whether the server response is too slow. Further, the fifth threshold is used to distinguish values of different processing logics.
[0098] S303: Control the server to perform a restart operation.
[0099] If the server response time is less than the fifth threshold, it indicates that the server response speed is slow, which may be due to underutilization of system resources or potential minor problems that lead to temporary inefficiency. Restart the server to clean up possible minor problems, such as memory leaks and temporary file accumulation, to increase server resources and avoid server overload.
[0100] Control server reboot, including: for Linux servers, you can remotely execute the reboot command through SSH; you can also implement the server automatic reboot function through API calls.
[0101] S304: Select a server from the candidate server resource pool as an expansion server, and adjust the services in the server to the expansion server.
[0102] If the server response time is greater than or equal to the fifth threshold, it indicates that the server is responding slowly, which may be due to excessive load, insufficient resources or other deep-seated problems. It is necessary to automatically select and configure a new server as an expansion server, join the existing cluster, and migrate part of the traffic to the expansion server.
[0103] Further, according to business needs and technical requirements, select a suitable physical machine or virtual machine from the candidate server resource pool as the expansion server. Confirm that the network connection between the expansion server and the existing server is normal and can perform file transfer and service communication.
[0104] In the embodiment of the present application, restarting the server when the response time is less than the fifth threshold can help eliminate potential minor problems and prevent them from gradually deteriorating into major failures, and increase server resources by restarting to avoid server overload. When the response time is greater than or equal to the fifth threshold, immediately adding new server resources can effectively relieve pressure and ensure stable operation of the system.
[0105] Specifically, adjusting the service in the server to the expansion server includes: copying the service files in the server to the expansion server; deploying the basic environment required for the service in the expansion server; deploying and controlling the service startup; adding a load balancing control component in the expansion server.
[0106] Use rsync, scp or other file transfer tools to safely copy the service files on the original server to the expansion server. Furthermore, you can check whether the service files have been transferred completely and correctly to the new server by verifying the file hash value to ensure consistency.
[0107] Install the necessary operating system packages, libraries, and tools on the expansion server according to the service requirements. For example, for Python applications, you may need to install the Python interpreter, pip, etc. Set environment variables to point to key information such as the correct library path, database connection string, etc. If the service depends on a database, ensure that the database has been initialized correctly and that the expansion server can access the database.
[0108] Create a dedicated operating system user for the service and write or copy an existing startup script to manage starting, stopping, and restarting the service through standard commands. Use systemctl status myservice or similar commands to check that the service started successfully and is running properly.
[0109] In the embodiment of the present application, by adding new servers, the system can handle more concurrent requests. After multiple servers share the traffic, the pressure on a single server is reduced, thereby improving the response speed and user experience.
[0110] Embodiment 4: Figure 4 is a schematic diagram of the structure of a resource expansion device in an embodiment of the present application, such as Figure 4 As shown, the resource expansion device 40 provided in the embodiment of the present application mainly includes: an attribute state acquisition module 41, a trigger condition judgment module 42, a time interval acquisition module 43, a time interval judgment module 44 and a resource expansion module 45.
[0111] Among them, the attribute status acquisition module 41 is used to obtain the attribute status of the server after executing the Nth resource expansion, and the attribute status is used to reflect the resource usage of the server, where N is greater than or equal to 1; the trigger condition judgment module 42 is used to judge whether the attribute status of the server reaches the resource expansion trigger condition; the time interval acquisition module 43 is used to obtain the time interval between the current time point and the time point of the Nth execution of the resource expansion operation when the attribute status of the server reaches the resource expansion trigger condition; the time interval judgment module 44 is used to judge whether the time interval reaches the resource expansion cycle, and the resource expansion cycle is the average time interval of the previous N resource expansions; the resource expansion module 45 is used to perform the N+1th resource expansion on the server when the time interval reaches the resource expansion cycle.
[0112] In one possible implementation, the attribute status of the server includes the server CPU occupancy rate, the server memory occupancy rate and the server storage occupancy rate; whether the attribute status of the server meets the resource expansion trigger condition includes at least one of the following: the server CPU occupancy rate reaches a first threshold, and the duration of the server CPU occupancy rate reaching the first threshold exceeds the first duration, the first threshold is the average CPU occupancy rate of N resource expansions, and the first duration is the average duration of the CPU occupancy rate of N resource expansions; the server memory occupancy rate reaches a second threshold, and the duration of the server memory occupancy rate reaching the second threshold exceeds the second duration, the second threshold is the average memory occupancy rate of N resource expansions, and the second duration is the average duration of the memory occupancy rate of N resource expansions; the server storage occupancy rate reaches a third threshold, and the duration of the server storage occupancy rate reaching the third threshold exceeds the third duration, the third threshold is the average storage occupancy rate of N resource expansions, and the third duration is the average duration of the storage occupancy rate of N resource expansions.
[0113] In one possible implementation, the trigger condition judgment module 42 is also used to obtain the service parallelism before obtaining the time interval between the current time point and the time point of performing the resource expansion operation for the Nth time and after performing the Nth resource expansion; to determine whether the service parallelism has reached a fourth threshold and whether the duration of reaching the fourth threshold exceeds the fourth duration, where the fourth threshold is the average service parallelism during the previous N resource expansions; the time interval acquisition module 43 is also used to obtain the time interval between the current time point and the time point of performing the resource expansion operation for the Nth time if the service parallelism reaches the fourth threshold and the duration of reaching the fourth threshold exceeds the fourth duration.
[0114] In a possible implementation, it also includes: a restart module, which is used to obtain the response status of any service; if the response status of the service is unresponsive, and the duration of the unresponsiveness of the service exceeds the fifth duration, then determine whether the server is in a running state; if the server is in a running state, control the service to perform a restart operation; if the server is in a non-running state, control the server to perform a startup operation.
[0115] In a possible implementation, the resource expansion module 45 is specifically configured to obtain the response time of the server; when the response time of the server is less than a fifth threshold, the server is controlled to perform a restart operation.
[0116] In a possible implementation, the resource expansion module 45 is specifically configured to select a server from the candidate server resource pool as an expansion server when the response time of the server is greater than or equal to a fifth threshold; and adjust the service in the server to the expansion server.
[0117] In a possible implementation, the resource expansion module 45 is specifically used to copy the service files in the server to the expansion server; deploy the basic environment required for the service in the expansion server; deploy and control the service startup; and add a load balancing control component in the expansion server.
[0118] The resource expansion device provided in the embodiment of the present application can execute the resource expansion method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0119] Embodiment five: Figure 5 is a schematic diagram of the structure of an electronic device provided in this embodiment. The electronic device may include a resource expansion device, such as Figure 5 As shown, the electronic device 500 includes a processor 510, a memory 520, an input device 530, and an output device 540; the number of the processor 510 in the electronic device can be one or more. Figure 5 A processor 510 is taken as an example; the processor 510, the memory 520, the input device 530 and the output device 540 in the electronic device can be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.
[0120] The memory 520 is a computer-readable storage medium that can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the resource expansion method in the embodiment of the present invention. The processor 510 executes various functional applications and data processing of the electronic device by running the software programs, instructions and modules stored in the memory 520, that is, implements the resource expansion method provided in the embodiment of the present invention.
[0121] The memory 520 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 520 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 520 may further include a memory remotely arranged relative to the processor 510, and these remote memories may be connected to the electronic 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.
[0122] The input device 530 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the electronic device, and may include a keyboard, a mouse, etc. The output device 540 may include a display device such as a display screen.
[0123] This embodiment also provides a storage medium containing computer executable instructions, and when the computer executable instructions are executed by a computer processor, they are used to implement the resource expansion method provided in the embodiment of the present invention.
[0124] Of course, the computer executable instructions of a storage medium including computer executable instructions provided by an embodiment of the present invention are not limited to the operations of the method described above, but can also execute related operations in the resource expansion method provided by any embodiment of the present invention.
[0125] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an 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, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (FLASH), a hard disk or an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0126] It is worth noting that in the embodiment of the above-mentioned search device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0127] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0128] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A resource expansion method, characterized in that: The method comprises: After performing the Nth resource expansion, obtaining the attribute status of the server, the attribute status is used to reflect the resource usage of the server, N is greater than or equal to 1; Determining whether the attribute status of the server meets the resource expansion triggering condition; When the attribute state of the server reaches the resource expansion triggering condition, obtaining the time interval between the current time point and the time point of performing the resource expansion operation for the Nth time; Determine whether the time interval reaches a resource expansion period, where the resource expansion period is an average time interval of N resource expansions; When the time interval reaches the resource expansion period, the N+1th resource expansion is performed on the server.
2. The method according to claim 1, characterized in that The attribute status of the server includes server CPU occupancy rate, server memory occupancy rate and server storage occupancy rate; Whether the attribute status of the server reaches the resource expansion trigger condition, including at least one of the following: the CPU occupancy rate of the server reaches a first threshold, and the duration of the CPU occupancy rate of the server reaching the first threshold exceeds a first duration, the first threshold is the average CPU occupancy rate of N resource expansions, and the first duration is the average duration of the CPU occupancy rate of N resource expansions; The memory occupancy rate of the server reaches a second threshold, and the duration for which the memory occupancy rate of the server reaches the second threshold exceeds a second duration, the second threshold is the average memory occupancy rate of N resource expansions, and the second duration is the average duration for which the memory occupancy rate of N resource expansions lasts; The server storage occupancy rate reaches a third threshold, and the duration for which the server storage occupancy rate reaches the third threshold exceeds a third duration, the third threshold is the average storage occupancy rate of N resource expansions, and the third duration is the average duration of the storage occupancy rate of N resource expansions.
3. The method according to claim 1, characterized in that Before obtaining the time interval between the current time point and the time point of performing the resource expansion operation for the Nth time, the method further includes: After executing the Nth resource expansion, obtain the service parallelism; Determine whether the service parallelism reaches a fourth threshold, and whether the duration of reaching the fourth threshold exceeds a fourth duration, where the fourth threshold is the average service parallelism during the previous N resource expansions; If the service parallelism reaches a fourth threshold, and the duration of reaching the fourth threshold exceeds a fourth duration, an operation of obtaining a time interval between the current time point and the time point of performing the resource expansion operation for the Nth time is performed.
4. The method according to claim 3, characterized in that Also includes: For any service, obtain the response status of the service; If the response status of the service is unresponsive, and the duration of the unresponsiveness of the service exceeds a fifth duration, determining whether the server is in a running state; If the server is in a running state, controlling the service to perform a restart operation; If the server is in a non-operating state, controlling the server to perform a startup operation.
5. The method according to any one of claims 1 to 3, characterized in that: The performing the N+1th resource expansion on the server includes: Obtaining the response time of the server; When the response time of the server is less than a fifth threshold, the server is controlled to perform a restart operation.
6. The method according to claim 5, characterized in that Also includes: When the response time of the server is greater than or equal to a fifth threshold, selecting a server from a candidate server resource pool as an expansion server; The services in the server are transferred to the expansion server.
7. The method according to claim 6, characterized in that The step of adjusting the service in the server to the expansion server comprises: Copying the service files in the server to the expansion server; Deploy the basic environment required for the service in the expansion server; Deploy and control the startup of the service; A load balancing control component is added to the expansion server.
8. A resource expansion device, characterized in that: The device comprises: An attribute status acquisition module, used to acquire the attribute status of the server after performing the Nth resource expansion, wherein the attribute status is used to reflect the resource usage of the server, where N is greater than or equal to 1; A trigger condition judgment module, used to judge whether the attribute status of the server meets the resource expansion trigger condition; A time interval acquisition module, used to acquire the time interval between the current time point and the time point of performing the resource expansion operation for the Nth time when the attribute state of the server reaches the resource expansion triggering condition; A time interval determination module, used to determine whether the time interval reaches a resource expansion period, where the resource expansion period is the average time interval of the previous N resource expansions; The resource expansion module is used to perform the N+1th resource expansion on the server when the time interval reaches the resource expansion period.
9. An electronic device, characterized in that: The device comprises: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the resource expansion method according to any one of claims 1 to 7.
10. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the resource expansion method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Container dynamic capacity expansion and contraction method and system applied to cloud service
CN115309506A
Pod capacity control method and device
CN116701126A
Link resource capacity expansion method and device and storage medium
CN116915612A
Request management method and device, computer equipment and storage medium
CN117424822A
Method and device for expanding and shrinking capacity of cloud resources
CN117472567A