WO2020211253A1 - Elastic scaling method and apparatus for number of hosts in distributed system, and computer device - Google Patents

Elastic scaling method and apparatus for number of hosts in distributed system, and computer device Download PDF

Info

Publication number
WO2020211253A1
WO2020211253A1 PCT/CN2019/103546 CN2019103546W WO2020211253A1 WO 2020211253 A1 WO2020211253 A1 WO 2020211253A1 CN 2019103546 W CN2019103546 W CN 2019103546W WO 2020211253 A1 WO2020211253 A1 WO 2020211253A1
Authority
WO
WIPO (PCT)
Prior art keywords
hosts
host
preset
aging value
docker container
Prior art date
Application number
PCT/CN2019/103546
Other languages
French (fr)
Chinese (zh)
Inventor
赵骏
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020211253A1 publication Critical patent/WO2020211253A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3006Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is distributed, e.g. networked systems, clusters, multiprocessor systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3051Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Definitions

  • This application relates to the field of cloud computing technology, and in particular to a method, device and computer equipment for elastic scaling of the number of hosts in a distributed system.
  • the main purpose of this application is to provide a method, device, computer equipment and storage medium for elastic scaling of the number of hosts in a distributed system, which aims to solve the problem that the existing distributed system does not have the ability of host elastic scaling and has periodicity-based Distributed systems with elastic scaling capabilities will have technical problems such as inaccurate elastic scaling of the host and low flexibility.
  • this application proposes a method for elastic scaling of the number of hosts in a distributed system.
  • the method includes the steps:
  • Indicators include one or more of system response time, the number of pod functions in the Docker container, the resource consumption of the programs running in the Docker container, CPU usage, and memory usage;
  • the standard index threshold includes at least a first preset index threshold corresponding to the expansion process
  • This application also provides an elastic scaling device for the number of hosts in a distributed system, including:
  • the monitoring module is used to monitor the indicator parameter data of the Docker container corresponding to the host in real time, wherein the indicator parameter data is parameter data corresponding to the indicator input by the user, and the indicator is determined by the user according to the Docker container corresponding to the host Setting, the indicators include one or more of system response time, the number of pod functions in the Docker container, the resource consumption of programs running in the Docker container, the CPU usage rate, and the memory usage rate;
  • a comparison module configured to compare the index parameter data with a preset standard index threshold to obtain a comparison result, where the standard index threshold includes at least a first preset index threshold corresponding to the expansion process;
  • the first judgment module is configured to judge whether the comparison result is that the index parameter data is greater than the first preset index threshold
  • the first obtaining module is used to obtain the current first business volume data if yes;
  • the expansion module is used to expand the current number of first original hosts to the number of first hosts matching the first service volume data.
  • the application also provides a computer device, including a memory and a processor, the memory stores computer readable instructions, and the processor implements the steps of the above method when the computer readable instructions are executed.
  • the present application also provides a computer non-volatile readable storage medium on which computer readable instructions are stored, and when the computer readable instructions are executed by a processor, the steps of the above method are realized.
  • the method, device, computer equipment and storage medium for elastic scaling of the number of hosts in the distributed system monitor the indicator parameter data of the Docker container corresponding to the host in real time; compare the indicator parameter data with the preset standard indicator threshold to obtain Comparison result: According to the comparison result, the number of hosts is subjected to elastic scaling processing corresponding to the current business volume through a preset host scaling strategy, and the elastic scaling processing includes expansion processing or shrinking processing.
  • This application monitors the indicator parameter data of the Docker container corresponding to each host in real time after pre-setting the indicator of the Docker container corresponding to the host and the standard indicator threshold corresponding to the indicator, and then the indicator parameter data and the standard indicator threshold The comparison results are obtained, and the above host scaling strategy is used according to the comparison results to expand or shrink the current number of hosts corresponding to the current business volume, so as to realize the control of the host based on the real-time index parameter data of each host. Effective and accurate elastic scaling of the quantity ensures the efficient and stable operation of the system and effectively improves the resource utilization rate of the system.
  • FIG. 1 is a schematic flowchart of a method for elastic scaling of the number of hosts in a distributed system according to an embodiment of the present application
  • FIG. 2 is a schematic flowchart of a method for elastic scaling of the number of hosts in a distributed system according to another embodiment of the present application;
  • FIG. 3 is a schematic structural diagram of an elastic scaling device for the number of hosts in a distributed system according to an embodiment of the present application
  • Fig. 4 is a schematic structural diagram of a computer device according to an embodiment of the present application.
  • the method for elastically scaling the number of hosts in a distributed system includes:
  • S1 Monitor the indicator parameter data of the Docker container corresponding to the host in real time, where the indicator parameter data is parameter data corresponding to an indicator input by the user, and the indicator is set by the user according to the Docker container corresponding to the host,
  • the indicators include one or more of system response time, the number of pod functions in the Docker container, the resource consumption of programs running in the Docker container, the CPU usage rate, and the memory usage rate;
  • the number of hosts is subjected to an elastic scaling process corresponding to the current business volume through a preset host scaling strategy, and the elastic scaling process includes capacity expansion processing or shrinking processing.
  • the designated subject of the method in this embodiment is an elastic scaling device for the number of hosts in a distributed system, which can be applied in a distributed system.
  • the aforementioned distributed system is a software system built on the network
  • the aforementioned host is a Node host installed in the distributed system
  • the aforementioned Docker container runs on the Node host
  • one Node host may include multiple Docker containers, where Docker container is an open source application container engine that allows developers to package their applications and dependent packages into a portable container, and then publish to any popular Linux machine, which can also be virtualized.
  • the above indicator parameter data is the parameter data corresponding to the indicator input by the user.
  • the above indicator is set by the user according to the Docker container corresponding to the host.
  • the above indicator corresponding to the Docker container of the host includes the system response time and the pod function in the Docker container. One or more of the number, the resource consumption of the program running in the Docker container, CPU usage, memory usage, etc.
  • the above host scaling strategy is set with a corresponding standard index threshold for each index, and each standard index threshold is correspondingly set with a first preset standard threshold corresponding to the expansion process and a second preset standard corresponding to the scaling process
  • the threshold that is, the first preset standard threshold and the second preset standard threshold are respectively used to determine whether to perform expansion processing or shrinking processing on the number of hosts.
  • the above host scaling strategy is an evaluation condition set based on the above indicators.
  • the number of hosts can be expanded or contracted according to the host scaling strategy.
  • the host scaling strategy It can include the first host scaling strategy and the second host scaling strategy. If the currently detected indicator is the CPU usage rate, the standard indicator value corresponding to the indicator is the CPU usage rate: the first preset standard threshold is 70%, and the second preset If the standard threshold is 30%, the first host scaling strategy is: when the CPU usage is greater than 70%, the number of hosts will be expanded. The number of expansions can be determined according to the current actual business volume; the second host will scale The strategy is: when the CPU usage rate is less than 30%, the number of hosts is scaled down, and the number of downscaling can also be determined according to the current actual business volume.
  • the indicator parameter data of the Docker container corresponding to each host is monitored in real time, and then the indicator parameter data is compared with the standard indicator value to obtain a comparison result, and the above host scaling strategy is used according to the comparison result to compare the current
  • the number of hosts performs elastic scaling processing corresponding to the current business volume, that is, expansion processing or shrinking processing, which realizes the effective and accurate elastic scaling of the number of hosts according to the real-time index parameter data of each host, ensuring the efficient and stable operation of the system , Effectively improve the resource utilization rate of the system.
  • the standard index threshold includes a first preset index threshold corresponding to the expansion process
  • the above step S3 includes:
  • S300 Determine whether the comparison result is that the index parameter data is greater than the first preset index threshold
  • S302 Expand the current number of first original hosts to the number of first hosts matching the first service volume data.
  • the above indicators may include system response time, the number of pod functions in the Docker container, the resource consumption of programs running in the Docker container, CPU usage, memory usage, etc.
  • the standard index threshold includes the first preset index threshold corresponding to the expansion process. After comparing the index parameter data with the preset standard index threshold to obtain the comparison result, it is further judged whether the comparison result is an index parameter The data is greater than the first preset index threshold. When the comparison result is that the index parameter data is greater than the first preset index threshold, that is, when the index parameter data obtained by real-time detection is greater than the first preset standard threshold, the expansion process will be performed .
  • the aforementioned first preset standard threshold corresponds to a plurality of preset thresholds corresponding to each different index.
  • the above-mentioned host expansion processing may specifically include the following: when the above-mentioned indicator is the system response time, the first preset index threshold may include a first preset threshold, and when the system response time is greater than the first preset threshold, Then the number of hosts is expanded.
  • the above system response time can be obtained indirectly according to the number of calls of the process of the Docker container opened on the host. The greater the number of calls of the process of the opened Docker container, the system response time The larger, or the above system response time can be obtained indirectly according to whether there is a backlog of message intermediates in the system.
  • the message intermediate is a queue.
  • Common message middlewares include kafka, RocketMq, etc. If there is a backlog in the message intermediate, It means that many tasks are inserted in the queue during this period, the processing speed of the system cannot keep up, and the system response time is large; when the above indicator is the number of pod functions in the Docker container, the first preset indicator threshold can include the second preset Set a threshold. When the number of pod functions in the Docker container is greater than the second preset threshold, the number of hosts is expanded. The above pod function is the process of the Docker container.
  • the Docker container service will first Increase the number of function pods, so when the number of pods increases, it can indicate that the current business volume has increased, and the processed business volume is more; when the above indicator is the resource consumption of the program running in the Docker container, the first preset indicator threshold can include The third preset threshold, when the resource consumption of the program running in the Docker container is greater than the third preset threshold, the number of hosts is expanded; when the above indicator is the CPU usage rate, the first preset indicator threshold may include the first Four preset thresholds. When the CPU usage rate is greater than the fourth preset threshold, the number of hosts is expanded; when the above indicator is the memory usage rate, the first preset indicator threshold may include the fifth preset threshold.
  • the number of hosts is expanded.
  • the above steps of performing expansion processing on the host need to perform expansion processing on the number of hosts according to the current first service volume data of the system. Specifically, when the comparison result is that the index parameter data is greater than the first preset index threshold When, first obtain the current first service volume data, then expand the current first original host number to the first host number matching the first service volume data, and compare the first host number with the The difference in the number of the first original host is recorded as the number of newly added hosts. Finally, it is necessary to create a specified number of Docker containers corresponding to the number of newly added hosts to complete the final expansion process, where the number of the first original host is Refers to the number of hosts before expansion.
  • the above specified number can be set according to the actual situation. For example, the ratio of a new host during expansion to the number of Docker containers in the new host that needs to be created can be set in advance. Then, the specified number can be determined based on the number of newly added hosts.
  • Scaling ensures the efficient and stable operation of the system and effectively improves the resource utilization rate of the system.
  • the host quantity value corresponding to the service volume can be preset, so that multiple hosts corresponding to the host quantity value can effectively process the service volume and ensure the processing efficiency of the system.
  • each business volume and each host quantity value are stored in the database in a one-to-one correspondence.
  • the designated host quantity value corresponding to the business volume data can be queried from the database, and the current host quantity can be expanded or contracted according to the designated host quantity value. .
  • the standard index threshold includes a second preset index threshold corresponding to the shrinking process, and after the above step S300, the method includes:
  • S303 Determine whether the comparison result is that the index parameter data is less than the second preset index threshold, where the second preset threshold is less than the first preset threshold;
  • S305 Reduce the current number of second original hosts to the number of second hosts matching the second service volume data.
  • the standard index threshold also includes a second preset index threshold corresponding to the above-mentioned shrinking process, and the second preset index threshold is less than the first preset index threshold, and it is determined that After the comparison result is not that the index parameter data is greater than the first preset index threshold, it is further necessary to determine whether the comparison result is that the index parameter data is less than the second preset index threshold.
  • the comparison result is that the index parameter data is greater than The first preset index threshold, that is, when the index parameter data obtained by real-time detection is less than the second preset index threshold, the scaling process will be performed.
  • the second preset index threshold corresponds to a plurality of preset thresholds corresponding to each index.
  • the second preset index threshold may include the sixth preset threshold.
  • the sixth preset threshold When the system response time is less than the sixth preset threshold, the number of hosts will be scaled down; when the above indicator is the number of pod functions in the Docker container, the second preset indicator threshold may include the seventh preset threshold. When the number of pod functions in the container is less than the seventh preset threshold, the number of hosts is scaled down; when the above indicator is the resource consumption of the program running in the Docker container, the first preset indicator threshold may include the eighth preset threshold. Set a threshold.
  • the first preset indicator threshold may include the ninth preset threshold. Set a threshold.
  • the CPU usage rate is less than the ninth preset threshold, the number of hosts will be scaled down; when the above indicator is the memory usage rate, the first preset indicator threshold may include the tenth preset threshold.
  • the memory usage rate is When it is less than the tenth preset threshold, the number of hosts is reduced.
  • the above-mentioned steps of shrinking processing need to shrink the number of hosts according to the current second business volume data of the system.
  • the current second business volume data first obtain the current second business volume data, and then change the current second original host
  • the number is scaled down to the number of second hosts matching the second service volume data to complete the scaling process of the host, where the second original host number refers to the number of hosts before the scaling process.
  • the detected index parameter data is less than the aforementioned second preset index threshold
  • the current number of second original hosts is reduced to the number of first hosts matching the second service volume data. It is beneficial to realize the effective elastic scaling of the number of hosts according to the current second business volume data, ensure the efficient and stable operation of the system, effectively improve the resource utilization rate of the system, and reduce the waste of system resources.
  • step S305 includes:
  • S3050 Obtain the aging value of each of the hosts and the number of the second hosts that match the second business volume data, and record the difference between the number of the second original host and the number of the second host To reduce the number of hosts;
  • S3051 Sort the aging value of each host in descending order of numerical value to obtain the aging value ranking
  • S3052 According to the aging value ranking, sequentially select multiple designated aging values corresponding to the reduced number of hosts from the aging value ranking;
  • the above step of reducing the current number of second original hosts to the number of second hosts matching the second business volume data is to filter out old hosts from all current hosts.
  • the number of designated hosts with the highest value and corresponding to the aforementioned reduction of the number of hosts is realized by recycling, where the number of the second original host refers to the number of hosts before the shrinking process, and the host with the highest aging value represents slow processing speed , Inefficient host.
  • the aging value of the host can be obtained by calculating the sum of the aging value of the host and the container aging value of each Docker container in each host.
  • the aging value of each host can be sorted in descending order of numerical value to obtain the corresponding aging value ranking, and sorting from the aging value according to the aging value ranking
  • Multiple designated aging values corresponding to the above-mentioned reduced number of hosts are filtered out, and finally multiple designated hosts corresponding to the multiple designated aging values can be obtained, and the shrinking process of the hosts is completed by recycling the above-mentioned multiple designated hosts .
  • the shrinking process when the shrinking process is required, after calculating the current aging value of each host and obtaining the aging value ranking corresponding to each aging value, the multiple aging values can be filtered directly from the aging value ranking The larger designated host is recycled.
  • the method before the above step S3050, the method includes:
  • S30502 Calculate the sum of the host aging value of each host and the container aging value of each Docker container in each host to obtain the aging value of each host.
  • the step of obtaining the aging value of each of the above hosts before the step of obtaining the aging value of each of the above hosts, it also includes a process of calculating the aging value of each of the above hosts, and the aging value of each host can be calculated by calculating the host aging value of the host and The sum of the container aging value of each Docker container in each host is calculated. Specifically, first obtain the first life cycle of each host, and input the first life cycle into a preset first formula to obtain the host aging value corresponding to each host, where the first life cycle is Refers to the creation time of the host.
  • the second life cycle mentioned above refers to the time when the Docker container has been created.
  • the method includes:
  • S305001 Calculate each first difference between the current time and the first creation time of each of the hosts to obtain each of the first life cycles corresponding to each of the hosts;
  • S305002 Calculate each second difference between the current time and the second creation time of each Docker container in each host, respectively, to obtain each second life cycle corresponding to each Docker container.
  • the aging value of the host can be obtained by calculating the sum of the aging value of the host and the container aging value of each Docker container in each host, the aging value corresponding to each host is calculated Before, you need to calculate the host aging value of each host and the container aging value of the Docker container in each host. Before calculating the aging value of each host and the aging value of each container, it is necessary to calculate the first life cycle of each host and the second life cycle of the Docker container in each host.
  • the first creation time of each host and the second creation time of the Docker container in each host must be obtained first, and then according to the current time, the first creation time of the current time and the first creation time of each host
  • the difference value can be used to obtain the first life cycle of each host, and the second difference between the current time and the second creation time of each Docker container can be calculated to obtain each Docker container in each host. The corresponding second life cycle.
  • the method before the above step S3053, the method includes:
  • S30531 Store the specified data in a preset database.
  • multiple designated aging values corresponding to the reduced number of hosts are selected from the foregoing aging value sorting, and the multiple specified aging values corresponding to the number of
  • the above-mentioned designated data can be the data retained when the designated host is working, and the designated data may contain some important data , And if the designated host is directly recycled at this time, the system will directly delete the designated data, resulting in the loss of important data.
  • the designated data in the designated host may be backed up.
  • the designated data may be important data.
  • the specific content of important data is not specifically limited.
  • the important data can be screened automatically by the system or according to the wishes of the business personnel.
  • a database can be set up in advance, and then the specified data can be extracted and transferred to the database for storage .
  • This embodiment backs up the designated data in the designated host before recycling the designated host, which helps to avoid the situation that the designated data will be deleted and cannot be recovered after the designated host is recovered, and reduces the amount of data in the designated host. Loss caused by loss of important data.
  • the method for elastic scaling of the number of hosts in the distributed system of the embodiment of the present application monitors the indicator parameters of the Docker container corresponding to each host in real time after pre-setting the indicator of the Docker container corresponding to the host and the standard indicator threshold corresponding to the indicator Data, and then compare the index parameter data with the standard index threshold to obtain a comparison result, and according to the comparison result, the above host scaling strategy is used to expand or shrink the current number of hosts corresponding to the current business volume to achieve According to the real-time index parameter data of each host, the number of hosts can be effectively and accurately elastically scaled to ensure the efficient and stable operation of the system and effectively improve the resource utilization rate of the system.
  • an embodiment of the present application also provides an elastic scaling device for the number of hosts in a distributed system, including:
  • the monitoring module 1 is used to monitor the indicator parameter data of the Docker container corresponding to the host in real time, wherein the indicator parameter data is the parameter data corresponding to the indicator input by the user, and the indicator is determined by the user according to the Docker corresponding to the host.
  • the container is set, and the indicators include one or more of system response time, the number of pod functions in the Docker container, the resource consumption of programs running in the Docker container, the CPU usage rate, and the memory usage rate;
  • the comparison module 2 is used to compare the index parameter data with a preset standard index threshold to obtain a comparison result
  • the processing module 3 is configured to perform an elastic scaling process corresponding to the current business volume on the number of hosts through a preset host scaling strategy according to the comparison result, and the elastic scaling process includes capacity expansion processing or capacity reduction processing.
  • the implementation process of the functions and roles of the monitoring module, the comparison module, and the processing module are detailed in the implementation process of the corresponding steps S1-S3 in the method for elastic scaling of the number of hosts in the distributed system, which will not be repeated here.
  • the standard index threshold includes a first preset index threshold corresponding to the expansion process
  • the above processing module includes:
  • the first judgment unit is configured to judge whether the comparison result is that the index parameter data is greater than the first preset index threshold
  • the first obtaining unit is configured to obtain current first business volume data if yes;
  • the expansion unit is configured to expand the current number of first original hosts to the number of first hosts matching the first service volume data.
  • the implementation process of the functions and roles of the first judging unit, the first acquiring unit, and the capacity expansion unit are detailed in the implementation process corresponding to steps S300-S302 in the method for elastic scaling of the number of hosts in the distributed system, here No longer.
  • the standard index threshold includes a second preset index threshold corresponding to the shrinking process
  • the above processing module includes:
  • a second judgment unit configured to judge whether the comparison result is that the index parameter data is less than the second preset index threshold, wherein the second preset threshold is less than the first preset threshold;
  • the second acquiring unit is configured to, if yes, acquire the current second business volume data
  • the shrinking unit is configured to shrink the current number of second original hosts to the number of second hosts matching the second service volume data.
  • the implementation process of the functions and effects of the second judgment unit, the second acquisition unit, and the scaling unit are detailed in the implementation process corresponding to steps S303-S305 in the method for elastic scaling of the number of hosts in the distributed system. This will not be repeated here.
  • the aforementioned shrinking unit includes:
  • the first obtaining subunit is used to obtain the aging value of each of the hosts, and the number of the second hosts matching the second service volume data, and compare the number of the second original host with the second The difference in the number of hosts is recorded as reducing the number of hosts;
  • the sorting subunit is used to sort the aging value of each of the hosts in numerical order from large to small to obtain the aging value ranking;
  • the screening subunit is used for sorting according to the aging value, and sequentially selecting a plurality of designated aging values corresponding to the reduced number of hosts from the aging value sorting;
  • the recovery subunit is used to recover each designated host corresponding to each designated aging value.
  • the implementation process of the functions and roles of the first acquisition sub-unit, the screening sub-unit, and the recycling sub-unit is detailed in the implementation process corresponding to steps S3050-S3053 in the method for elastic scaling of the number of hosts in the distributed system. This will not be repeated here.
  • the aforementioned shrinking unit includes:
  • the second acquiring subunit is used to acquire the first life cycle of each of the hosts, and input the first life cycle into a preset first formula to obtain the host aging value corresponding to each of the hosts, where
  • the first calculation subunit is used to calculate the sum of the host aging value of each host and the container aging value of each Docker container in each host to obtain the aging value of each host.
  • the implementation process of the functions and roles of the second acquisition subunit, the third acquisition subunit, and the first calculation subunit is detailed in the corresponding steps S30500-S30502 in the method for elastic scaling of the number of hosts in the distributed system. The realization process will not be repeated here.
  • the aforementioned shrinking unit includes:
  • the fourth obtaining subunit is configured to obtain the first creation time corresponding to each host and the second creation time corresponding to each Docker container in each host;
  • the second calculation subunit is configured to calculate each first difference between the current time and the first creation time of each of the hosts to obtain each of the first life cycles corresponding to each of the hosts;
  • the third calculation subunit is used to calculate the second difference between the current time and the second creation time of each Docker container in each host to obtain each second life cycle corresponding to each Docker container .
  • the implementation process of the functions and roles of the fourth acquisition subunit, the second calculation subunit, and the third calculation subunit are detailed in the corresponding steps S305000-S305002 in the method for elastic scaling of the number of hosts in the distributed system. The realization process will not be repeated here.
  • the aforementioned shrinking unit includes:
  • Extracting subunit for extracting designated data in each designated host
  • the storage subunit is used to store the specified data in a preset database.
  • the implementation process of the functions and roles of the extraction subunit and the storage subunit is detailed in the implementation process of the corresponding steps S30530-S30531 in the method for elastic scaling of the number of hosts in the distributed system, which will not be repeated here.
  • the device for elastically scaling the number of hosts in the distributed system of the embodiment of the present application monitors the indicator parameters of the Docker container corresponding to each host in real time after pre-setting the indicator of the Docker container corresponding to the host and the standard indicator threshold corresponding to the indicator Data, and then compare the index parameter data with the standard index threshold to obtain a comparison result, and according to the comparison result, the above host scaling strategy is used to expand or shrink the current number of hosts corresponding to the current business volume to achieve According to the real-time index parameter data of each host, the number of hosts can be effectively and accurately elastically scaled to ensure the efficient and stable operation of the system and effectively improve the resource utilization rate of the system.
  • an embodiment of the present application also provides a computer device.
  • the computer device may be a server, and its internal structure may be as shown in FIG. 4.
  • the computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor designed for the computer equipment is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, computer readable instructions, and a database.
  • the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the non-volatile storage medium.
  • the database of the computer equipment is used to store data such as standard index thresholds and index parameter data.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer-readable instruction executes the process of the above-mentioned method embodiment.
  • FIG. 4 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the devices and computer equipment to which the solution of the present application is applied.
  • An embodiment of the present application further provides a computer non-volatile readable storage medium, on which computer readable instructions are stored, and when the computer readable instructions are executed by a processor, the processes as in the foregoing method embodiments are implemented.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Quality & Reliability (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

An elastic scaling method and apparatus for the number of hosts in a distributed system, and a computer device. Said method comprises: monitoring, in real time, index parameter data of a Docket container corresponding to hosts (S1); comparing the index parameter data with a preset standard index threshold to obtain a comparison result (S2); and according to the comparison result, performing elastic scaling processing corresponding to the current traffic on the number of hosts by means of a preset host scaling strategy (S3). The present invention can effectively and accurately achieve the elastic scaling for the number of hosts.

Description

分布式系统中主机数量弹性伸缩方法、装置和计算机设备Method, device and computer equipment for elastic scaling of host number in distributed system
本申请要求于2019年04月16日提交中国专利局、申请号为201910305187.9,发明名称为“分布式系统中主机数量弹性伸缩方法、装置和计算机设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on April 16, 2019, the application number is 201910305187.9, and the invention title is "Methods, devices, and computer equipment for the elastic scaling of the number of hosts in a distributed system", and its entire contents Incorporated in this application by reference.
技术领域Technical field
本申请涉及云计算技术领域,具体涉及一种分布式系统中主机数量弹性伸缩方法、装置和计算机设备。This application relates to the field of cloud computing technology, and in particular to a method, device and computer equipment for elastic scaling of the number of hosts in a distributed system.
背景技术Background technique
现有的许多以Docker容器部署的分布式系统不具备主机弹性伸缩的能力,往往需要提前准备好足够多的冗余的主机来满足处于业务调用的高峰期的分布式系统的需求,而当分布式系统处于业务调用的低谷期时,则会出现大量闲置资源的浪费。另外,也存在一些具备主机弹性伸缩的能力的分布式系统,但这些分布式系统的主机弹性伸缩是基于周期性的弹性伸缩,即指通过固定的一个周期来实现主机的弹性伸缩,例如,分布式系统在9点至18点的工作时间段内的业务调用使用量很大,则可以定制在每天9点前主机扩容一定数目的主机,以及在每天18点后主机缩容一定数目的主机,这种基于周期性的弹性伸缩不能根据业务调用的实际数据量来进行及时的弹性伸缩,对主机的弹性伸缩不精确、灵活度低,且分布式系统的资源使用率不高。Many existing distributed systems deployed with Docker containers do not have the ability to elastically scale hosts. It is often necessary to prepare enough redundant hosts in advance to meet the needs of distributed systems at the peak of business calls. When the integrated system is in the low period of business call, a lot of idle resources will be wasted. In addition, there are also some distributed systems with the ability of host elastic scaling, but the host elastic scaling of these distributed systems is based on periodic elastic scaling, that is, the elastic scaling of the host is realized through a fixed cycle, for example, distributed The business call usage of the system is very large during the working hours from 9:00 to 18:00. You can customize the host to expand a certain number of hosts before 9:00 every day, and to shrink a certain number of hosts after 18:00 every day. This kind of periodic elastic scaling cannot perform timely elastic scaling according to the actual data volume of the business call, the elastic scaling of the host is not accurate, the flexibility is low, and the resource utilization rate of the distributed system is not high.
技术问题technical problem
本申请的主要目的为提供一种分布式系统中主机数量弹性伸缩方法、装置、计算机设备和存储介质,旨在解决现有的分布式系统不具备主机弹性伸缩的能力,以及具有基于周期性的弹性伸缩能力的分布式系统会存在对主机的弹性伸缩不精确,灵活度低的技术问题。The main purpose of this application is to provide a method, device, computer equipment and storage medium for elastic scaling of the number of hosts in a distributed system, which aims to solve the problem that the existing distributed system does not have the ability of host elastic scaling and has periodicity-based Distributed systems with elastic scaling capabilities will have technical problems such as inaccurate elastic scaling of the host and low flexibility.
技术解决方案Technical solutions
为了实现上述申请目的,本申请提出一种分布式系统中主机数量弹性伸缩方法,所述方法包括步骤:In order to achieve the purpose of the above application, this application proposes a method for elastic scaling of the number of hosts in a distributed system. The method includes the steps:
实时监控主机对应的Docker容器的指标参数数据,其中所述指标参数数据为与用户输入的指标相对应的参数数据,所述指标由所述用户根据所述主机对应的Docker容器进行设置,所述指标包括系统响应时间、Docker容器内的pod函数的数量、Docker容器内运行的程序的资源消耗量、CPU使用率以及内存使用率中的一种或多种;Monitor the indicator parameter data of the Docker container corresponding to the host in real time, where the indicator parameter data is parameter data corresponding to the indicator input by the user, and the indicator is set by the user according to the Docker container corresponding to the host. Indicators include one or more of system response time, the number of pod functions in the Docker container, the resource consumption of the programs running in the Docker container, CPU usage, and memory usage;
将所述指标参数数据与预设的标准指标阈值进行比较,得到比较结果,其中所述标准指标阈值至少包括与扩容处理对应的第一预设指标阈值;Comparing the index parameter data with a preset standard index threshold to obtain a comparison result, where the standard index threshold includes at least a first preset index threshold corresponding to the expansion process;
判断所述比较结果是否为所述指标参数数据大于所述第一预设指标阈值;Judging whether the comparison result is that the index parameter data is greater than the first preset index threshold;
若是,获取当前的第一业务量数据;If yes, obtain the current first business volume data;
将当前的第一原主机数量扩容至与所述第一业务量数据相匹配的第一主机数量。Expanding the current number of first original hosts to the number of first hosts matching the first service volume data.
本申请还提供一种分布式系统中主机数量弹性伸缩装置,包括:This application also provides an elastic scaling device for the number of hosts in a distributed system, including:
监控模块,用于实时监控主机对应的Docker容器的指标参数数据,其中所述指标参数数据为与用户输入的指标相对应的参数数据,所述指标由所述用户根据所述主机对应的Docker容器进行设置,所述指标包括系统响应时间、Docker容器内的pod函数的数量、Docker容器内运行的程序的资源消耗量、CPU使用率以及内存使用率中的一种或多种;The monitoring module is used to monitor the indicator parameter data of the Docker container corresponding to the host in real time, wherein the indicator parameter data is parameter data corresponding to the indicator input by the user, and the indicator is determined by the user according to the Docker container corresponding to the host Setting, the indicators include one or more of system response time, the number of pod functions in the Docker container, the resource consumption of programs running in the Docker container, the CPU usage rate, and the memory usage rate;
比较模块,用于将所述指标参数数据与预设的标准指标阈值进行比较,得到比较结果,其中所述标准指标阈值至少包括与扩容处理对应的第一预设指标阈值;A comparison module, configured to compare the index parameter data with a preset standard index threshold to obtain a comparison result, where the standard index threshold includes at least a first preset index threshold corresponding to the expansion process;
第一判断模块,用于判断所述比较结果是否为所述指标参数数据大于所述第一预设指标阈值;The first judgment module is configured to judge whether the comparison result is that the index parameter data is greater than the first preset index threshold;
第一获取模块,用于若是,获取当前的第一业务量数据;The first obtaining module is used to obtain the current first business volume data if yes;
扩容模块,用于将当前的第一原主机数量扩容至与所述第一业务量数据相匹配的第一主机数量。The expansion module is used to expand the current number of first original hosts to the number of first hosts matching the first service volume data.
本申请还提供一种计算机设备,包括存储器和处理器,所述存储器中存储有计算机可读指令,所述处理器执行所述计算机可读指令时实现上述方法的步骤。The application also provides a computer device, including a memory and a processor, the memory stores computer readable instructions, and the processor implements the steps of the above method when the computer readable instructions are executed.
本申请还提供一种计算机非易失性可读存储介质,其上存储有计算机可读指令,所述计算机可读指令被处理器执行时实现上述方法的步骤。The present application also provides a computer non-volatile readable storage medium on which computer readable instructions are stored, and when the computer readable instructions are executed by a processor, the steps of the above method are realized.
有益效果Beneficial effect
本申请中提供的分布式系统中主机数量弹性伸缩方法、装置、计算机设备和存储介质,实时监控主机对应的Docker容器的指标参数数据;将指标参数数据与预设的标准指标阈值进行比较,得到比较结果;根据比较结果,通过预设的主机伸缩策略对主机的数量进行与当前业务量对应的弹性伸缩处理,弹性伸缩处理包括扩容处理或缩容处理。本申请通过在预先设置好对应于主机的Docker容器的指标以及与该指标对应的标准指标阈值后,实时监控各主机对应的Docker容器的指标参数数据,再将该指标参数数据与该标准指标阈值进行比较得到比较结果,并根据该比较结果采用上述主机伸缩策略来对当前的主机数量进行与当前业务量对应的扩容处理或缩容处理,实现了根据各主机实时的指标参数数据来对主机的数量进行有效、精确的弹性伸缩,保证系统的高效稳定运行,有效地提高系统的资源使用率。The method, device, computer equipment and storage medium for elastic scaling of the number of hosts in the distributed system provided in this application monitor the indicator parameter data of the Docker container corresponding to the host in real time; compare the indicator parameter data with the preset standard indicator threshold to obtain Comparison result: According to the comparison result, the number of hosts is subjected to elastic scaling processing corresponding to the current business volume through a preset host scaling strategy, and the elastic scaling processing includes expansion processing or shrinking processing. This application monitors the indicator parameter data of the Docker container corresponding to each host in real time after pre-setting the indicator of the Docker container corresponding to the host and the standard indicator threshold corresponding to the indicator, and then the indicator parameter data and the standard indicator threshold The comparison results are obtained, and the above host scaling strategy is used according to the comparison results to expand or shrink the current number of hosts corresponding to the current business volume, so as to realize the control of the host based on the real-time index parameter data of each host. Effective and accurate elastic scaling of the quantity ensures the efficient and stable operation of the system and effectively improves the resource utilization rate of the system.
附图说明Description of the drawings
图1是本申请一实施例的分布式系统中主机数量弹性伸缩方法的流程示意图;FIG. 1 is a schematic flowchart of a method for elastic scaling of the number of hosts in a distributed system according to an embodiment of the present application;
图2是本申请另一实施例的分布式系统中主机数量弹性伸缩方法的流程示意图;2 is a schematic flowchart of a method for elastic scaling of the number of hosts in a distributed system according to another embodiment of the present application;
图3是本申请一实施例的分布式系统中主机数量弹性伸缩装置的结构示意图;FIG. 3 is a schematic structural diagram of an elastic scaling device for the number of hosts in a distributed system according to an embodiment of the present application;
图4是本申请一实施例的计算机设备的结构示意图。Fig. 4 is a schematic structural diagram of a computer device according to an embodiment of the present application.
本发明的最佳实施方式The best mode of the invention
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。It should be understood that the specific embodiments described here are only used to explain the application, and are not used to limit the application.
参照图1,本申请一实施例的分布式系统中主机数量弹性伸缩方法,包括:1, the method for elastically scaling the number of hosts in a distributed system according to an embodiment of the present application includes:
S1:实时监控主机对应的Docker容器的指标参数数据,其中所述指标参数数据为与用户输入的指标相对应的参数数据,所述指标由所述用户根据所述主机对应的Docker容器进行设置,所述指标包括系统响应时间、Docker容器内的pod函数的数量、Docker容器内运行的程序的资源消耗量、CPU使用率以及内存使用率中的一种或多种;S1: Monitor the indicator parameter data of the Docker container corresponding to the host in real time, where the indicator parameter data is parameter data corresponding to an indicator input by the user, and the indicator is set by the user according to the Docker container corresponding to the host, The indicators include one or more of system response time, the number of pod functions in the Docker container, the resource consumption of programs running in the Docker container, the CPU usage rate, and the memory usage rate;
S2:将所述指标参数数据与预设的标准指标阈值进行比较,得到比较结果;S2: Compare the index parameter data with a preset standard index threshold to obtain a comparison result;
S3:根据所述比较结果,通过预设的主机伸缩策略对所述主机的数量进行与当前业务量对应的弹性伸缩处理,所述弹性伸缩处理包括扩容处理或缩容处理。S3: According to the comparison result, the number of hosts is subjected to an elastic scaling process corresponding to the current business volume through a preset host scaling strategy, and the elastic scaling process includes capacity expansion processing or shrinking processing.
如上述步骤S1所述,本实施例的方法的指定主体为分布式系统中主机数量弹性伸缩装置,可应用于分布式系统内。上述分布式系统为建立在网络之上的软件系统,上述主机为设置于分布式系统的Node主机,上述Docker容器运行于该Node主机之上,且一个Node主机内可包括多个Docker容器,其中Docker容器是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的Linux机器上,也可以实现虚拟化。上述指标参数数据为与用户输入的指标相对应的参数数据,上述指标由用户根据主机对应的Docker容器进行设置,上述与主机的Docker容器对应的指标包括系统响应时间、Docker容器内的pod函数的数量、Docker容器内运行的程序的资源消耗量、CPU使用率、内存使用率等中的一种或多种。上述主机伸缩策略对于每个指标都设置有相对应的标准指标阈值,且每个标准指标阈值对应设置有与扩容处理对应的第一预设标准阈值和与缩容处理对应的第二预设标准阈值,即第一预设标准阈值和第二预设标准阈值分别是用于判断是否对主机的数量进行扩容处理或缩容处理的依据。上述主机伸缩策略为根据上述指标而设定的评定条件,在得到了上述指标参数数据后,可根据主机伸缩策略来对主机的数量进行对应的扩容处理或缩容处理,举例地,主机伸缩策略可包括第一主机伸缩策略和第二主机伸缩策略,若当前检测的指标为CPU使用率,对应于指标为CPU使用率的标准指标值为:第一预设标准阈值为70%,第二预设标准阈值为30%,则第一主机伸缩策略为:当CPU使用率大于70%时,则对主机的数量进行扩容处理,扩容的数量可根据当前的实际业务量进行确定;第二主机伸缩策略为:当CPU使用率小于30%时,则对主机的数量进行缩容处理,缩容的数量也可根据当前的实际业务量进行确定。在本实施例,通过实时监控各主机对应的Docker容器的指标参数数据,再将该指标参数数据与该标准指标值进行比较得到比较结果,并根据该比较结果采用上述主机伸缩策略来对当前的主机数量进行与当前业务量对应的弹性伸缩处理,即扩容处理或缩容处理,实现了根据各主机实时的指标参数数据来对主机的数量进行有效、精确的弹性伸缩,保证系统的高效稳定运行,有效地提高系统的资源使用率。As described in step S1 above, the designated subject of the method in this embodiment is an elastic scaling device for the number of hosts in a distributed system, which can be applied in a distributed system. The aforementioned distributed system is a software system built on the network, the aforementioned host is a Node host installed in the distributed system, the aforementioned Docker container runs on the Node host, and one Node host may include multiple Docker containers, where Docker container is an open source application container engine that allows developers to package their applications and dependent packages into a portable container, and then publish to any popular Linux machine, which can also be virtualized. The above indicator parameter data is the parameter data corresponding to the indicator input by the user. The above indicator is set by the user according to the Docker container corresponding to the host. The above indicator corresponding to the Docker container of the host includes the system response time and the pod function in the Docker container. One or more of the number, the resource consumption of the program running in the Docker container, CPU usage, memory usage, etc. The above host scaling strategy is set with a corresponding standard index threshold for each index, and each standard index threshold is correspondingly set with a first preset standard threshold corresponding to the expansion process and a second preset standard corresponding to the scaling process The threshold, that is, the first preset standard threshold and the second preset standard threshold are respectively used to determine whether to perform expansion processing or shrinking processing on the number of hosts. The above host scaling strategy is an evaluation condition set based on the above indicators. After obtaining the above indicator parameter data, the number of hosts can be expanded or contracted according to the host scaling strategy. For example, the host scaling strategy It can include the first host scaling strategy and the second host scaling strategy. If the currently detected indicator is the CPU usage rate, the standard indicator value corresponding to the indicator is the CPU usage rate: the first preset standard threshold is 70%, and the second preset If the standard threshold is 30%, the first host scaling strategy is: when the CPU usage is greater than 70%, the number of hosts will be expanded. The number of expansions can be determined according to the current actual business volume; the second host will scale The strategy is: when the CPU usage rate is less than 30%, the number of hosts is scaled down, and the number of downscaling can also be determined according to the current actual business volume. In this embodiment, the indicator parameter data of the Docker container corresponding to each host is monitored in real time, and then the indicator parameter data is compared with the standard indicator value to obtain a comparison result, and the above host scaling strategy is used according to the comparison result to compare the current The number of hosts performs elastic scaling processing corresponding to the current business volume, that is, expansion processing or shrinking processing, which realizes the effective and accurate elastic scaling of the number of hosts according to the real-time index parameter data of each host, ensuring the efficient and stable operation of the system , Effectively improve the resource utilization rate of the system.
参照图2,进一步地,本申请一实施例中,所述标准指标阈值包括与所述扩容处理对应的第一预设指标阈值,上述步骤S3,包括:2, further, in an embodiment of the present application, the standard index threshold includes a first preset index threshold corresponding to the expansion process, and the above step S3 includes:
S300:判断所述比较结果是否为所述指标参数数据大于所述第一预设指标阈值;S300: Determine whether the comparison result is that the index parameter data is greater than the first preset index threshold;
S301:若是,获取当前的第一业务量数据;S301: If yes, obtain the current first business volume data;
S302:将当前的第一原主机数量扩容至与所述第一业务量数据相匹配的第一主机数量。S302: Expand the current number of first original hosts to the number of first hosts matching the first service volume data.
如上述步骤S300至S302所述,上述指标可包括系统响应时间、Docker容器内的pod函数的数量、Docker容器内运行的程序的资源消耗量、CPU使用率、内存使用率等,在本实施例,上述标准指标阈值包括与上述扩容处理对应的第一预设指标阈值,在将所述指标参数数据与预设的标准指标阈值进行比较,得到比较结果后,进一步判断该比较结果是否为指标参数数据大于上述第一预设指标阈值,当该比较结果是指标参数数据大于上述第一预设指标阈值,即实时检测得到的指标参数数据大于上述第一预设标准阈值时,则会进行扩容处理。其中,上述第一预设标准阈值对应于每个不同的指标分别有对应的多个预设阈值。上述对主机进行扩容处理的情况具体可包括以下几种:当上述指标为系统响应时间,第一预设指标阈值可包括第一预设阈值,当系统响应时间大于该第一预设阈值时,则对主机的数量进行扩容处理,其中上述系统响应时间可根据主机上开启的Docker容器的进程的被调用次数来间接求取得到,开启的Docker容器的进程的被调用次数越大,系统响应时间越大,或者上述系统响应时间可根据系统内的消息中间体是否有积压来间接求得,消息中间体是一个队列,常见的消息中间件有kafka、RocketMq等,如果消息中间体中有积压,则说明这段时间队列中插入了很多任务,系统的处理的速度跟不上,系统响应时间大;当上述指标为Docker容器内的pod函数的数量,第一预设指标阈值可包括第二预设阈值,当Docker容器内的pod函数的数量大于第二预设阈值时,对主机的数量进行扩容处理,其中上述pod函数为Docker容器的进程,当业务量大的时候,Docker容器服务首先会增加函数pod的数量,因此当pod数量增加时可说明当前业务量增大,处理的业务量较多;当上述指标为Docker容器内运行的程序的资源消耗量,第一预设指标阈值可包括第三预设阈值,当Docker容器内运行的程序的资源消耗量大于第三预设阈值时,对主机的数量进行扩容处理;当上述指标为CPU使用率,第一预设指标阈值可包括第四预设阈值,当CPU使用率大于第四预设阈值时,对主机的数量进行扩容处理;当上述指标为内存使用率,第一预设指标阈值可包括第五预设阈值,当内存使用率大于第五预设阈值时,对主机的数量进行扩容处理。在本实施例中,上述对主机进行扩容处理的步骤需要根据系统当前的第一业务量数据来对主机的数量进行扩容处理,具体地,当比较结果为指标参数数据大于第一预设指标阈值时,首先获取当前的第一业务量数据,然后将当前的第一原主机数量扩容至与所述第一业务量数据相匹配的第一主机数量,并且将所述第一主机数量与所述第一原主机数量的差值记为新增主机数量,最后还需要创建与所述新增主机数量对应的指定数量的Docker容器,以完成最终的扩容处理,其中,上述第一原主机数量是指进行扩容处理前的主机的数量,上述指定数量可根据实际情况进行设定,例如可预先设置好扩容时的一个新增主机与对应需要创建的该新增主机内的Docker容器的数量比例,之后便可以根据上述新增主机数量来确定出上述指定数量。本实施例通过将当前的第一原主机数量扩容至与所述第一业务量数据相匹配的第一主机数量,有利于实现根据当前的第一业务量数据来对主机的数量进行有效的弹性伸缩,保证系统的高效稳定运行,有效地提高系统的资源使用率。进一步地,可预先设置与业务量对应的主机数量值,使得与该主机数量值对应的多个主机能有效地对该业务量进行处理,保证系统的处理效率。然后将各业务量与各主机数量值一一对应的存储在数据库中。当知道当前的业务量数据后,便可从数据库中查询得到与该业务量数据对应的指定主机数量值,并可根据该指定主机数量值来对当前的主机数量进行对应的扩容或缩容处理。As described in the above steps S300 to S302, the above indicators may include system response time, the number of pod functions in the Docker container, the resource consumption of programs running in the Docker container, CPU usage, memory usage, etc. In this embodiment The standard index threshold includes the first preset index threshold corresponding to the expansion process. After comparing the index parameter data with the preset standard index threshold to obtain the comparison result, it is further judged whether the comparison result is an index parameter The data is greater than the first preset index threshold. When the comparison result is that the index parameter data is greater than the first preset index threshold, that is, when the index parameter data obtained by real-time detection is greater than the first preset standard threshold, the expansion process will be performed . Wherein, the aforementioned first preset standard threshold corresponds to a plurality of preset thresholds corresponding to each different index. The above-mentioned host expansion processing may specifically include the following: when the above-mentioned indicator is the system response time, the first preset index threshold may include a first preset threshold, and when the system response time is greater than the first preset threshold, Then the number of hosts is expanded. The above system response time can be obtained indirectly according to the number of calls of the process of the Docker container opened on the host. The greater the number of calls of the process of the opened Docker container, the system response time The larger, or the above system response time can be obtained indirectly according to whether there is a backlog of message intermediates in the system. The message intermediate is a queue. Common message middlewares include kafka, RocketMq, etc. If there is a backlog in the message intermediate, It means that many tasks are inserted in the queue during this period, the processing speed of the system cannot keep up, and the system response time is large; when the above indicator is the number of pod functions in the Docker container, the first preset indicator threshold can include the second preset Set a threshold. When the number of pod functions in the Docker container is greater than the second preset threshold, the number of hosts is expanded. The above pod function is the process of the Docker container. When the business volume is large, the Docker container service will first Increase the number of function pods, so when the number of pods increases, it can indicate that the current business volume has increased, and the processed business volume is more; when the above indicator is the resource consumption of the program running in the Docker container, the first preset indicator threshold can include The third preset threshold, when the resource consumption of the program running in the Docker container is greater than the third preset threshold, the number of hosts is expanded; when the above indicator is the CPU usage rate, the first preset indicator threshold may include the first Four preset thresholds. When the CPU usage rate is greater than the fourth preset threshold, the number of hosts is expanded; when the above indicator is the memory usage rate, the first preset indicator threshold may include the fifth preset threshold. When the rate is greater than the fifth preset threshold, the number of hosts is expanded. In this embodiment, the above steps of performing expansion processing on the host need to perform expansion processing on the number of hosts according to the current first service volume data of the system. Specifically, when the comparison result is that the index parameter data is greater than the first preset index threshold When, first obtain the current first service volume data, then expand the current first original host number to the first host number matching the first service volume data, and compare the first host number with the The difference in the number of the first original host is recorded as the number of newly added hosts. Finally, it is necessary to create a specified number of Docker containers corresponding to the number of newly added hosts to complete the final expansion process, where the number of the first original host is Refers to the number of hosts before expansion. The above specified number can be set according to the actual situation. For example, the ratio of a new host during expansion to the number of Docker containers in the new host that needs to be created can be set in advance. Then, the specified number can be determined based on the number of newly added hosts. In this embodiment, by expanding the current number of first original hosts to the number of first hosts matching the first service volume data, it is beneficial to realize effective flexibility in the number of hosts according to the current first service volume data. Scaling ensures the efficient and stable operation of the system and effectively improves the resource utilization rate of the system. Further, the host quantity value corresponding to the service volume can be preset, so that multiple hosts corresponding to the host quantity value can effectively process the service volume and ensure the processing efficiency of the system. Then, each business volume and each host quantity value are stored in the database in a one-to-one correspondence. When the current business volume data is known, the designated host quantity value corresponding to the business volume data can be queried from the database, and the current host quantity can be expanded or contracted according to the designated host quantity value. .
进一步地,本申请一实施例中,所述标准指标阈值包括与所述缩容处理对应的第二预设指标阈值,上述步骤S300之后,包括:Further, in an embodiment of the present application, the standard index threshold includes a second preset index threshold corresponding to the shrinking process, and after the above step S300, the method includes:
S303:判断所述比较结果是否为所述指标参数数据小于所述第二预设指标阈,其中所述第二预设阈值小于所述第一预设阈值;S303: Determine whether the comparison result is that the index parameter data is less than the second preset index threshold, where the second preset threshold is less than the first preset threshold;
S304:若是,获取当前的第二业务量数据;S304: If yes, obtain the current second business volume data;
S305:将当前的第二原主机数量缩容至与所述第二业务量数据相匹配的第二主机数量。S305: Reduce the current number of second original hosts to the number of second hosts matching the second service volume data.
如上述步骤S303至S305所述,上述标准指标阈值还包括与上述缩容处理对应的第二预设指标阈值,且上述第二预设指标阈值小于上述第一预设指标阈值,在判断得出比较结果不为所述指标参数数据大于所述第一预设指标阈值的步骤之后,进一步还需要判断比较结果是否为指标参数数据小于上述第二预设指标阈值,当比较结果是指标参数数据大于上述第一预设指标阈值,即当实时检测得到的指标参数数据小于上述第二预设指标阈值时,则会进行缩容处理。其中,上述第二预设指标阈值对应于每个指标分别有对应的多个预设阈值,具体地,当上述指标为系统响应时间,第二预设指标阈值可包括第六预设阈值,当系统响应时间小于第六预设阈值时,则对主机的数量进行缩容处理;当上述指标为Docker容器内的pod函数的数量,第二预设指标阈值可包括第七预设阈值,当Docker容器内的pod函数的数量小于第七预设阈值时,对主机的数量进行缩容处理;当上述指标为Docker容器内运行的程序的资源消耗量,第一预设指标阈值可包括第八预设阈值,当Docker容器内运行的程序的资源消耗量小于第八预设阈值时,对主机的数量进行缩容处理;当上述指标为CPU使用率,第一预设指标阈值可包括第九预设阈值,当CPU使用率小于第九预设阈值时,对主机的数量进行缩容处理;当上述指标为内存使用率,第一预设指标阈值可包括第十预设阈值,当内存使用率小于第十预设阈值时,对主机的数量进行缩容处理。另外,上述进行缩容处理的步骤需要根据系统当前的第二业务量数据来对主机的数量进行缩容处理,具体地,首先获取当前的第二业务量数据,然后将当前的第二原主机数量缩容至与所述第二业务量数据相匹配的第二主机数量以完成对主机的缩容处理,其中上述第二原主机数量是指进行缩容处理前的主机的数量。在本实施例,当检测得到的指标参数数据小于上述第二预设指标阈值时,通过将当前的第二原主机数量缩容至与所述第二业务量数据相匹配的第一主机数量,有利于实现根据当前的第二业务量数据来对主机的数量进行有效的弹性伸缩,保证系统的高效稳定运行,有效地提高系统的资源使用率,减少系统的资源浪费。As described in the above steps S303 to S305, the standard index threshold also includes a second preset index threshold corresponding to the above-mentioned shrinking process, and the second preset index threshold is less than the first preset index threshold, and it is determined that After the comparison result is not that the index parameter data is greater than the first preset index threshold, it is further necessary to determine whether the comparison result is that the index parameter data is less than the second preset index threshold. When the comparison result is that the index parameter data is greater than The first preset index threshold, that is, when the index parameter data obtained by real-time detection is less than the second preset index threshold, the scaling process will be performed. Wherein, the second preset index threshold corresponds to a plurality of preset thresholds corresponding to each index. Specifically, when the index is the system response time, the second preset index threshold may include the sixth preset threshold. When the system response time is less than the sixth preset threshold, the number of hosts will be scaled down; when the above indicator is the number of pod functions in the Docker container, the second preset indicator threshold may include the seventh preset threshold. When the number of pod functions in the container is less than the seventh preset threshold, the number of hosts is scaled down; when the above indicator is the resource consumption of the program running in the Docker container, the first preset indicator threshold may include the eighth preset threshold. Set a threshold. When the resource consumption of the program running in the Docker container is less than the eighth preset threshold, the number of hosts is scaled down; when the above indicator is the CPU usage rate, the first preset indicator threshold may include the ninth preset threshold. Set a threshold. When the CPU usage rate is less than the ninth preset threshold, the number of hosts will be scaled down; when the above indicator is the memory usage rate, the first preset indicator threshold may include the tenth preset threshold. When the memory usage rate is When it is less than the tenth preset threshold, the number of hosts is reduced. In addition, the above-mentioned steps of shrinking processing need to shrink the number of hosts according to the current second business volume data of the system. Specifically, first obtain the current second business volume data, and then change the current second original host The number is scaled down to the number of second hosts matching the second service volume data to complete the scaling process of the host, where the second original host number refers to the number of hosts before the scaling process. In this embodiment, when the detected index parameter data is less than the aforementioned second preset index threshold, the current number of second original hosts is reduced to the number of first hosts matching the second service volume data, It is beneficial to realize the effective elastic scaling of the number of hosts according to the current second business volume data, ensure the efficient and stable operation of the system, effectively improve the resource utilization rate of the system, and reduce the waste of system resources.
进一步地,本申请一实施例中,上述步骤S305,包括:Further, in an embodiment of the present application, the above step S305 includes:
S3050:获取各所述主机的衰老值,以及与所述第二业务量数据相匹配的所述第二主机数量,并将所述第二原主机数量与所述第二主机数量的差值记为减少主机数量;S3050: Obtain the aging value of each of the hosts and the number of the second hosts that match the second business volume data, and record the difference between the number of the second original host and the number of the second host To reduce the number of hosts;
S3051:将各所述主机的衰老值按照数值由大到小的顺序进行排序,得到衰老值排序;S3051: Sort the aging value of each host in descending order of numerical value to obtain the aging value ranking;
S3052:根据所述衰老值排序,依次从所述衰老值排序中筛选出与所述减少主机数量对应的多个指定衰老值;S3052: According to the aging value ranking, sequentially select multiple designated aging values corresponding to the reduced number of hosts from the aging value ranking;
S3053:将与各所述指定衰老值对应的各指定主机进行回收。S3053: Reclaim each designated host corresponding to each designated aging value.
如上述步骤S3050至S3053所述,上述将当前的第二原主机数量缩容至与所述第二业务量数据相匹配的第二主机数量的步骤,是通过从当前所有的主机中筛选出衰老值最高的且与上述减少主机数量对应的多个指定主机进行回收来实现的,其中上述第二原主机数量是指进行缩容处理前的主机的数量,上述衰老值最高的主机代表处理速度慢,效率低的主机。具体地,首先获取各所述主机的衰老值,以及与上述第二业务量数据相匹配的第二主机数量,并将第二原主机数量与第二主机数量的差值记为减少主机数量,其中主机的衰老值可通过计算主机的主机衰老值与各主机内的各Docker容器的容器衰老值的和值得出。在计算得到每一个主机的衰老值后,可将每一个主机的衰老值按照数值由大到小的顺序进行排序,得到对应的衰老值排序,并且根据该衰老值排序来依次从衰老值排序中筛选出与上述减少主机数量对应的多个指定衰老值,最后便可以得到与该多个指定衰老值对应的多个指定主机,通过将上述多个指定主机进行回收来完成对主机的缩容处理。在本实施例,当需要进行缩容处理时,在计算出各主机当前的衰老值并得到与各衰老值对应的衰老值排序后,便可从直接从衰老值排序筛选出该多个衰老值较大的指定主机进行回收。通过将一些衰老值较大、存在时间较长的主机进行淘汰,有利于减少系统的资源消耗,也能提升系统的处理效率。As described in the above steps S3050 to S3053, the above step of reducing the current number of second original hosts to the number of second hosts matching the second business volume data is to filter out old hosts from all current hosts. The number of designated hosts with the highest value and corresponding to the aforementioned reduction of the number of hosts is realized by recycling, where the number of the second original host refers to the number of hosts before the shrinking process, and the host with the highest aging value represents slow processing speed , Inefficient host. Specifically, first obtain the aging value of each of the hosts and the number of second hosts that match the above-mentioned second business volume data, and record the difference between the number of second original hosts and the number of second hosts as the reduced number of hosts, The aging value of the host can be obtained by calculating the sum of the aging value of the host and the container aging value of each Docker container in each host. After calculating the aging value of each host, the aging value of each host can be sorted in descending order of numerical value to obtain the corresponding aging value ranking, and sorting from the aging value according to the aging value ranking Multiple designated aging values corresponding to the above-mentioned reduced number of hosts are filtered out, and finally multiple designated hosts corresponding to the multiple designated aging values can be obtained, and the shrinking process of the hosts is completed by recycling the above-mentioned multiple designated hosts . In this embodiment, when the shrinking process is required, after calculating the current aging value of each host and obtaining the aging value ranking corresponding to each aging value, the multiple aging values can be filtered directly from the aging value ranking The larger designated host is recycled. By eliminating some hosts with a large aging value and a long time existence, it is helpful to reduce the resource consumption of the system and also improve the processing efficiency of the system.
进一步地,本申请一实施例中,上述步骤S3050之前,包括:Further, in an embodiment of the present application, before the above step S3050, the method includes:
S30500:获取各所述主机的第一生命周期,并将所述第一生命周期输入到预设的第一公式,以求出各所述主机对应的主机衰老值,其中所述第一公式为:S1=50分*D/120,S1为主机衰老值,D为第一生命周期,且D超过120天按120天算;以及,S30500: Obtain the first life cycle of each host, and input the first life cycle into a preset first formula to obtain a host aging value corresponding to each host, where the first formula is : S1=50 points*D/120, S1 is the host aging value, D is the first life cycle, and D is over 120 days as 120 days; and,
S30501:获取各所述主机内各Docker容器的第二生命周期,并将所述第二生命周期输入到预设的第二公式,以求出各所述主机内的各所述Docker容器的容器衰老值,其中所述第二公式为:S2=50分/Docker容器个数*H1/240+...+50分/Docker容器个数*Hn/240,Hn为第二生命周期,且Hn超过240小时按240小时算,不足一小时按一小时算;S30501: Obtain the second life cycle of each Docker container in each host, and input the second life cycle into a preset second formula to find the container of each Docker container in each host Aging value, where the second formula is: S2=50 points/number of Docker containers*H1/240+...+50 points/number of Docker containers*Hn/240, Hn is the second life cycle, and Hn More than 240 hours are counted as 240 hours, and less than one hour is counted as one hour;
S30502:分别计算各所述主机的主机衰老值与各所述主机内的各所述Docker容器的容器衰老值的和值,得到各所述主机的衰老值。S30502: Calculate the sum of the host aging value of each host and the container aging value of each Docker container in each host to obtain the aging value of each host.
如上述步骤S30500至S30502所述,在获取各上述主机的衰老值的步骤之前,还包括对各上述主机的衰老值进行计算的过程,且各主机的衰老值可通过计算主机的主机衰老值与各主机内的各Docker容器的容器衰老值的和值得出。具体地,首先获取各主机的第一生命周期,并将所述第一生命周期输入到预设的第一公式来求出各所述主机对应的主机衰老值,其中上述的第一生命周期是指主机的已创建时间,上述的第一预设公式为:主机衰老值=50分*D/120(D:为主机已创建天数,即存活的天数,D超过120天按120天算);然后获取各主机内各Docker容器的第二生命周期,并将所述第二生命周期输入到预设的第二公式,以求出各所述主机内的各所述Docker容器的容器衰老值,其中上述的第二生命周期是指的Docker容器的已创建时间,上述的第二预设公式为容器衰老值=50分/Docker容器个数*H1/240+...+50分/Docker容器个数* Hn/240(Hn:为Docker容器已创建小时,即存活的小时数。Hn超过240小时按240小时算,不足一小时按一小时算);最后分别计算各主机的主机衰老值与各主机内的各Docker容器的容器衰老值的和值,便可以得到每一个主机的衰老值。As described in the above steps S30500 to S30502, before the step of obtaining the aging value of each of the above hosts, it also includes a process of calculating the aging value of each of the above hosts, and the aging value of each host can be calculated by calculating the host aging value of the host and The sum of the container aging value of each Docker container in each host is calculated. Specifically, first obtain the first life cycle of each host, and input the first life cycle into a preset first formula to obtain the host aging value corresponding to each host, where the first life cycle is Refers to the creation time of the host. The first preset formula mentioned above is: host aging value=50 minutes*D/120 (D: is the number of days the host has been created, that is, the number of days that the host has been alive, and D exceeds 120 days as 120 days); Then obtain the second life cycle of each Docker container in each host, and input the second life cycle into a preset second formula to obtain the container aging value of each Docker container in each host, The second life cycle mentioned above refers to the time when the Docker container has been created. The second preset formula mentioned above is the aging value of the container=50 points/number of Docker containers*H1/240+...+50 points/Docker container Number* Hn/240 (Hn: Docker container has been created hours, that is, the number of hours alive. Hn over 240 hours is calculated as 240 hours, less than one hour is calculated as one hour); finally calculate the host aging value of each host and The aging value of each Docker container in each host is summed to obtain the aging value of each host.
进一步地,本申请一实施例中,上述步骤S30500之前,包括:Further, in an embodiment of the present application, before the foregoing step S30500, the method includes:
S305000:获取各所述主机对应的第一创建时间以及各所述主机内各Docker容器对应的第二创建时间;S305000: Obtain the first creation time corresponding to each host and the second creation time corresponding to each Docker container in each host;
S305001:分别计算当前时间与各所述主机的第一创建时间的各第一差值,得到各所述主机对应的各所述第一生命周期;以及S305001: Calculate each first difference between the current time and the first creation time of each of the hosts to obtain each of the first life cycles corresponding to each of the hosts; and
S305002:分别计算当前时间与各所述主机内各所述Docker容器的第二创建时间的各第二差值,得到各所述Docker容器对应的各所述第二生命周期。S305002: Calculate each second difference between the current time and the second creation time of each Docker container in each host, respectively, to obtain each second life cycle corresponding to each Docker container.
如上述步骤S305000至S305002所述,由于主机的衰老值可通过计算主机的主机衰老值与各主机内的各Docker容器的容器衰老值的和值得出,因此在计算出每一个主机对应的衰老值前,需要先计算出各主机的主机衰老值以及各主机内的Docker容器的容器衰老值。而在计算出各上述主机衰老值和各上述容器衰老值之前,需要先计算出各主机的第一生命周期以及各主机内的Docker容器的第二生命周期。具体地,首先要获取各主机的第一创建时间以及各主机内的Docker容器的第二创建时间,然后根据当前时间,通过分别计算当前时间与各所述主机的第一创建时间的各第一差值,便可得到上述各主机的第一生命周期,以及通过分别计算当前时间与各所述Docker容器的第二创建时间的各第二差值,便可得到上述各主机内的各Docker容器对应的第二生命周期。As described in the above steps S305000 to S305002, since the aging value of the host can be obtained by calculating the sum of the aging value of the host and the container aging value of each Docker container in each host, the aging value corresponding to each host is calculated Before, you need to calculate the host aging value of each host and the container aging value of the Docker container in each host. Before calculating the aging value of each host and the aging value of each container, it is necessary to calculate the first life cycle of each host and the second life cycle of the Docker container in each host. Specifically, the first creation time of each host and the second creation time of the Docker container in each host must be obtained first, and then according to the current time, the first creation time of the current time and the first creation time of each host The difference value can be used to obtain the first life cycle of each host, and the second difference between the current time and the second creation time of each Docker container can be calculated to obtain each Docker container in each host. The corresponding second life cycle.
进一步地,本申请一实施例中,上述步骤S3053之前,包括:Further, in an embodiment of the present application, before the above step S3053, the method includes:
S30530:提取出各所述指定主机内的指定数据;S30530: Extract the designated data in each of the designated hosts;
S30531:将所述指定数据存储到预设的数据库。S30531: Store the specified data in a preset database.
如上述步骤S30530和S30531所述,当需要对当前的主机进行缩容处理时,在从上述衰老值排序中筛选出与上述减少主机数量对应的多个指定衰老值,并查询出与该多个指定衰老值对应的多个指定主机时,由于该多个指定主机内还存储有指定数据,其中上述指定数据可为该指定主机工作时保留的数据,且该指定数据可能包含有一些重要的数据,而此时如果直接对该指定主机进行回收则系统会直接将该指定数据进行删除,从而造成重要数据的丢失。在本实施例,在进行将与各指定衰老值对应的各指定主机进行回收的缩容操作之前,可先将上述指定主机内的指定数据进行数据备份,其中上述指定数据可为重要数据,对重要数据的具体内容不作具体限定,该重要数据可由系统自动筛选出来的或者根据业务人员的意愿进行筛选的,另外,可预先设置一个数据库,然后将该指定数据提取出来并转移到该数据库进行存储。本实施例通过在对指定主机进行回收之前对指定主机内的指定数据进行数据备份,有利于避免出现指定主机在被回收之后,指定数据会被删除并且无法恢复的情况,降低由于指定主机内的重要数据丢失而造成的损失。As described in the above steps S30530 and S30531, when the current host needs to be scaled down, multiple designated aging values corresponding to the reduced number of hosts are selected from the foregoing aging value sorting, and the multiple specified aging values corresponding to the number of When specifying multiple designated hosts corresponding to the aging value, because the multiple designated hosts also store designated data, the above-mentioned designated data can be the data retained when the designated host is working, and the designated data may contain some important data , And if the designated host is directly recycled at this time, the system will directly delete the designated data, resulting in the loss of important data. In this embodiment, before performing the shrinking operation of recovering each designated host corresponding to each designated aging value, the designated data in the designated host may be backed up. The designated data may be important data. The specific content of important data is not specifically limited. The important data can be screened automatically by the system or according to the wishes of the business personnel. In addition, a database can be set up in advance, and then the specified data can be extracted and transferred to the database for storage . This embodiment backs up the designated data in the designated host before recycling the designated host, which helps to avoid the situation that the designated data will be deleted and cannot be recovered after the designated host is recovered, and reduces the amount of data in the designated host. Loss caused by loss of important data.
本申请实施例的分布式系统中主机数量弹性伸缩方法,通过在预先设置好对应于主机的Docker容器的指标以及与该指标对应的标准指标阈值后,实时监控各主机对应的Docker容器的指标参数数据,再将该指标参数数据与该标准指标阈值进行比较得到比较结果,并根据该比较结果采用上述主机伸缩策略来对当前的主机数量进行与当前业务量对应的扩容处理或缩容处理,实现了根据各主机实时的指标参数数据来对主机的数量进行有效、精确的弹性伸缩,保证系统的高效稳定运行,有效地提高系统的资源使用率。The method for elastic scaling of the number of hosts in the distributed system of the embodiment of the present application monitors the indicator parameters of the Docker container corresponding to each host in real time after pre-setting the indicator of the Docker container corresponding to the host and the standard indicator threshold corresponding to the indicator Data, and then compare the index parameter data with the standard index threshold to obtain a comparison result, and according to the comparison result, the above host scaling strategy is used to expand or shrink the current number of hosts corresponding to the current business volume to achieve According to the real-time index parameter data of each host, the number of hosts can be effectively and accurately elastically scaled to ensure the efficient and stable operation of the system and effectively improve the resource utilization rate of the system.
参照图3,本申请一实施例中还提供了一种分布式系统中主机数量弹性伸缩装置,包括:3, an embodiment of the present application also provides an elastic scaling device for the number of hosts in a distributed system, including:
监控模块1,用于实时监控主机对应的Docker容器的指标参数数据,其中所述指标参数数据为与用户输入的指标相对应的参数数据,所述指标由所述用户根据所述主机对应的Docker容器进行设置,所述指标包括系统响应时间、Docker容器内的pod函数的数量、Docker容器内运行的程序的资源消耗量、CPU使用率以及内存使用率中的一种或多种;The monitoring module 1 is used to monitor the indicator parameter data of the Docker container corresponding to the host in real time, wherein the indicator parameter data is the parameter data corresponding to the indicator input by the user, and the indicator is determined by the user according to the Docker corresponding to the host. The container is set, and the indicators include one or more of system response time, the number of pod functions in the Docker container, the resource consumption of programs running in the Docker container, the CPU usage rate, and the memory usage rate;
比较模块2,用于将所述指标参数数据与预设的标准指标阈值进行比较,得到比较结果;The comparison module 2 is used to compare the index parameter data with a preset standard index threshold to obtain a comparison result;
处理模块3,用于根据所述比较结果,通过预设的主机伸缩策略对所述主机的数量进行与当前业务量对应的弹性伸缩处理,所述弹性伸缩处理包括扩容处理或缩容处理。The processing module 3 is configured to perform an elastic scaling process corresponding to the current business volume on the number of hosts through a preset host scaling strategy according to the comparison result, and the elastic scaling process includes capacity expansion processing or capacity reduction processing.
本实施例中,上述监控模块、比较模块与处理模块的功能和作用的实现过程具体详见上述分布式系统中主机数量弹性伸缩方法中对应步骤S1-S3的实现过程,在此不再赘述。In this embodiment, the implementation process of the functions and roles of the monitoring module, the comparison module, and the processing module are detailed in the implementation process of the corresponding steps S1-S3 in the method for elastic scaling of the number of hosts in the distributed system, which will not be repeated here.
进一步地,本申请一实施例中,所述标准指标阈值包括与所述扩容处理对应的第一预设指标阈值,上述处理模块,包括:Further, in an embodiment of the present application, the standard index threshold includes a first preset index threshold corresponding to the expansion process, and the above processing module includes:
第一判断单元,用于判断所述比较结果是否为所述指标参数数据大于所述第一预设指标阈值;The first judgment unit is configured to judge whether the comparison result is that the index parameter data is greater than the first preset index threshold;
第一获取单元,用于若是,获取当前的第一业务量数据;The first obtaining unit is configured to obtain current first business volume data if yes;
扩容单元,用于将当前的第一原主机数量扩容至与所述第一业务量数据相匹配的第一主机数量。The expansion unit is configured to expand the current number of first original hosts to the number of first hosts matching the first service volume data.
本实施例中,上述第一判断单元、第一获取单元与扩容单元的功能和作用的实现过程具体详见上述分布式系统中主机数量弹性伸缩方法中对应步骤S300-S302的实现过程,在此不再赘述。In this embodiment, the implementation process of the functions and roles of the first judging unit, the first acquiring unit, and the capacity expansion unit are detailed in the implementation process corresponding to steps S300-S302 in the method for elastic scaling of the number of hosts in the distributed system, here No longer.
进一步地,本申请一实施例中,所述标准指标阈值包括与所述缩容处理对应的第二预设指标阈值,上述处理模块,包括:Further, in an embodiment of the present application, the standard index threshold includes a second preset index threshold corresponding to the shrinking process, and the above processing module includes:
第二判断单元,用于判断所述比较结果是否为所述指标参数数据小于所述第二预设指标阈值,其中所述第二预设阈值小于所述第一预设阈值;A second judgment unit, configured to judge whether the comparison result is that the index parameter data is less than the second preset index threshold, wherein the second preset threshold is less than the first preset threshold;
第二获取单元,用于若是,获取当前的第二业务量数据;The second acquiring unit is configured to, if yes, acquire the current second business volume data;
缩容单元,用于将当前的第二原主机数量缩容至与所述第二业务量数据相匹配的第二主机数量。The shrinking unit is configured to shrink the current number of second original hosts to the number of second hosts matching the second service volume data.
本实施例中,上述第二判断单元、第二获取单元与缩容单元的功能和作用的实现过程具体详见上述分布式系统中主机数量弹性伸缩方法中对应步骤S303-S305的实现过程,在此不再赘述。In this embodiment, the implementation process of the functions and effects of the second judgment unit, the second acquisition unit, and the scaling unit are detailed in the implementation process corresponding to steps S303-S305 in the method for elastic scaling of the number of hosts in the distributed system. This will not be repeated here.
进一步地,本申请一实施例中,上述缩容单元,包括:Further, in an embodiment of the present application, the aforementioned shrinking unit includes:
第一获取子单元,用于获取各所述主机的衰老值,以及与所述第二业务量数据相匹配的所述第二主机数量,并将所述第二原主机数量与所述第二主机数量的差值记为减少主机数量;排序子单元,用于将各所述主机的衰老值按照数值由大到小的顺序进行排序,得到衰老值排序;The first obtaining subunit is used to obtain the aging value of each of the hosts, and the number of the second hosts matching the second service volume data, and compare the number of the second original host with the second The difference in the number of hosts is recorded as reducing the number of hosts; the sorting subunit is used to sort the aging value of each of the hosts in numerical order from large to small to obtain the aging value ranking;
筛选子单元,用于根据所述衰老值排序,依次从所述衰老值排序中筛选出与所述减少主机数量对应的多个指定衰老值;The screening subunit is used for sorting according to the aging value, and sequentially selecting a plurality of designated aging values corresponding to the reduced number of hosts from the aging value sorting;
回收子单元,用于将与各所述指定衰老值对应的各指定主机进行回收。The recovery subunit is used to recover each designated host corresponding to each designated aging value.
本实施例中,上述第一获取子单元、筛选子单元与回收子单元的功能和作用的实现过程具体详见上述分布式系统中主机数量弹性伸缩方法中对应步骤S3050-S3053的实现过程,在此不再赘述。In this embodiment, the implementation process of the functions and roles of the first acquisition sub-unit, the screening sub-unit, and the recycling sub-unit is detailed in the implementation process corresponding to steps S3050-S3053 in the method for elastic scaling of the number of hosts in the distributed system. This will not be repeated here.
进一步地,本申请一实施例中,上述缩容单元,包括:Further, in an embodiment of the present application, the aforementioned shrinking unit includes:
第二获取子单元,用于获取各所述主机的第一生命周期,并将所述第一生命周期输入到预设的第一公式,以求出各所述主机对应的主机衰老值,其中所述第一公式为:S1=50分*D/120,S1为主机衰老值,D为第一生命周期,且D超过120天按120天算;以及,The second acquiring subunit is used to acquire the first life cycle of each of the hosts, and input the first life cycle into a preset first formula to obtain the host aging value corresponding to each of the hosts, where The first formula is: S1=50 points*D/120, S1 is the host aging value, D is the first life cycle, and D exceeds 120 days as 120 days; and,
第三获取子单元,用于获取各所述主机内各Docker容器的第二生命周期,并将所述第二生命周期输入到预设的第二公式,以求出各所述主机内的各所述Docker容器的容器衰老值,其中所述第二公式为:S2=50分/Docker容器个数*H1/240+...+50分/Docker容器个数*Hn/240,Hn为第二生命周期,且Hn超过240小时按240小时算,不足一小时按一小时算;The third acquisition subunit is used to acquire the second life cycle of each Docker container in each host, and input the second life cycle into a preset second formula to obtain each The container aging value of the Docker container, wherein the second formula is: S2=50 points/number of Docker containers*H1/240+...+50 points/number of Docker containers*Hn/240, where Hn is the first 2. Life cycle, and Hn exceeds 240 hours as 240 hours, and less than one hour as one hour;
第一计算子单元,用于分别计算各所述主机的主机衰老值与各所述主机内的各所述Docker容器的容器衰老值的和值,得到各所述主机的衰老值。The first calculation subunit is used to calculate the sum of the host aging value of each host and the container aging value of each Docker container in each host to obtain the aging value of each host.
本实施例中,上述第二获取子单元、第三获取子单元与第一计算子单元的功能和作用的实现过程具体详见上述分布式系统中主机数量弹性伸缩方法中对应步骤S30500-S30502的实现过程,在此不再赘述。In this embodiment, the implementation process of the functions and roles of the second acquisition subunit, the third acquisition subunit, and the first calculation subunit is detailed in the corresponding steps S30500-S30502 in the method for elastic scaling of the number of hosts in the distributed system. The realization process will not be repeated here.
进一步地,本申请一实施例中,上述缩容单元,包括:Further, in an embodiment of the present application, the aforementioned shrinking unit includes:
第四获取子单元,用于获取各所述主机对应的第一创建时间以及各所述主机内各Docker容器对应的第二创建时间;The fourth obtaining subunit is configured to obtain the first creation time corresponding to each host and the second creation time corresponding to each Docker container in each host;
第二计算子单元,用于分别计算当前时间与各所述主机的第一创建时间的各第一差值,得到各所述主机对应的各所述第一生命周期;以及The second calculation subunit is configured to calculate each first difference between the current time and the first creation time of each of the hosts to obtain each of the first life cycles corresponding to each of the hosts; and
第三计算子单元,用于分别计算当前时间与各所述主机内各所述Docker容器的第二创建时间的各第二差值,得到各所述Docker容器对应的各所述第二生命周期。The third calculation subunit is used to calculate the second difference between the current time and the second creation time of each Docker container in each host to obtain each second life cycle corresponding to each Docker container .
本实施例中,上述第四获取子单元、第二计算子单元与第三计算子单元的功能和作用的实现过程具体详见上述分布式系统中主机数量弹性伸缩方法中对应步骤S305000-S305002的实现过程,在此不再赘述。In this embodiment, the implementation process of the functions and roles of the fourth acquisition subunit, the second calculation subunit, and the third calculation subunit are detailed in the corresponding steps S305000-S305002 in the method for elastic scaling of the number of hosts in the distributed system. The realization process will not be repeated here.
进一步地,本申请一实施例中,上述缩容单元,包括:Further, in an embodiment of the present application, the aforementioned shrinking unit includes:
提取子单元,用于提取出各所述指定主机内的指定数据;Extracting subunit for extracting designated data in each designated host;
存储子单元,用于将所述指定数据存储到预设的数据库。The storage subunit is used to store the specified data in a preset database.
本实施例中,上述提取子单元与存储子单元的功能和作用的实现过程具体详见上述分布式系统中主机数量弹性伸缩方法中对应步骤S30530-S30531的实现过程,在此不再赘述。In this embodiment, the implementation process of the functions and roles of the extraction subunit and the storage subunit is detailed in the implementation process of the corresponding steps S30530-S30531 in the method for elastic scaling of the number of hosts in the distributed system, which will not be repeated here.
本申请实施例的分布式系统中主机数量弹性伸缩装置,通过在预先设置好对应于主机的Docker容器的指标以及与该指标对应的标准指标阈值后,实时监控各主机对应的Docker容器的指标参数数据,再将该指标参数数据与该标准指标阈值进行比较得到比较结果,并根据该比较结果采用上述主机伸缩策略来对当前的主机数量进行与当前业务量对应的扩容处理或缩容处理,实现了根据各主机实时的指标参数数据来对主机的数量进行有效、精确的弹性伸缩,保证系统的高效稳定运行,有效地提高系统的资源使用率。The device for elastically scaling the number of hosts in the distributed system of the embodiment of the present application monitors the indicator parameters of the Docker container corresponding to each host in real time after pre-setting the indicator of the Docker container corresponding to the host and the standard indicator threshold corresponding to the indicator Data, and then compare the index parameter data with the standard index threshold to obtain a comparison result, and according to the comparison result, the above host scaling strategy is used to expand or shrink the current number of hosts corresponding to the current business volume to achieve According to the real-time index parameter data of each host, the number of hosts can be effectively and accurately elastically scaled to ensure the efficient and stable operation of the system and effectively improve the resource utilization rate of the system.
参照图4,本申请实施例中还提供一种计算机设备,该计算机设备可以是服务器,其内部结构可以如图4所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设备设计的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机可读指令和数据库。该内存储器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的数据库用于存储标准指标阈值与指标参数数据等数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机可读指令在执行时,执行如上述各方法的实施例的流程。本领域技术人员可以理解,图4中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的装置、计算机设备的限定。Referring to FIG. 4, an embodiment of the present application also provides a computer device. The computer device may be a server, and its internal structure may be as shown in FIG. 4. The computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor designed for the computer equipment is used to provide calculation and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer readable instructions, and a database. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the non-volatile storage medium. The database of the computer equipment is used to store data such as standard index thresholds and index parameter data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer-readable instruction is executed, it executes the process of the above-mentioned method embodiment. Those skilled in the art can understand that the structure shown in FIG. 4 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the devices and computer equipment to which the solution of the present application is applied.
本申请一实施例还提供一种计算机非易失性可读存储介质,其上存储有计算机可读指令,该计算机可读指令被处理器执行时实现如上述各方法的实施例的流程。An embodiment of the present application further provides a computer non-volatile readable storage medium, on which computer readable instructions are stored, and when the computer readable instructions are executed by a processor, the processes as in the foregoing method embodiments are implemented.
以上所述仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above are only the preferred embodiments of this application, and do not limit the scope of this application. Any equivalent structure or equivalent process transformation made using the content of this application description and drawings, or directly or indirectly applied to other related The technical field is equally included in the scope of patent protection of this application.

Claims (20)

  1. 一种分布式系统中主机数量弹性伸缩方法,其特征在于,包括:A method for elastic scaling of the number of hosts in a distributed system is characterized in that it includes:
    实时监控主机对应的Docker容器的指标参数数据,其中所述指标参数数据为与用户输入的指标相对应的参数数据,所述指标由所述用户根据所述主机对应的Docker容器进行设置,所述指标包括系统响应时间、Docker容器内的pod函数的数量、Docker容器内运行的程序的资源消耗量、CPU使用率以及内存使用率中的一种或多种;Monitor the indicator parameter data of the Docker container corresponding to the host in real time, where the indicator parameter data is parameter data corresponding to the indicator input by the user, and the indicator is set by the user according to the Docker container corresponding to the host. Indicators include one or more of system response time, the number of pod functions in the Docker container, the resource consumption of the programs running in the Docker container, CPU usage, and memory usage;
    将所述指标参数数据与预设的标准指标阈值进行比较,得到比较结果,其中所述标准指标阈值至少包括与扩容处理对应的第一预设指标阈值;Comparing the index parameter data with a preset standard index threshold to obtain a comparison result, where the standard index threshold includes at least a first preset index threshold corresponding to the expansion process;
    判断所述比较结果是否为所述指标参数数据大于所述第一预设指标阈值;Judging whether the comparison result is that the index parameter data is greater than the first preset index threshold;
    若是,获取当前的第一业务量数据;If yes, obtain the current first business volume data;
    将当前的第一原主机数量扩容至与所述第一业务量数据相匹配的第一主机数量。Expanding the current number of first original hosts to the number of first hosts matching the first service volume data.
  2. 根据权利要求1所述的分布式系统中主机数量弹性伸缩方法,其特征在于,所述标准指标阈值还包括与缩容处理对应的第二预设指标阈值,所述判断所述比较结果是否为所述指标参数数据大于所述第一预设指标阈值的步骤之后,包括:The method for elastic scaling of the number of hosts in a distributed system according to claim 1, wherein the standard index threshold further comprises a second preset index threshold corresponding to the scaling process, and the determining whether the comparison result is After the step of the index parameter data being greater than the first preset index threshold, the method includes:
    若否,判断所述比较结果是否为所述指标参数数据小于所述第二预设指标阈值,其中所述第二预设阈值小于所述第一预设阈值;If not, determine whether the comparison result is that the index parameter data is less than the second preset index threshold, where the second preset threshold is less than the first preset threshold;
    若是,获取当前的第二业务量数据;If yes, obtain the current second business volume data;
    将当前的第二原主机数量缩容至与所述第二业务量数据相匹配的第二主机数量。The current number of second original hosts is reduced to the number of second hosts matching the second service volume data.
  3. 根据权利要求2所述的分布式系统中主机数量弹性伸缩方法,其特征在于,所述将当前的第二原主机数量缩容至与所述第二业务量数据相匹配的第二主机数量的步骤,包括:The method for elastic scaling of the number of hosts in a distributed system according to claim 2, wherein the current number of second original hosts is reduced to less than the number of second hosts matching the second service volume data. The steps include:
    获取各所述主机的衰老值,以及与所述第二业务量数据相匹配的所述第二主机数量,并将所述第二原主机数量与所述第二主机数量的差值记为减少主机数量;Obtain the aging value of each of the hosts, and the number of the second hosts that match the second business volume data, and record the difference between the number of the second original host and the number of the second host as a decrease Number of hosts;
    将各所述主机的衰老值按照数值由大到小的顺序进行排序,得到衰老值排序;Sorting the aging value of each host in descending order of numerical value to obtain the aging value ranking;
    根据所述衰老值排序,依次从所述衰老值排序中筛选出与所述减少主机数量对应的多个指定衰老值;According to the aging value ranking, a plurality of designated aging values corresponding to the reduced number of hosts are sequentially selected from the aging value ranking;
    将与各所述指定衰老值对应的各指定主机进行回收。Each designated host corresponding to each designated aging value is recycled.
  4. 根据权利要求3所述的分布式系统中主机数量弹性伸缩方法,其特征在于,所述获取各所述主机的衰老值,以及与所述第二业务量数据相匹配的所述第二主机数量的步骤之前,包括:The method for elastic scaling of the number of hosts in a distributed system according to claim 3, wherein the acquiring the aging value of each of the hosts and the number of the second hosts matching the second service volume data Before the steps, include:
    获取各所述主机的第一生命周期,并将所述第一生命周期输入到预设的第一公式,以求出各所述主机对应的主机衰老值,其中所述第一公式为:S1=50分*D/120,S1为主机衰老值,D为第一生命周期,且D超过120天按120天算;以及,Obtain the first life cycle of each of the hosts, and input the first life cycle into a preset first formula to obtain the host aging value corresponding to each of the hosts, wherein the first formula is: S1 =50 points*D/120, S1 is the host aging value, D is the first life cycle, and D exceeds 120 days as 120 days; and,
    获取各所述主机内各Docker容器的第二生命周期,并将所述第二生命周期输入到预设的第二公式,以求出各所述主机内的各所述Docker容器的容器衰老值,其中所述第二公式为:S2=50分/Docker容器个数*H1/240+...+50分/Docker容器个数*Hn/240,Hn为第二生命周期,且Hn超过240小时按240小时算,不足一小时按一小时算;Obtain the second life cycle of each Docker container in each host, and input the second life cycle into a preset second formula to obtain the container aging value of each Docker container in each host , Where the second formula is: S2=50 points/number of Docker containers*H1/240+...+50 points/number of Docker containers*Hn/240, Hn is the second life cycle, and Hn exceeds 240 Hour is calculated as 240 hours, and less than one hour is calculated as one hour;
    分别计算各所述主机的主机衰老值与各所述主机内的各所述Docker容器的容器衰老值的和值,得到各所述主机的衰老值。The sum of the host aging value of each host and the container aging value of each Docker container in each host is calculated respectively to obtain the aging value of each host.
  5. 根据权利要求4所述的分布式系统中主机数量弹性伸缩方法,其特征在于,所述获取各所述主机的第一生命周期,并将所述第一生命周期输入到预设的第一公式,以求出各所述主机对应的主机衰老值的步骤之前,包括:The method for elastic scaling of the number of hosts in a distributed system according to claim 4, wherein the first life cycle of each of the hosts is obtained, and the first life cycle is input into a preset first formula , Before the step of obtaining the host aging value corresponding to each host includes:
    获取各所述主机对应的第一创建时间以及各所述主机内各Docker容器对应的第二创建时间;Acquiring the first creation time corresponding to each host and the second creation time corresponding to each Docker container in each host;
    分别计算当前时间与各所述主机的第一创建时间的各第一差值,得到各所述主机对应的各所述第一生命周期;以及,Respectively calculating each first difference between the current time and the first creation time of each of the hosts to obtain each of the first life cycles corresponding to each of the hosts; and,
    分别计算当前时间与各所述主机内各所述Docker容器的第二创建时间的各第二差值,得到各所述Docker容器对应的各所述第二生命周期。Each second difference value between the current time and the second creation time of each Docker container in each host is calculated respectively to obtain each second life cycle corresponding to each Docker container.
  6. 根据权利要求3所述的分布式系统中主机数量弹性伸缩方法,其特征在于,所述将与各所述指定衰老值对应的各指定主机进行回收的步骤之前,包括:The method for elastic scaling of the number of hosts in a distributed system according to claim 3, characterized in that, before the step of recycling the designated hosts corresponding to the designated aging values, the method comprises:
    提取出各所述指定主机内的指定数据;Extract the designated data in each of the designated hosts;
    将所述指定数据存储到预设的数据库。The specified data is stored in a preset database.
  7. 一种分布式系统中主机数量弹性伸缩装置,其特征在于,包括:An elastic scaling device for the number of hosts in a distributed system, characterized in that it comprises:
    监控模块,用于实时监控主机对应的Docker容器的指标参数数据,其中所述指标参数数据为与用户输入的指标相对应的参数数据,所述指标由所述用户根据所述主机对应的Docker容器进行设置,所述指标包括系统响应时间、Docker容器内的pod函数的数量、Docker容器内运行的程序的资源消耗量、CPU使用率以及内存使用率中的一种或多种;The monitoring module is used to monitor the indicator parameter data of the Docker container corresponding to the host in real time, wherein the indicator parameter data is parameter data corresponding to the indicator input by the user, and the indicator is determined by the user according to the Docker container corresponding to the host Setting, the indicators include one or more of system response time, the number of pod functions in the Docker container, the resource consumption of programs running in the Docker container, the CPU usage rate, and the memory usage rate;
    比较模块,用于将所述指标参数数据与预设的标准指标阈值进行比较,得到比较结果,其中所述标准指标阈值至少包括与扩容处理对应的第一预设指标阈值;A comparison module, configured to compare the index parameter data with a preset standard index threshold to obtain a comparison result, where the standard index threshold includes at least a first preset index threshold corresponding to the expansion process;
    第一判断模块,用于判断所述比较结果是否为所述指标参数数据大于所述第一预设指标阈值;The first judgment module is configured to judge whether the comparison result is that the index parameter data is greater than the first preset index threshold;
    第一获取模块,用于若是,获取当前的第一业务量数据;The first obtaining module is used to obtain the current first business volume data if yes;
    扩容模块,用于将当前的第一原主机数量扩容至与所述第一业务量数据相匹配的第一主机数量。The expansion module is used to expand the current number of first original hosts to the number of first hosts matching the first service volume data.
  8. 根据权利要求7所述的分布式系统中主机数量弹性伸缩装置,其特征在于,所述标准指标阈值还包括与所述缩容处理对应的第二预设指标阈值,所述分布式系统中主机数量弹性伸缩装置,包括:The device for elastic scaling of the number of hosts in a distributed system according to claim 7, wherein the standard index threshold further comprises a second preset index threshold corresponding to the scaling process, and the host in the distributed system A number of elastic expansion devices, including:
    第二判断模块,用于判断所述比较结果是否为所述指标参数数据小于所述第二预设指标阈值,其中所述第二预设阈值小于所述第一预设阈值;A second judgment module, configured to judge whether the comparison result is that the index parameter data is less than the second preset index threshold, wherein the second preset threshold is less than the first preset threshold;
    第二获取模块,用于若是,获取当前的第二业务量数据;The second obtaining module is used to obtain the current second business volume data if yes;
    缩容模块,用于将当前的第二原主机数量缩容至与所述第二业务量数据相匹配的第二主机数量。The shrinking module is used to shrink the current number of second original hosts to the number of second hosts matching the second service volume data.
  9. 根据权利要求8所述的分布式系统中主机数量弹性伸缩装置,其特征在于,所述缩容模块,包括:The device for elastically scaling the number of hosts in a distributed system according to claim 8, wherein the shrinking module comprises:
    第一获取单元,用于获取各所述主机的衰老值,以及与所述第二业务量数据相匹配的所述第二主机数量,并将所述第二原主机数量与所述第二主机数量的差值记为减少主机数量;排序子单元,用于将各所述主机的衰老值按照数值由大到小的顺序进行排序,得到衰老值排序;The first obtaining unit is configured to obtain the aging value of each of the hosts, and the number of the second hosts that match the second service volume data, and compare the number of the second original host with the second host The difference in quantity is recorded as reducing the number of hosts; the sorting sub-unit is used to sort the aging value of each host in descending order of numerical value to obtain the aging value ranking;
    筛选单元,用于根据所述衰老值排序,依次从所述衰老值排序中筛选出与所述减少主机数量对应的多个指定衰老值;The screening unit is configured to sort according to the aging value, and sequentially filter out multiple designated aging values corresponding to the reduced number of hosts from the aging value sorting;
    回收单元,用于将与各所述指定衰老值对应的各指定主机进行回收。The recovery unit is used to recover each designated host corresponding to each designated aging value.
  10. 根据权利要求9所述的分布式系统中主机数量弹性伸缩装置,其特征在于,所述缩容模块,包括:The device for elastically scaling the number of hosts in a distributed system according to claim 9, wherein the shrinking module comprises:
    第二获取单元,用于获取各所述主机的第一生命周期,并将所述第一生命周期输入到预设的第一公式,以求出各所述主机对应的主机衰老值,其中所述第一公式为:S1=50分*D/120,S1为主机衰老值,D为第一生命周期,且D超过120天按120天算;以及,The second acquiring unit is used to acquire the first life cycle of each of the hosts, and input the first life cycle into a preset first formula to obtain the host aging value corresponding to each of the hosts, where The first formula is: S1=50 points*D/120, S1 is the host aging value, D is the first life cycle, and D exceeds 120 days as 120 days; and,
    第三获取单元,用于获取各所述主机内各Docker容器的第二生命周期,并将所述第二生命周期输入到预设的第二公式,以求出各所述主机内的各所述Docker容器的容器衰老值,其中所述第二公式为:S2=50分/Docker容器个数*H1/240+...+50分/Docker容器个数*Hn/240,Hn为第二生命周期,且Hn超过240小时按240小时算,不足一小时按一小时算;The third acquiring unit is used to acquire the second life cycle of each Docker container in each host, and input the second life cycle into a preset second formula, so as to obtain each location in each host. The container aging value of the Docker container, where the second formula is: S2=50 points/number of Docker containers*H1/240+...+50 points/number of Docker containers*Hn/240, Hn is the second Life cycle, and Hn exceeds 240 hours as 240 hours, and less than one hour as one hour;
    第一计算单元,用于分别计算各所述主机的主机衰老值与各所述主机内的各所述Docker容器的容器衰老值的和值,得到各所述主机的衰老值。The first calculation unit is used to calculate the sum of the host aging value of each host and the container aging value of each Docker container in each host to obtain the aging value of each host.
  11. 根据权利要求10所述的分布式系统中主机数量弹性伸缩装置,其特征在于,所述缩容模块,包括:The device for elastically scaling the number of hosts in a distributed system according to claim 10, wherein the shrinking module comprises:
    第四获取单元,用于获取各所述主机对应的第一创建时间以及各所述主机内各Docker容器对应的第二创建时间;The fourth obtaining unit is configured to obtain the first creation time corresponding to each of the hosts and the second creation time corresponding to each Docker container in each of the hosts;
    第二计算单元,用于分别计算当前时间与各所述主机的第一创建时间的各第一差值,得到各所述主机对应的各所述第一生命周期;以及The second calculation unit is configured to calculate each first difference between the current time and the first creation time of each of the hosts to obtain each of the first life cycles corresponding to each of the hosts; and
    第三计算单元,用于分别计算当前时间与各所述主机内各所述Docker容器的第二创建时间的各第二差值,得到各所述Docker容器对应的各所述第二生命周期。The third calculation unit is configured to calculate each second difference between the current time and the second creation time of each Docker container in each host to obtain each second life cycle corresponding to each Docker container.
  12. 根据权利要求9所述的分布式系统中主机数量弹性伸缩装置,其特征在于,所述缩容模块,包括:The device for elastically scaling the number of hosts in a distributed system according to claim 9, wherein the shrinking module comprises:
    提取单元,用于提取出各所述指定主机内的指定数据;An extraction unit for extracting designated data in each of the designated hosts;
    存储单元,用于将所述指定数据存储到预设的数据库。The storage unit is used to store the specified data in a preset database.
  13. 一种计算机设备,包括存储器和处理器,所述存储器中存储有计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现分布式系统中主机数量弹性伸缩方法,该分布式系统中主机数量弹性伸缩方法,包括:A computer device includes a memory and a processor, and computer-readable instructions are stored in the memory. The method is characterized in that, when the processor executes the computer-readable instructions, a method for elastically scaling the number of hosts in a distributed system is implemented. The method for elastic scaling of the number of hosts in a distributed system includes:
    实时监控主机对应的Docker容器的指标参数数据,其中所述指标参数数据为与用户输入的指标相对应的参数数据,所述指标由所述用户根据所述主机对应的Docker容器进行设置,所述指标包括系统响应时间、Docker容器内的pod函数的数量、Docker容器内运行的程序的资源消耗量、CPU使用率以及内存使用率中的一种或多种;Monitor the indicator parameter data of the Docker container corresponding to the host in real time, where the indicator parameter data is parameter data corresponding to the indicator input by the user, and the indicator is set by the user according to the Docker container corresponding to the host. Indicators include one or more of system response time, the number of pod functions in the Docker container, the resource consumption of the programs running in the Docker container, CPU usage, and memory usage;
    将所述指标参数数据与预设的标准指标阈值进行比较,得到比较结果,其中所述标准指标阈值至少包括与扩容处理对应的第一预设指标阈值;Comparing the index parameter data with a preset standard index threshold to obtain a comparison result, where the standard index threshold includes at least a first preset index threshold corresponding to the expansion process;
    判断所述比较结果是否为所述指标参数数据大于所述第一预设指标阈值;Judging whether the comparison result is that the index parameter data is greater than the first preset index threshold;
    若是,获取当前的第一业务量数据;If yes, obtain the current first business volume data;
    将当前的第一原主机数量扩容至与所述第一业务量数据相匹配的第一主机数量。Expanding the current number of first original hosts to the number of first hosts matching the first service volume data.
  14. 根据权利要求13所述的计算机设备,其特征在于,所述标准指标阈值还包括与缩容处理对应的第二预设指标阈值,所述判断所述比较结果是否为所述指标参数数据大于所述第一预设指标阈值的步骤之后,包括:The computer device according to claim 13, wherein the standard index threshold value further comprises a second preset index threshold value corresponding to the shrinking process, and the determining whether the comparison result is that the index parameter data is greater than all After the step of describing the first preset index threshold, it includes:
    若否,判断所述比较结果是否为所述指标参数数据小于所述第二预设指标阈值,其中所述第二预设阈值小于所述第一预设阈值;If not, determine whether the comparison result is that the index parameter data is less than the second preset index threshold, where the second preset threshold is less than the first preset threshold;
    若是,获取当前的第二业务量数据;If yes, obtain the current second business volume data;
    将当前的第二原主机数量缩容至与所述第二业务量数据相匹配的第二主机数量。The current number of second original hosts is reduced to the number of second hosts matching the second service volume data.
  15. 根据权利要求14所述的计算机设备,其特征在于,所述将当前的第二原主机数量缩容至与所述第二业务量数据相匹配的第二主机数量的步骤,包括:The computer device according to claim 14, wherein the step of reducing the current number of second original hosts to the number of second hosts matching the second service volume data comprises:
    获取各所述主机的衰老值,以及与所述第二业务量数据相匹配的所述第二主机数量,并将所述第二原主机数量与所述第二主机数量的差值记为减少主机数量;Obtain the aging value of each of the hosts, and the number of the second hosts that match the second business volume data, and record the difference between the number of the second original host and the number of the second host as a decrease Number of hosts;
    将各所述主机的衰老值按照数值由大到小的顺序进行排序,得到衰老值排序;Sorting the aging value of each host in descending order of numerical value to obtain the aging value ranking;
    根据所述衰老值排序,依次从所述衰老值排序中筛选出与所述减少主机数量对应的多个指定衰老值;According to the aging value ranking, a plurality of designated aging values corresponding to the reduced number of hosts are sequentially selected from the aging value ranking;
    将与各所述指定衰老值对应的各指定主机进行回收。Each designated host corresponding to each designated aging value is recycled.
  16. 根据权利要求15所述的计算机设备,其特征在于,所述获取各所述主机的衰老值,以及与所述第二业务量数据相匹配的所述第二主机数量的步骤之前,包括:15. The computer device according to claim 15, wherein before the step of acquiring the aging value of each of the hosts and the number of the second hosts matching the second service volume data, the method comprises:
    获取各所述主机的第一生命周期,并将所述第一生命周期输入到预设的第一公式,以求出各所述主机对应的主机衰老值,其中所述第一公式为:S1=50分*D/120,S1为主机衰老值,D为第一生命周期,且D超过120天按120天算;以及,Obtain the first life cycle of each of the hosts, and input the first life cycle into a preset first formula to obtain the host aging value corresponding to each of the hosts, wherein the first formula is: S1 =50 points*D/120, S1 is the host aging value, D is the first life cycle, and D exceeds 120 days as 120 days; and,
    获取各所述主机内各Docker容器的第二生命周期,并将所述第二生命周期输入到预设的第二公式,以求出各所述主机内的各所述Docker容器的容器衰老值,其中所述第二公式为:S2=50分/Docker容器个数*H1/240+...+50分/Docker容器个数*Hn/240,Hn为第二生命周期,且Hn超过240小时按240小时算,不足一小时按一小时算;Obtain the second life cycle of each Docker container in each host, and input the second life cycle into a preset second formula to obtain the container aging value of each Docker container in each host , Where the second formula is: S2=50 points/number of Docker containers*H1/240+...+50 points/number of Docker containers*Hn/240, Hn is the second life cycle, and Hn exceeds 240 Hour is calculated as 240 hours, and less than one hour is calculated as one hour;
    分别计算各所述主机的主机衰老值与各所述主机内的各所述Docker容器的容器衰老值的和值,得到各所述主机的衰老值。The sum of the host aging value of each host and the container aging value of each Docker container in each host is calculated respectively to obtain the aging value of each host.
  17. 一种计算机非易失性可读存储介质,其上存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现分布式系统中主机数量弹性伸缩方法,该分布式系统中主机数量弹性伸缩方法,包括:A computer nonvolatile readable storage medium having computer readable instructions stored thereon, wherein the computer readable instructions are executed by a processor to implement a method for elastic scaling of the number of hosts in a distributed system. The methods for elastic scaling of the number of hosts in the system include:
    实时监控主机对应的Docker容器的指标参数数据,其中所述指标参数数据为与用户输入的指标相对应的参数数据,所述指标由所述用户根据所述主机对应的Docker容器进行设置,所述指标包括系统响应时间、Docker容器内的pod函数的数量、Docker容器内运行的程序的资源消耗量、CPU使用率以及内存使用率中的一种或多种;Monitor the indicator parameter data of the Docker container corresponding to the host in real time, where the indicator parameter data is parameter data corresponding to the indicator input by the user, and the indicator is set by the user according to the Docker container corresponding to the host. Indicators include one or more of system response time, the number of pod functions in the Docker container, the resource consumption of the programs running in the Docker container, CPU usage, and memory usage;
    将所述指标参数数据与预设的标准指标阈值进行比较,得到比较结果,其中所述标准指标阈值至少包括与扩容处理对应的第一预设指标阈值;Comparing the index parameter data with a preset standard index threshold to obtain a comparison result, where the standard index threshold includes at least a first preset index threshold corresponding to the expansion process;
    判断所述比较结果是否为所述指标参数数据大于所述第一预设指标阈值;Judging whether the comparison result is that the index parameter data is greater than the first preset index threshold;
    若是,获取当前的第一业务量数据;If yes, obtain the current first business volume data;
    将当前的第一原主机数量扩容至与所述第一业务量数据相匹配的第一主机数量。Expanding the current number of first original hosts to the number of first hosts matching the first service volume data.
  18. 根据权利要求17所述的计算机非易失性可读存储介质,其特征在于,所述标准指标阈值还包括与缩容处理对应的第二预设指标阈值,所述判断所述比较结果是否为所述指标参数数据大于所述第一预设指标阈值的步骤之后,包括:The computer non-volatile readable storage medium according to claim 17, wherein the standard index threshold value further comprises a second preset index threshold value corresponding to the shrinking process, and the determining whether the comparison result is After the step of the index parameter data being greater than the first preset index threshold, the method includes:
    若否,判断所述比较结果是否为所述指标参数数据小于所述第二预设指标阈值,其中所述第二预设阈值小于所述第一预设阈值;If not, determine whether the comparison result is that the index parameter data is less than the second preset index threshold, where the second preset threshold is less than the first preset threshold;
    若是,获取当前的第二业务量数据;If yes, obtain the current second business volume data;
    将当前的第二原主机数量缩容至与所述第二业务量数据相匹配的第二主机数量。The current number of second original hosts is reduced to the number of second hosts matching the second service volume data.
  19. 根据权利要求18所述的计算机非易失性可读存储介质,其特征在于,所述将当前的第二原主机数量缩容至与所述第二业务量数据相匹配的第二主机数量的步骤,包括:The computer non-volatile readable storage medium according to claim 18, wherein the current number of the second original host is reduced to a maximum of the number of the second host matching the second service volume data The steps include:
    获取各所述主机的衰老值,以及与所述第二业务量数据相匹配的所述第二主机数量,并将所述第二原主机数量与所述第二主机数量的差值记为减少主机数量;Obtain the aging value of each of the hosts, and the number of the second hosts that match the second business volume data, and record the difference between the number of the second original host and the number of the second host as a decrease Number of hosts;
    将各所述主机的衰老值按照数值由大到小的顺序进行排序,得到衰老值排序;Sorting the aging value of each host in descending order of numerical value to obtain the aging value ranking;
    根据所述衰老值排序,依次从所述衰老值排序中筛选出与所述减少主机数量对应的多个指定衰老值;According to the aging value ranking, a plurality of designated aging values corresponding to the reduced number of hosts are sequentially selected from the aging value ranking;
    将与各所述指定衰老值对应的各指定主机进行回收。Each designated host corresponding to each designated aging value is recycled.
  20. 根据权利要求19所述的计算机非易失性可读存储介质,其特征在于,所述获取各所述主机的衰老值,以及与所述第二业务量数据相匹配的所述第二主机数量的步骤之前,包括:The computer non-volatile readable storage medium according to claim 19, wherein the acquiring the aging value of each of the hosts, and the number of the second hosts matching the second service volume data Before the steps, include:
    获取各所述主机的第一生命周期,并将所述第一生命周期输入到预设的第一公式,以求出各所述主机对应的主机衰老值,其中所述第一公式为:S1=50分*D/120,S1为主机衰老值,D为第一生命周期,且D超过120天按120天算;以及,Obtain the first life cycle of each of the hosts, and input the first life cycle into a preset first formula to obtain the host aging value corresponding to each of the hosts, wherein the first formula is: S1 =50 points*D/120, S1 is the host aging value, D is the first life cycle, and D exceeds 120 days as 120 days; and,
    获取各所述主机内各Docker容器的第二生命周期,并将所述第二生命周期输入到预设的第二公式,以求出各所述主机内的各所述Docker容器的容器衰老值,其中所述第二公式为:S2=50分/Docker容器个数*H1/240+...+50分/Docker容器个数*Hn/240,Hn为第二生命周期,且Hn超过240小时按240小时算,不足一小时按一小时算;Obtain the second life cycle of each Docker container in each host, and input the second life cycle into a preset second formula to obtain the container aging value of each Docker container in each host , Where the second formula is: S2=50 points/number of Docker containers*H1/240+...+50 points/number of Docker containers*Hn/240, Hn is the second life cycle, and Hn exceeds 240 Hour is calculated as 240 hours, and less than one hour is calculated as one hour;
    分别计算各所述主机的主机衰老值与各所述主机内的各所述Docker容器的容器衰老值的和值,得到各所述主机的衰老值。The sum of the host aging value of each host and the container aging value of each Docker container in each host is calculated respectively to obtain the aging value of each host.
PCT/CN2019/103546 2019-04-16 2019-08-30 Elastic scaling method and apparatus for number of hosts in distributed system, and computer device WO2020211253A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910305187.9A CN110175068A (en) 2019-04-16 2019-04-16 Host number elastic telescopic method, apparatus and computer equipment in distributed system
CN201910305187.9 2019-04-16

Publications (1)

Publication Number Publication Date
WO2020211253A1 true WO2020211253A1 (en) 2020-10-22

Family

ID=67689980

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/103546 WO2020211253A1 (en) 2019-04-16 2019-08-30 Elastic scaling method and apparatus for number of hosts in distributed system, and computer device

Country Status (2)

Country Link
CN (1) CN110175068A (en)
WO (1) WO2020211253A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110175068A (en) * 2019-04-16 2019-08-27 平安科技(深圳)有限公司 Host number elastic telescopic method, apparatus and computer equipment in distributed system
CN113138860B (en) * 2020-01-17 2023-11-03 中国移动通信集团浙江有限公司 Message queue management method and device
CN111464355B (en) * 2020-03-31 2022-11-15 北京金山云网络技术有限公司 Method and device for controlling expansion and contraction capacity of Kubernets container cluster and network equipment
CN112799854B (en) * 2021-04-15 2021-07-13 腾讯科技(深圳)有限公司 Task processing method and device, electronic equipment and readable storage medium
CN114745278B (en) * 2022-04-11 2024-05-24 中和农信农业集团有限公司 Method and device for expanding and shrinking capacity of service system, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3073383A1 (en) * 2013-11-19 2016-09-28 ZTE Corporation Method, device, and computer storage medium for hierarchical storage
US20170011028A1 (en) * 2015-07-08 2017-01-12 Alibaba Group Holding Limited Apparatuses and methods for flexible scheduling in a database system
WO2017123554A1 (en) * 2016-01-11 2017-07-20 Alibaba Group Holding Limited Method, system, and device for allocating resources in a server
CN107656807A (en) * 2016-07-26 2018-02-02 华为技术有限公司 The automatic elastic telescopic method and device of a kind of virtual resource
CN110175068A (en) * 2019-04-16 2019-08-27 平安科技(深圳)有限公司 Host number elastic telescopic method, apparatus and computer equipment in distributed system

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106603618A (en) * 2016-09-14 2017-04-26 浪潮电子信息产业股份有限公司 Cloud platform-based application auto scaling method
CN106961351A (en) * 2017-03-03 2017-07-18 南京邮电大学 Intelligent elastic telescopic method based on Docker container clusters
CN106992887A (en) * 2017-04-05 2017-07-28 国家电网公司 The implementation method of application example elastic telescopic based on container, apparatus and system
CN108228347A (en) * 2017-12-21 2018-06-29 上海电机学院 The Docker self-adapting dispatching systems that a kind of task perceives
CN108769100A (en) * 2018-04-03 2018-11-06 郑州云海信息技术有限公司 A kind of implementation method and its device based on kubernetes number of containers elastic telescopics

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3073383A1 (en) * 2013-11-19 2016-09-28 ZTE Corporation Method, device, and computer storage medium for hierarchical storage
US20170011028A1 (en) * 2015-07-08 2017-01-12 Alibaba Group Holding Limited Apparatuses and methods for flexible scheduling in a database system
WO2017123554A1 (en) * 2016-01-11 2017-07-20 Alibaba Group Holding Limited Method, system, and device for allocating resources in a server
CN107656807A (en) * 2016-07-26 2018-02-02 华为技术有限公司 The automatic elastic telescopic method and device of a kind of virtual resource
CN110175068A (en) * 2019-04-16 2019-08-27 平安科技(深圳)有限公司 Host number elastic telescopic method, apparatus and computer equipment in distributed system

Also Published As

Publication number Publication date
CN110175068A (en) 2019-08-27

Similar Documents

Publication Publication Date Title
WO2020211253A1 (en) Elastic scaling method and apparatus for number of hosts in distributed system, and computer device
CN106802826B (en) Service processing method and device based on thread pool
CN109539473B (en) Fault type determination method of air conditioning system and electronic equipment
CN107783829B (en) Task processing method and device, storage medium and computer equipment
WO2020232871A1 (en) Method and device for microservice dependency analysis
US10452402B2 (en) Operation instruction response control method and terminal for human-machine interface
WO2019223174A1 (en) Automatic task rerunning method and system, computer device and storage medium
CN111930589B (en) Streaming task automatic monitoring system and method
CN114637650B (en) Elastic expansion method based on Kubernetes cluster
WO2020143181A1 (en) Data storage method, apparatus, computer device and storage medium
WO2022110863A1 (en) Compatibility detection method and apparatus, device, and readable storage medium
CN105511937A (en) Batch virtual machine blue screen monitoring method suitable for cloud platform
CN112434308A (en) Application vulnerability detection method and device, electronic equipment and computer storage medium
CN111090593A (en) Method, device, electronic equipment and storage medium for determining crash attribution
CN111124791A (en) System testing method and device
WO2024119930A1 (en) Scheduling method and apparatus, and computer device and storage medium
CN110704313B (en) JAVA virtual machine memory leakage detection method and device
WO2024021475A1 (en) Container scheduling method and apparatus
US7680921B2 (en) Management system, management computer, managed computer, management method and program
CN108255710B (en) Script abnormity detection method and terminal thereof
CN114490091B (en) Method and device for monitoring rule engine performance in industrial data acquisition management system
CN116450176A (en) Version updating method and device, electronic equipment and storage medium
CN115269519A (en) Log detection method and device and electronic equipment
CN111090627B (en) Log storage method and device based on pooling, computer equipment and storage medium
CN113469702A (en) Active risk identification model for intelligent contract

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19924700

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19924700

Country of ref document: EP

Kind code of ref document: A1