CN112764934B - Calculation method for CPU utilization rate of load balancing equipment - Google Patents

Calculation method for CPU utilization rate of load balancing equipment Download PDF

Info

Publication number
CN112764934B
CN112764934B CN202110122671.5A CN202110122671A CN112764934B CN 112764934 B CN112764934 B CN 112764934B CN 202110122671 A CN202110122671 A CN 202110122671A CN 112764934 B CN112764934 B CN 112764934B
Authority
CN
China
Prior art keywords
time
work
packet
cycle
pass
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN202110122671.5A
Other languages
Chinese (zh)
Other versions
CN112764934A (en
Inventor
王晓凡
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Hongji Information Technology Co Ltd
Original Assignee
Shanghai Hongji Information Technology Co Ltd
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 Shanghai Hongji Information Technology Co Ltd filed Critical Shanghai Hongji Information Technology Co Ltd
Priority to CN202110122671.5A priority Critical patent/CN112764934B/en
Publication of CN112764934A publication Critical patent/CN112764934A/en
Application granted granted Critical
Publication of CN112764934B publication Critical patent/CN112764934B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load

Abstract

The invention discloses a calculation method of CPU utilization rate of load balancing equipment, which calculates a time value of single cycle according to a formula of time pass = time end-time start; obtaining continuously-changed time all and time work values according to the calculation; at the end of each cycle, time pass is accumulated: time all = time all + time pass; at the end of each cycle, if packet exists is true, then calculate: time work = time work + time pass; calculating the CPU utilization rate according to the data; the CPU calculation method provided by the invention can accurately quantify and reflect the CPU busy/idle degree in a period of time for a load balancing system for polling and receiving packets.

Description

Calculation method for CPU utilization rate of load balancing equipment
Technical Field
The invention relates to the technical field of CPU utilization rate, in particular to a method for calculating the CPU utilization rate of load balancing equipment.
Background
Load balancing is a critical component of a high availability network infrastructure, typically used to distribute workload to multiple servers to improve the performance and reliability of websites, applications, databases, or other services.
In a web page (web) architecture without load balancing, users are directly connected to a web server, and if the server is down, the users have no way to access naturally. In addition, if many users attempt to access the server at the same time, the limit that they can handle is exceeded, there may be situations where the loading speed is slow or no connection at all.
This failure can be alleviated by introducing a load balancer and additional web servers. Typically, all backend servers will be guaranteed to provide the same content so that the user can receive consistent content regardless of which server responds. Additional multiple web servers may also share the load, relieving individual web servers of stress, and thus handling more user requests.
The load balancing device may be software or a dedicated hardware device.
To achieve the highest performance, the load balancing program may monopolize the entire Central Processing Unit (CPU) core and employ a round robin packet reception scheme. I.e. to continuously try to collect data packets from the network card in a dead loop, and to process the packets immediately once they are.
For maximum efficiency, the load balancing process is typically exclusive of the CPU. And the method of the endless loop polling for receiving the packets is that the program is continuously polled even if no data packet exists on the network card. Thus, the CPU occupancy rate of this process is always kept at 100% in view of the operating system (e.g., linux, a widely used operating system).
Therefore, a method for calculating the CPU utilization rate of the load balancing device is a urgent problem to be solved.
Disclosure of Invention
The invention aims to provide a novel CPU statistical method aiming at a polling and packet-collecting mode, wherein the CPU utilization rate displayed under an operating system of a load balancing system can not reflect the real situation.
In order to achieve the above purpose, the technical scheme provided by the invention is as follows: a calculation method of CPU utilization rate of load balancing equipment comprises the following steps:
step 1: recording a current time value time start at the beginning of each cycle, and recording a current time value end at the end of each cycle; the time of the single cycle is time pass, and the time value of the single cycle can be calculated according to the formula of time pass = time end-time start;
step 2: setting a data packet detection point as a packet exists, and if the current cycle detects that the network card has a received packet, setting the packet exists as true, otherwise setting the packet exists as false;
step 3: setting an accumulated total time variable time all, and accumulating a total time variable work when the network card receives the packet;
step 4: obtaining continuously-changed time all and time work values according to the calculation;
at the end of each cycle, time pass is accumulated: time all = time all + time pass;
at the end of each cycle, if packet exists is true, then calculate: time work = time work + time pass; if the packet exists is false, not performing calculation;
step 5: calculating the CPU utilization rate:
counting CPU utilization rate from time t0 to time t1 (t 0< t 1):
the values of time all and time work are read at time t0 and are noted as: time all_0 and time work_0;
the values of time all and time work are read at time t1 and are noted as: time all_1 and time work_1;
the CPU usage in the time period t0 to t1 is:
i.e. the ratio of the time for processing the data packet to the total time during this period.
As an improvement, in the step 4, if the network card has not received the packet, the time work is always 0; if the network card has a packet receiving function every time, the time all is equal to the time work.
Compared with the prior art, the invention has the advantages that: the CPU calculation method provided by the invention can accurately quantify and reflect the CPU busy/idle degree in a period of time for a load balancing system for polling and receiving packets.
Drawings
Fig. 1 is a flowchart of a method for calculating CPU utilization of a load balancing device according to the present invention.
Detailed Description
The method for calculating the CPU utilization rate of the load balancing device is further described in detail below with reference to the accompanying drawings.
The invention discloses a method for calculating the CPU utilization rate of load balancing equipment, which comprises the following specific implementation processes:
recording a current time value time start at the beginning of each cycle, and recording a current time value end at the end of each cycle; the time of the single cycle is time pass, and the time value of the single cycle can be calculated according to the formula of time pass = time end-time start; setting a data packet detection point as a packet exists, and if the current cycle detects that the network card has a received packet, setting the packet exists as true, otherwise setting the packet exists as false; setting a cumulative total time variable time all, and accumulating a total time variable work when the network card receives the packet.
Obtaining continuously-changed time all and time work values according to the calculation; at the end of each cycle, time pass is accumulated: time all = time all + time pass; at the end of each cycle, if packet exists is true, then calculate: time work = time work + time pass; if the packet exists is false, not performing calculation; if the network card has not received the packet, the time work is always 0; if the network card has a packet receiving function every time, the time all is equal to the time work.
The calculation method of the CPU utilization rate is as follows:
counting CPU utilization rate from time t0 to time t1 (t 0< t 1):
the values of time all and time work are read at time t0 and are noted as: time all_0 and time work_0;
the values of time all and time work are read at time t1 and are noted as: time all_1 and time work_1;
the CPU usage in the time period t0 to t1 is:
i.e. the ratio of the time for processing the data packet to the total time during this period.
The invention and its embodiments have been described above with no limitation, and the actual construction is not limited to the embodiments of the invention as shown in the drawings. In summary, if one of ordinary skill in the art is informed by this disclosure, a structural manner and an embodiment similar to the technical solution should not be creatively devised without departing from the gist of the present invention.

Claims (2)

1. The method for calculating the CPU utilization rate of the load balancing equipment is characterized by comprising the following steps of:
step 1: recording a current time value time start at the beginning of each cycle, and recording a current time value end at the end of each cycle; the time of the single cycle is time pass, and the time value of the single cycle can be calculated according to the formula of time pass = time end-time start;
step 2: setting a data packet detection point as a packet exists, and if the current cycle detects that the network card has a received packet, setting the packet exists as true, otherwise setting the packet exists as false;
step 3: setting an accumulated total time variable time all, wherein the initial value of the accumulated total time variable time all is time all=0; the total time variable time work when the accumulated network card receives the packet is the initial value of time work=0;
step 4: obtaining continuously-changed time all and time work values according to the calculation;
at the end of each cycle, time pass is accumulated: time all = time all + time pass;
at the end of each cycle, if packet exists is true, then calculate: time work = time work + time pass; if the packet exists is false, not performing calculation;
step 5: calculating the CPU utilization rate:
counting CPU utilization rate from time t0 to time t1 (t 0< t 1):
the values of time all and time work are read at time t0 and are noted as: time all_0 and time work_0;
the values of time all and time work are read at time t1 and are noted as: time all_1 and time work_1;
the CPU usage in the time period t0 to t1 is:
i.e. the ratio of the time for processing the data packet to the total time during this period.
2. The method for calculating the CPU utilization of the load balancing device according to claim 1, wherein: in the step 4, if the network card has not received the packet, the time work is always 0; if the network card has a packet receiving function every time, the time all is equal to the time work.
CN202110122671.5A 2021-01-29 2021-01-29 Calculation method for CPU utilization rate of load balancing equipment Active CN112764934B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110122671.5A CN112764934B (en) 2021-01-29 2021-01-29 Calculation method for CPU utilization rate of load balancing equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110122671.5A CN112764934B (en) 2021-01-29 2021-01-29 Calculation method for CPU utilization rate of load balancing equipment

Publications (2)

Publication Number Publication Date
CN112764934A CN112764934A (en) 2021-05-07
CN112764934B true CN112764934B (en) 2024-01-30

Family

ID=75706587

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110122671.5A Active CN112764934B (en) 2021-01-29 2021-01-29 Calculation method for CPU utilization rate of load balancing equipment

Country Status (1)

Country Link
CN (1) CN112764934B (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1664789A (en) * 2004-03-04 2005-09-07 中兴通讯股份有限公司 Method for real-time CPU occupation rate detection of operating systems
CN106201441A (en) * 2016-07-08 2016-12-07 汉柏科技有限公司 The acquisition methods of cpu busy percentage and device in a kind of network equipment
CN106527653A (en) * 2016-10-12 2017-03-22 东软集团股份有限公司 CPU frequency adjusting method and apparatus
CN107491378A (en) * 2017-08-31 2017-12-19 杭州迪普科技股份有限公司 A kind of determination method and device of CPU usage
CN107491372A (en) * 2017-08-03 2017-12-19 郑州云海信息技术有限公司 A kind of method and system for linux system RPM bags statistics CPU usage
CN107832157A (en) * 2017-12-13 2018-03-23 深圳天珑无线科技有限公司 Dynamic power supply management method, mobile terminal and storage medium
CN107977302A (en) * 2017-11-24 2018-05-01 杭州迪普科技股份有限公司 A kind of CPU usage output method and device
CN108446176A (en) * 2018-02-07 2018-08-24 平安普惠企业管理有限公司 A kind of method for allocating tasks, computer readable storage medium and terminal device
CN109002377A (en) * 2018-07-26 2018-12-14 郑州云海信息技术有限公司 A kind of processor detection method, processor detection device and computer equipment
CN109684167A (en) * 2018-12-06 2019-04-26 北京城市网邻信息技术有限公司 Calculation method, device, storage medium and the terminal of application program CPU usage
CN111552614A (en) * 2020-04-28 2020-08-18 杭州迪普科技股份有限公司 Statistical method and device for CPU utilization rate

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11593134B2 (en) * 2018-01-26 2023-02-28 Nicira, Inc. Throttling CPU utilization by implementing a rate limiter

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1664789A (en) * 2004-03-04 2005-09-07 中兴通讯股份有限公司 Method for real-time CPU occupation rate detection of operating systems
CN106201441A (en) * 2016-07-08 2016-12-07 汉柏科技有限公司 The acquisition methods of cpu busy percentage and device in a kind of network equipment
CN106527653A (en) * 2016-10-12 2017-03-22 东软集团股份有限公司 CPU frequency adjusting method and apparatus
CN107491372A (en) * 2017-08-03 2017-12-19 郑州云海信息技术有限公司 A kind of method and system for linux system RPM bags statistics CPU usage
CN107491378A (en) * 2017-08-31 2017-12-19 杭州迪普科技股份有限公司 A kind of determination method and device of CPU usage
CN107977302A (en) * 2017-11-24 2018-05-01 杭州迪普科技股份有限公司 A kind of CPU usage output method and device
CN107832157A (en) * 2017-12-13 2018-03-23 深圳天珑无线科技有限公司 Dynamic power supply management method, mobile terminal and storage medium
CN108446176A (en) * 2018-02-07 2018-08-24 平安普惠企业管理有限公司 A kind of method for allocating tasks, computer readable storage medium and terminal device
CN109002377A (en) * 2018-07-26 2018-12-14 郑州云海信息技术有限公司 A kind of processor detection method, processor detection device and computer equipment
CN109684167A (en) * 2018-12-06 2019-04-26 北京城市网邻信息技术有限公司 Calculation method, device, storage medium and the terminal of application program CPU usage
CN111552614A (en) * 2020-04-28 2020-08-18 杭州迪普科技股份有限公司 Statistical method and device for CPU utilization rate

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种基于多衡量指标的HDFS负载均衡算法;康承昆;刘晓洁;;四川大学学报(自然科学版)(第06期);全文 *

Also Published As

Publication number Publication date
CN112764934A (en) 2021-05-07

Similar Documents

Publication Publication Date Title
CN110276182B (en) API distributed current limiting realization method
CN112162865B (en) Scheduling method and device of server and server
WO2022057391A1 (en) Cache memory adjustment method, apparatus, and computer device
CN110858843B (en) Service request processing method and device and computer readable storage medium
CN110162270B (en) Data storage method, storage node and medium based on distributed storage system
CN1201246C (en) Dynamic loading balance method for cluster server
CN103561354B (en) Method and device for calculating and processing video smoothness
CN109981744B (en) Data distribution method and device, storage medium and electronic equipment
CN110795284B (en) Data recovery method, device and equipment and readable storage medium
CN110708256A (en) CDN scheduling method, device, network equipment and storage medium
CN111104303A (en) Server index data acquisition method, device and medium
CN110365598B (en) Heartbeat message sending method, device, server, terminal and storage medium
CN111538572A (en) Task processing method, device, scheduling server and medium
CN112764934B (en) Calculation method for CPU utilization rate of load balancing equipment
CN106201721B (en) A kind of memory dynamic adjusting method and system based on virtualization technology
CN112596985B (en) IT asset detection method, device, equipment and medium
CN111597041B (en) Calling method and device of distributed system, terminal equipment and server
JP2006317991A (en) Method for tuning process number
CN115334001B (en) Data resource scheduling method and device based on priority relation
CN113079062B (en) Resource adjusting method and device, computer equipment and storage medium
CN110769272A (en) Node adjusting method and related equipment thereof
Zhang et al. An Improved Nginx Dynamic Load Balancing Algorithm
US20190347139A1 (en) Technique for Determining a Load of an Application
CN115567597A (en) Message request forwarding method and device of payment settlement system
CN111953567B (en) Method, system, equipment and medium for configuring multi-cluster management software parameters

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant