WO2018188542A1 - 计数方法、计数器及存储介质 - Google Patents

计数方法、计数器及存储介质 Download PDF

Info

Publication number
WO2018188542A1
WO2018188542A1 PCT/CN2018/082233 CN2018082233W WO2018188542A1 WO 2018188542 A1 WO2018188542 A1 WO 2018188542A1 CN 2018082233 W CN2018082233 W CN 2018082233W WO 2018188542 A1 WO2018188542 A1 WO 2018188542A1
Authority
WO
WIPO (PCT)
Prior art keywords
application source
current
mode
database
counting application
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.)
Ceased
Application number
PCT/CN2018/082233
Other languages
English (en)
French (fr)
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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to US16/495,839 priority Critical patent/US11455293B2/en
Priority to SG11201908133V priority patent/SG11201908133VA/en
Publication of WO2018188542A1 publication Critical patent/WO2018188542A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/217Database tuning
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2379Updates performed during online database operations; commit processing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • H04L41/0813Configuration setting characterised by the conditions triggering a change of settings
    • H04L41/082Configuration setting characterised by the conditions triggering a change of settings the condition being updates or upgrades of network functionality
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0876Network utilisation, e.g. volume of load or congestion level
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0876Network utilisation, e.g. volume of load or congestion level
    • H04L43/0882Utilisation of link capacity
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/16Threshold monitoring
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/50Testing arrangements

Definitions

  • the present application relates to the field of data processing technologies, and in particular, to a counting method, a counter, and a storage medium.
  • the embodiment of the present application provides a counting method, a counter, and a storage medium, which can dynamically adjust the mode of the counting application source update database, reduce the frequency of interaction with the database, and reduce the pressure of the database while ensuring the counting accuracy.
  • the present application provides a counting method, the method comprising:
  • the number of the current counting application source unit time and the server related parameter are obtained, and the server related parameter includes at least one of a CPU usage rate, a memory usage rate, and a current network connection number;
  • a mode of the current counting application source update database the mode including a real-time mode and a high-performance mode
  • the mode of the current counting application source update database is the high performance mode, the counts generated by the current counting application source running in the server are accumulated to obtain an accumulated value;
  • the accumulated value of the current counting application source is updated to the database according to the preset frequency.
  • the application further provides a counter, the counter comprising:
  • a detecting unit configured to detect whether there is a counting application source
  • the obtaining unit is configured to obtain, if there is a counting application source, a quantity of the current counting application source unit time and a server related parameter, where the server related parameter includes at least one of a CPU usage rate, a memory usage rate, and a current network connection number. ;
  • a determining unit configured to determine, according to the number of the counting or the server-related parameter, a mode of the current counting application source update database, where the mode includes a real-time mode and a high-performance mode;
  • a counting unit configured to accumulate a count generated by running the current counting application source in the server to obtain an accumulated value if the mode of the current counting application source updating database is a high performance mode
  • an updating unit configured to update the accumulated value of the current counting application source to the database according to the preset frequency.
  • the present application further provides another counter comprising a memory and a processor coupled to the memory; the memory for storing program data; the processor for running the memory stored in the memory Program data to perform a counting method as described in the first aspect above.
  • the embodiment of the present application further provides a computer readable storage medium, where the one or more program data is stored, and the one or more program data may be processed by one or more processes.
  • the apparatus is executed to implement a counting method as described in the above first aspect.
  • the embodiment of the present application can dynamically adjust the mode of the counting application source update database, and reduce the frequency of interaction with the database while reducing the pressure of the database while ensuring the counting accuracy.
  • the mode of counting the application source update database is the high performance mode
  • the database is updated according to the preset frequency to achieve a balance between database performance and counting accuracy.
  • FIG. 1 is a schematic flow chart of a counting method provided by an embodiment of the present application.
  • FIG. 2 is a schematic diagram of a sub-flow of a counting method provided by an embodiment of the present application.
  • FIG. 3 is a schematic diagram of another sub-flow of a counting method provided by an embodiment of the present application.
  • FIG. 4 is a schematic diagram of another sub-flow of a counting method provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of another sub-flow of a counting method according to an embodiment of the present application.
  • FIG. 6 is a schematic flow chart of a counting method according to another embodiment of the present application.
  • FIG. 7 is a schematic block diagram of a counter provided by an embodiment of the present application.
  • FIG. 8 is a schematic block diagram of a determining unit provided by an embodiment of the present application.
  • FIG. 9 is a schematic block diagram of another determining unit provided by an embodiment of the present application.
  • FIG. 10 is a schematic block diagram of an update unit provided by an embodiment of the present application.
  • FIG. 11 is a schematic block diagram of a counter provided by another embodiment of the present application.
  • FIG. 12 is a schematic block diagram of a counter provided by another embodiment of the present application.
  • FIG. 1 is a schematic flowchart diagram of a counting method according to an embodiment of the present application. The method includes S101 to S106.
  • Detect whether there is a source of counting applications Specifically, it is possible to detect whether there is a counting request source through a connection request. For example, if the IP address in the connection request is detected to match the IP address of the pre-stored counting application source, if there is a match, there is a counting application source.
  • the connection request for counting the application source is sent to the server.
  • the server related parameters include at least one of a CPU usage rate, a memory usage rate, and a current network connection number.
  • Unit time is not only a unit time, but also a period of time, such as 1 hour.
  • S103 Determine, according to the quantity counted in the unit time or the server-related parameter, a mode of the current counting application source update database, where the mode includes a real-time mode and a high-performance mode.
  • the high performance mode is a non-real time mode, that is, a mode other than the real time mode.
  • S104 is executed, and in the real time mode, S106 is executed.
  • the mode of the current counting application source update database is determined according to the number of counts in the current counting application source unit time.
  • S103 includes S201-S203. As shown in FIG. 2, in S201, it is determined whether the number of counts in a unit time exceeds a preset number. S202: If the number of counts per unit time exceeds a preset number, determine that the mode of the current count application source update database is a high performance mode. S203. If the number of counts in the unit time is less than or equal to the preset quantity, determine that the mode of the current count application source update database is the real-time mode.
  • the database is updated in real time; if the number of counts per unit time is relatively large, the database is updated in a high performance mode.
  • the mode of updating the database of the current counting application source can be dynamically adjusted, and the frequency of interaction between the server and the database is reduced while the accuracy of the counting is ensured, and the pressure on the server and the database is reduced.
  • the mode of the current counting application source update database may also be determined according to the server-related parameters.
  • S103 includes S301-S303. As shown in FIG. 3, in S301, it is determined whether the CPU usage rate is greater than the first preset usage rate, or whether the memory usage rate is greater than the second preset usage rate, or whether the current network connection number is equal to the maximum network connection number of the server. If yes, execute S302, otherwise, execute S303. S302. Determine that the mode of the current counting application source update database is a high performance mode. S303. Determine a mode in which the current counting application source update database is a real-time mode. Preferably, the first preset usage rate is 30%, and the second preset usage rate is 90%.
  • the server when the CPU usage is greater than 30%, or the memory usage is greater than 90%, or the current number of network connections is equal to the maximum number of network connections of the server, it can be understood that the server currently has a large amount of work to be processed, if the database is updated. If the mode is the implementation mode, the server will have more work to process, which will take up more CPU or memory, which will increase the pressure on the server and increase the pressure on the database. Therefore, when the CPU usage is greater than the first pre- Set the usage rate, or the memory usage rate is greater than the second preset usage rate, or the current network connection number is equal to the maximum number of network connections of the server.
  • the current counting application source uses the high performance mode to update the database. Otherwise, the database is updated in real time mode.
  • the technical solution described in FIG. 3 can dynamically adjust the mode of the current counting application source update database, reduce the frequency of interaction between the server and the database, reduce the pressure on the server and the database, and improve the performance of the server while ensuring the counting accuracy.
  • S104 Accumulate the count generated by the current counting application source running in the server to obtain an accumulated value.
  • the accumulated value of the current counting application source running in the server may be accumulated over a period of time to obtain an accumulated value.
  • the accumulated value may be cleared; or the current counting application source may be in the server.
  • the counts generated by the internal runs are accumulated and the accumulated values are obtained.
  • S105 Update the accumulated value of the current counting application source to the database according to a preset frequency. Wherein, if the accumulated value is obtained by accumulating the count generated by the operation within a certain period of time (the time corresponding to the preset frequency), the accumulated value of the current counting application source is incrementally added to the database, and is added to the database. , clear the accumulated value. If the accumulated value is obtained by accumulating the counts generated by the operation, the increment in the accumulated value of the current count application source is updated to the database according to the preset frequency.
  • the preset frequency is related to the number of counts in the current count application source unit time or the server-related parameters, wherein, preferably, the preset frequency initial value is 1 minute. After the execution of S105 is completed, it ends.
  • S105 includes S401-S403.
  • S401 Determine whether the number of counts of the current counting application source is reduced in a unit time. If it is decreased, S402 is executed, otherwise, S403 is executed.
  • S402. The preset frequency is correspondingly reduced, and the accumulated value of the current counting application source is updated to the database according to the reduced preset frequency.
  • S403. The preset frequency is increased correspondingly, and the accumulated value of the current counting application source is updated to the database according to the increased preset frequency.
  • the technical solution dynamically adjusts the frequency of the current counting application source update database to achieve a balance between database performance and counting accuracy.
  • S105 includes S501-S503.
  • S501 Determine whether the CPU usage rate or the memory usage rate or the current network connection number is increased. If it is increased, S502 is executed, otherwise, S503 is executed.
  • S502. Decrease the preset frequency correspondingly, and update the accumulated value of the current counting application source to the database according to the reduced preset frequency.
  • S503. The preset frequency is increased correspondingly, and the accumulated value of the current counting application source is updated to the database according to the increased preset frequency. Understandably, if the CPU usage or memory usage or the current number of network connections increases, the workload of the server increases. If the preset frequency is increased accordingly, the workload of the server is increased, and the pressure on the server is increased.
  • the technical solution dynamically adjusts the frequency of the current counting application source update database, that is, dynamically adjusts the interaction frequency between the server and the database, improves the performance of the server and the database, and can be between the performance of the database and the accuracy of the counting. Achieve balance.
  • S106 Update the count generated by the current counting application source running in the server to the database in real time.
  • FIG. 6 is a schematic flowchart diagram of a counting method according to another embodiment of the present application.
  • the method includes S601 to S611.
  • Detect whether there is a source of counting applications Specifically, it is possible to detect whether there is a counting request source through a connection request. For example, if the IP address in the connection request is detected to match the IP address of the pre-stored counting application source, if there is a match, there is a counting application source.
  • the connection request for counting the application source is sent to the server.
  • the server related parameters include at least one of a CPU usage rate, a memory usage rate, and a current network connection number.
  • Unit time is not only a unit time, but also a period of time, such as 1 hour.
  • S603. Determine, according to the quantity counted in the unit time or the server-related parameter, a mode of the current counting application source update database, where the mode includes a real-time mode and a high-performance mode.
  • the high performance mode is a non-real time mode, that is, a mode other than the real time mode.
  • S604 is executed, and in the real time mode, S609 is executed.
  • the mode of the current counting application source update database is judged according to the number of counts in the unit time, please refer to the content of FIG. 2 .
  • the mode of the current counting application source update database is determined, please refer to the content of FIG.
  • S604 accumulating the counts generated by the current counting application source running in the server to obtain an accumulated value.
  • the accumulated counts are generated by accumulating the counts generated by the current count application source running in the server for a period of time, and in this case, the accumulated values are cleared.
  • S605. Update the accumulated value of the current counting application source to the database according to the preset frequency.
  • the accumulated value is obtained by accumulating the counts generated by the operation within a certain period of time (the time corresponding to the preset frequency), then the accumulated value of the current counting application source is incrementally added to the database, and after being added to the database, Clear the accumulated value.
  • the preset frequency is related to the number of counts in the current count application source unit time or the server-related parameters, wherein, preferably, the preset frequency initial value is 1 minute.
  • S605 refers to the content described in FIG. 4. In other embodiments, S605 refers to the content described in FIG.
  • S607 Compare the current total amount of the current counting application source with the current accumulated value, and compare the threshold set by the current counting application source.
  • Each of the counting application sources sets a threshold. It can be understood that the number of times the other platforms call the server is limited, and cannot be called indefinitely. Can be applied in the billing scenario. If the current counting application source gives 100 bucks, then the number of times the current counting application source is allowed to call the server is 100. If it exceeds 100 times, the server will not be allowed to be called unless otherwise paid. .
  • S608 If the set threshold is exceeded, stop counting the current counting application source and issue an early warning. If the number of counts of the current counting application source has reached a predetermined threshold, the server will stop counting the current counting application source and issue an alert to remind the current counting application source to pay attention.
  • S609 Update the count generated by the current counting application source running in the server to the database in real time. If the current counting application source uses the real-time mode update database, the count generated by running the current counting application source in the server will be updated to the database in real time.
  • the method embodiment compares the current total count of the counting application source with the threshold set by the current counting application source, and if the set threshold is exceeded, stops counting the current counting application source and issues an early warning. Remind the current counting application source by stopping the counting of the current counting application source and issuing an alert.
  • FIG. 7 is a schematic block diagram of a counter provided by an embodiment of the present application.
  • the counter 70 includes a detecting unit 701, an obtaining unit 702, a determining unit 703, a counting unit 704, and an updating unit 705.
  • the detecting unit 701 is configured to detect whether there is a counting application source.
  • the obtaining unit 702 is configured to obtain, if the counting application source exists, the number of counts in the unit time of the current counting application source and the server related parameters.
  • the determining unit 703 is configured to determine, according to the current counting application source unit time count quantity or server related parameter, a mode of the current counting application source update database, where the mode includes a real time mode and a high performance mode.
  • the determining unit is configured to determine a mode of the current counting application source update database according to the number of counts in the current counting application source unit time.
  • the determining unit 703 includes a first determining unit 801 and a first determining unit. 802.
  • the first determining unit 801 is configured to determine whether the number of counts in the unit time exceeds a preset number.
  • the first determining unit 802 is configured to determine that the mode of the current counting application source update database is a high performance mode, if the number of counts per unit time exceeds a preset number.
  • the first determining unit 802 is further configured to determine that the mode of the current counting application source update database is a real-time mode, if the number of counts in the unit time is less than or equal to the preset number.
  • the determining unit is configured to determine a mode of the current counting application source update database according to the server related parameter.
  • the determining unit 703 includes a second determining unit 901 and a second determining unit 902.
  • the second determining unit 901 is configured to determine whether the CPU usage rate is greater than the first preset usage rate, or whether the memory usage rate is greater than the second preset usage rate, or whether the current network connection number is equal to the maximum network connection number of the server.
  • the second determining unit 902 is configured to determine that the current counting application source is updated if the CPU usage rate is greater than the first preset usage rate, or the memory usage rate is greater than the second preset usage rate, or the current network connection number is equal to the maximum network connection number of the server.
  • the mode of the database is high performance mode.
  • the second determining unit 902 is further configured to determine, in a case where the determination result of the second determining unit 901 is negative, that the mode of determining the current counting application source update database is the real-time mode.
  • the counting unit 704 is configured to accumulate the counts generated by the current counting application source running in the server to obtain an accumulated value if the mode of the current counting application source update database is the high performance mode.
  • the updating unit 705 is configured to update the accumulated value of the current counting application source to the database according to the preset frequency.
  • the update unit 705 includes a third determination unit 101 and a modification update unit 102.
  • the third determining unit 101 is configured to determine whether the number of the current counting application source counted in the unit time is decreased.
  • the update unit 102 is configured to: if the number of the current counting application source counted in the unit time decreases, correspondingly reduce the preset frequency, and update the accumulated value of the current counting application source to the database according to the reduced preset frequency. .
  • the update unit 102 is further configured to: if the current count application source increases the number of counts in the unit time, increase the preset frequency correspondingly, and update the accumulated value of the current count application source according to the increased preset frequency to database.
  • the third determining unit 101 is further configured to determine whether the CPU usage rate or the memory usage rate or the current network connection number is increased.
  • the update unit 102 is further configured to increase the CPU usage rate or the memory usage rate or the current network connection number, reduce the preset frequency correspondingly, and update the accumulated value of the current counting application source according to the reduced preset frequency to database.
  • the modification updating unit 102 is further configured to: when the determination result of the third determining unit is negative, increase the preset frequency correspondingly, and update the accumulated value of the current counting application source according to the increased preset frequency. Go to the database.
  • the updating unit 705 is further configured to update the count generated by the current counting application source running in the server to the database in real time.
  • FIG. 11 is a schematic block diagram of a counter according to another embodiment of the present application.
  • the counter 110 includes a detecting unit 111, an obtaining unit 112, a determining unit 113, a counting unit 114, an updating unit 115, a comparing unit 116, and a stopping unit 117.
  • the detection unit 111, the obtaining unit 112, and the determining unit 113 refer to the content described by the foregoing detecting unit 701, the obtaining unit 702, and the determining unit 703.
  • the counting unit 114 is configured to accumulate the counts generated by the current counting application source running in the server to obtain an accumulated value.
  • the updating unit 115 is configured to update the accumulated value of the current counting application source to the database according to the preset frequency.
  • the obtaining unit 112 is further configured to: after updating the accumulated value of the current counting application source to the database, obtain the total amount of the current counting application source in the database, and save the current total amount.
  • the comparing unit 116 is configured to compare, when the mode of the application source update database is the high performance mode, the sum of the current total amount of the current counting application source and the current accumulated value, and the threshold set by the current counting application source.
  • the comparing unit 116 is further configured to: when the mode of the application source update database is the real-time energy mode, compare the current total amount of the current count application source in the database with the threshold set by the current counting application source.
  • the stopping unit 117 is configured to: if the mode of the application source update database is the high performance mode, if the current counting application source exceeds the preset threshold according to the sum of the current total amount and the current accumulated value, stop counting the current counting application source and Issue an early warning.
  • the stopping unit 117 is further configured to stop counting the current counting application source and issue an early warning if the current counting application source exceeds the preset threshold according to the current total amount when the mode of the application source update database is counted.
  • the counter described above can be implemented in the form of a computer program data that can be run on a counter as shown in FIG.
  • FIG. 12 is a schematic block diagram of a counter according to another embodiment of the present application.
  • the counter 120 includes a memory 121 and a processor 122.
  • the memory 121 and the processor 122 are connected by a bus 123. among them:
  • the memory 121 is for storing data with various functions.
  • the data stored in the memory 121 in the embodiment of the present application includes a preset frequency, a first preset usage rate, a second preset usage rate, a maximum network connection number of the server, a preset number, a CPU usage rate, a memory usage rate, and a current network.
  • the memory 121 of the embodiment of the present application may be a system memory, such as a non-volatile (such as a ROM, a flash memory, etc.).
  • the memory 121 in the embodiment of the present application may also be an external memory outside the system, such as a magnetic disk, an optical disk, a magnetic tape, or the like.
  • the memory 121 provides an environment for the execution of program data that, when executed by the processor 122, causes the processor 122 to perform the above counting method.
  • the processor 122 is configured to execute program data stored in the memory 121 to perform implementations of all embodiments of the above counting method.
  • the application further provides a computer readable storage medium storing one or more program data, the one or more program data being executable by one or more processors, when All embodiments of the above counting method can be implemented when one or more program data is executed by one or more processors.
  • the computer readable storage medium can be an internal storage unit of the device, such as a hard disk or memory of the device.
  • the computer readable storage medium may also be an external storage device of the device, such as a plug-in hard disk equipped with the device, a smart memory card (SMC), a Secure Digital (SD) card, or the like. Further, the computer readable storage medium may also include both an internal storage unit of the device and an external storage device.

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Environmental & Geological Engineering (AREA)
  • Computer Security & Cryptography (AREA)
  • Debugging And Monitoring (AREA)
  • Computer And Data Communications (AREA)

Abstract

一种计数方法、计数器及存储介质,所述方法包括:检测是否存在计数申请源(101);若存在计数申请源,获取当前计数申请源单位时间内计数的数量及服务器相关参数(102);根据所述计数的数量或所述服务器相关参数判断当前计数申请源更新数据库的模式,所述模式包括实时模式和高性能模式(103);若当前计数申请源更新数据库的模式为高性能模式,将当前计数申请源在服务器内运行产生的计数进行累加而得出累加值(104);根据预设的频率将当前计数申请源的累加值更新到数据库(105)。

Description

计数方法、计数器及存储介质
本申请要求于2017年4月10日提交中国专利局、申请号为201710229564.6、发明名称为“一种计数方法及计数器”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及数据处理技术领域,尤其涉及一种计数方法、计数器及存储介质。
背景技术
当其他多个平台调用某个预设平台(服务器)时,其他多个平台(多个计数申请源)在该预设平台上运行产生计数。目前普遍采用的是数据库计数或第三方系统计数方案。数据库计数会产生频繁的更新操作,对数据库产生很大压力;第三方系统计数需要依赖Redis、mongoDB或Zookeeper等第三方系统,增加了开发和运营成本。
发明内容
本申请实施例提供了一种计数方法、计数器及存储介质,可以动态调整计数申请源更新数据库的模式,在保证计数准确性的同时,减少与数据库的交互频率,降低了数据库的压力。
第一方面,本申请提供了一种计数方法,该方法包括:
检测是否存在计数申请源;
若存在计数申请源,获取当前计数申请源单位时间内计数的数量及服务器相关参数,所述服务器相关参数包括CPU使用率、内存使用率及当前网络连接数中的至少一种;
根据所述计数的数量或所述服务器相关参数判断当前计数申请源更新数据库的模式,所述模式包括实时模式和高性能模式;
若当前计数申请源更新数据库的模式为高性能模式,将当前计数申请源在 服务器内运行产生的计数进行累加而得出累加值;
根据预设的频率将当前计数申请源的累加值更新到数据库。
第二方面,本申请还提供了一种计数器,该计数器包括:
检测单元,用于检测是否存在计数申请源;
获取单元,用于若存在计数申请源,获取当前计数申请源单位时间内计数的数量及服务器相关参数,所述服务器相关参数包括CPU使用率、内存使用率及当前网络连接数中的至少一种;
判断单元,用于根据所述计数的数量或所述服务器相关参数判断当前计数申请源更新数据库的模式,所述模式包括实时模式和高性能模式;
计数单元,用于若当前计数申请源更新数据库的模式为高性能模式,将当前计数申请源在服务器内运行产生的计数进行累加而得出累加值;
更新单元,用于根据预设的频率将当前计数申请源的累加值更新到数据库。
第三方面,本申请还提供了另一种计数器,该计数器包括存储器,以及与所述存储器相连的处理器;所述存储器用于存储程序数据;所述处理器用于运行所述存储器中存储的程序数据,以执行上述第一方面所述的一种计数方法。
第四方面,本申请实施例还提供了一种计算机可读存储介质,该计算机可读存储介质存储有一个或者一个以上程序数据,所述一个或者一个以上程序数据可被一个或者一个以上的处理器执行,以实现上述第一方面所述的一种计数方法。
本申请实施例可以动态调整计数申请源更新数据库的模式,在保证计数准确性的同时,减少与数据库的交互频率,降低了数据库的压力。另一方面,在计数申请源更新数据库的模式为高性能模式的情况下,根据预设的频率更新数据库,在数据库性能与计数准确性之间达到平衡。
附图说明
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例提供的一种计数方法的示意流程图;
图2是本申请实施例提供的一种计数方法的一个子流程示意图;
图3是本申请实施例提供的一种计数方法的另一个子流程示意图;
图4是本申请实施例提供的一种计数方法的另一个子流程示意图;
图5是本申请实施例提供的一种计数方法的另一个子流程示意图;
图6是本申请另一实施例提供的一种计数方法的流程示意图;
图7是本申请实施例提供的一种计数器的示意性框图;
图8是本申请实施例提供的判断单元的示意性框图;
图9是本申请实施例提供的另一个判断单元的示意性框图;
图10是本申请实施例提供的更新单元的示意性框图;
图11是本申请另一实施例提供的一种计数器的示意性框图;
图12是本申请又一实施例提供的一种计数器的示意性框图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
应当理解,当在本说明书和所附权利要求书中使用时,术语“包括”和“包含”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。还应当理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。
图1为本申请实施例提供的一种计数方法的流程示意图。该方法包括S101~S106。
S101,检测是否存在计数申请源。具体地,可以通过连接请求来检测是否存在计数申请源。如检测连接请求中的IP地址是否与预存的计数申请源的IP地址匹配,若匹配,即存在计数申请源。其中,计数申请源的连接请求是发送到服务器上的。计数申请源至少有一个。可以理解地,能检测到一个或者多个计数申请源。
S102,若存在计数申请源,获取当前计数申请源单位时间内计数的数量及服务器相关参数。其中,服务器相关参数包括CPU使用率、内存使用率及当前 网络连接数中的至少一种。单位时间并非仅指单位时间,也可以是一段时间,如1小时等。
S103,根据单位时间内计数的数量或服务器相关参数判断当前计数申请源更新数据库的模式,所述模式包括实时模式和高性能模式。其中,高性能模式为非实时模式,即除去实时模式之外的模式。若为高性能模式,执行S104,若为实时模式,执行S106。
优选地,根据当前计数申请源单位时间内计数的数量判断当前计数申请源更新数据库的模式,具体地,S103包括S201-S203。如图2所示,S201,判断单位时间内计数的数量是否超过预设数量。S202,若单位时间内计数的数量超过预设数量,确定当前计数申请源更新数据库的模式为高性能模式。S203,若单位时间内计数的数量小于或者等于预设数量,确定当前计数申请源更新数据库的模式为实时模式。可以理解地,若单位时间内计数的数量比较少,那么实时的更新数据库;若单位时间内计数的数量比较多,采用高性能模式更新数据库。可以动态地调整当前计数申请源更新数据库的模式,在保证计数准确性的同时,减少服务器与数据库的交互频率,降低了服务器和数据库的压力。
在其他实施例中,还可以根据服务器相关参数判断当前计数申请源更新数据库的模式,具体地,S103包括S301-S303。如图3所示,S301,判断CPU使用率是否大于第一预设使用率,或者内存使用率是否大于第二预设使用率,或者当前网络连接数是否等于服务器最大网络连接数。若是,执行S302,否则,执行S303。S302,确定当前计数申请源更新数据库的模式为高性能模式。S303,确定当前计数申请源更新数据库的模式为实时模式。其中,优选地,第一预设使用率30%,第二预设使用率为90%。可以理解地,当CPU使用率大于30%,或者内存使用率大于90%,或者当前网络连接数等于服务器最大网络连接数,那么可以理解为服务器目前已经有大量的工作需要处理,若更新数据库的模式为实施模式的话,服务器将会有更多的工作需要处理,将会占用更多的CPU或者内存,将会增加服务器的压力,也会增加数据库的压力,因此当CPU使用率大于第一预设使用率,或者内存使用率大于第二预设使用率,或者当前网络连接数等于服务器最大网络连接数,当前计数申请源采用高性能模式更新数据库,否则,采用实时模式更新数据库。图3所述的技术方案可以动态地调整当前计 数申请源更新数据库的模式,在保证计数准确性的同时,减少服务器与数据库的交互频率,降低了服务器和数据库的压力,提高了服务器的性能。
S104,将当前计数申请源在服务器内运行产生的计数进行累加而得出累加值。具体地,可以在一段时间内将当前计数申请源在服务器内运行产生的计数进行累加而得出累加值,在该种情况下,累加值会清零;也可以是将当前计数申请源在服务器内运行产生的计数一直累加而得到累加值。
S105,根据预设的频率将当前计数申请源的累加值更新到数据库。其中,若累加值是指在一段时间内(预设的频率所对应的时间)运行产生的计数而累加得到的,那么将当前计数申请源的累加值以增量累加到数据库,累加到数据库后,将该累加值清零。若累加值是运行产生的计数一直累加而得到的,那么根据预设的频率将当前计数申请源的累加值中的增量更新到数据库。预设的频率跟当前计数申请源单位时间内计数的数量或者服务器相关参数有关,其中,优选地,预设的频率初始值为1分钟。S105执行完毕后,结束。
具体地,如图4所示,S105包括S401-S403。S401,判断当前计数申请源在单位时间内计数的数量是否减少。若减少,则执行S402,否则,执行S403。S402,相应降低所述预设的频率,并根据降低后的预设的频率将当前计数申请源的累加值更新到数据库。S403,相应增加所述预设的频率,并根据增加后的预设的频率将当前计数申请源的累加值更新到数据库。可以理解地,在高性能模式下,若当前计数申请源在单位时间内计数的数量减少,那么相应降低预设的频率,即可以经过比较长的时间将当前计数申请源的累加值更新到数据库;若当前计数申请源在单位时间内计数的数量增加,那么相应增加预设的频率,需要及时地把累加值更新到数据库。该技术方案在高性能模式下,动态的调整当前计数申请源更新数据库的频率,以实现在数据库性能与计数准确性之间达到平衡。
在其他实施例中,具体地,如图5所示,S105包括S501-S503。S501,判断CPU使用率或者内存使用率或者当前网络连接数是否增加。若增加,执行S502,否则,执行S503。S502,相应降低所述预设的频率,并根据降低后的预设的频率将当前计数申请源的累加值更新到数据库。S503,相应增加所述预设的频率,并根据增加后的预设的频率将当前计数申请源的累加值更新到数据库。 可以理解地,若CPU使用率或者内存使用率或者当前网络连接数增加,那么服务器的工作量增加,此时若相应增加预设的频率,那么会加大服务器的工作量,增加服务器的压力,因此需要相应降低预设的频率,即相应降低当前计数申请源更新数据库的频率。否则,需要相应增加预设的频率。该技术方案在高性能模式下,动态地调整当前计数申请源更新数据库的频率,即动态调整服务器与数据库的交互频率,提高了服务器和数据库的性能,同时可以在数据库性能与计数准确性之间达到平衡。
S106,实时将当前计数申请源在服务器内运行产生的计数更新到数据库。
图6为本申请另一实施例提供的一种计数方法的流程示意图。该方法包括S601~S611。
S601,检测是否存在计数申请源。具体地,可以通过连接请求来检测是否存在计数申请源。如检测连接请求中的IP地址是否与预存的计数申请源的IP地址匹配,若匹配,即存在计数申请源。其中,计数申请源的连接请求是发送到服务器上的。计数申请源至少有一个。可以理解地,能检测到一个或者多个计数申请源。
S602,若存在计数申请源,获取当前计数申请源单位时间内计数的数量及服务器相关参数。其中,服务器相关参数包括CPU使用率、内存使用率及当前网络连接数中的至少一种。单位时间并非仅指单位时间,也可以是一段时间,如1小时等。
S603,根据单位时间内计数的数量或服务器相关参数判断当前计数申请源更新数据库的模式,所述模式包括实时模式和高性能模式。其中,高性能模式为非实时模式,即除去实时模式之外的模式。若为高性能模式,执行S604,若为实时模式,执行S609。其中,根据单位时间内计数的数量判断当前计数申请源更新数据库的模式,请参看图2的内容。根据服务器相关参数判断当前计数申请源更新数据库的模式,请参看图3的内容。
S604,将当前计数申请源在服务器内运行产生的计数进行累加而得出累加值。具体地,在一段时间内将当前计数申请源在服务器内运行产生的计数进行累加而得出累加值,在该种情况下,累加值会清零。
S605,根据预设的频率将当前计数申请源的累加值更新到数据库。其中, 累加值是指在一段时间内(预设的频率所对应的时间)运行产生的计数而累加得到的,那么将当前计数申请源的累加值以增量累加到数据库,累加到数据库后,将该累加值清零。预设的频率跟当前计数申请源单位时间内计数的数量或者服务器相关参数有关,其中,优选地,预设的频率初始值为1分钟。具体地,S605请参看图4描述的内容。在其他实施例中,S605请参看图5描述的内容。
S606,将当前计数申请源的累加值更新到数据库后,获取数据库中当前计数申请源的总量,并保存为当前总量。
S607,将当前计数申请源的当前总量与当前累加值的和,与当前计数申请源设定的阈值进行比较。其中,每个计数申请源都设定一个阈值,可以理解地,其他平台调用服务器的次数是有限制的,不能无限次的调用。可以应用在计费场景中,如当前计数申请源给了100块钱,那么允许当前计数申请源调用服务器的次数为100,如果超过了100次,那么将不允许调用服务器,除非另外再交钱。
S608,若超过设定的阈值,停止对当前计数申请源计数并发出预警。如当前计数申请源的计数的数量已经达到预定的阈值,那么服务器将会停止对当前计数申请源的计数,并发出预警,以提醒当前计数申请源注意。
S609,实时将当前计数申请源在服务器内运行产生的计数更新到数据库。若当前计数申请源采用实时模式更新数据库,那么将实时的将该当前计数申请源在服务器内运行产生的计数更新到数据库。
S610,将获取的当前计数申请源在数据库中的当前总量与当前计数申请源设定的阈值进行比较。若当前计数申请源采用实时模式更新数据库,也对当前计数申请源设定一个阈值,表示当前计数申请源调用服务器的次数是有限制的。
S611,若超过设定的阈值,停止对当前计数申请源计数并发出预警。以提醒当前计数申请源注意。
该方法实施例对计数申请源的当前计数总量与当前计数申请源设定的阈值进行比较,若超过设定的阈值,停止对当前计数申请源计数并发出预警。通过停止对当前计数申请源计数并发出预警的方式,以提醒当前计数申请源的注意。
图7为本申请实施例提供的一种计数器的示意性框图。该计数器70包括检测单元701、获取单元702、判断单元703、计数单元704、更新单元705。
检测单元701,用于检测是否存在计数申请源。
获取单元702,用于若存在计数申请源,获取当前计数申请源单位时间内计数的数量及服务器相关参数。
判断单元703,用于根据当前计数申请源单位时间内计数的数量或服务器相关参数判断当前计数申请源更新数据库的模式,所述模式包括实时模式和高性能模式。
优选地,所述判断单元用于根据当前计数申请源单位时间内计数的数量判断当前计数申请源更新数据库的模式,如图8所示,判断单元703包括第一判断单元801、第一确定单元802。第一判断单元801,用于判断单位时间内计数的数量是否超过预设数量。第一确定单元802,用于若单位时间内计数的数量超过预设数量,确定当前计数申请源更新数据库的模式为高性能模式。第一确定单元802,还用于若单位时间内计数的数量小于或者等于预设数量,确定当前计数申请源更新数据库的模式为实时模式。
在其他实施例中,所述判断单元用于根据服务器相关参数判断当前计数申请源更新数据库的模式,如图9所示,判断单元703包括第二判断单元901、第二确定单元902。第二判断单元901,用于判断CPU使用率是否大于第一预设使用率,或者内存使用率是否大于第二预设使用率,或者当前网络连接数是否等于服务器最大网络连接数。第二确定单元902,用于若CPU使用率大于第一预设使用率,或者内存使用率大于第二预设使用率,或者当前网络连接数等于服务器最大网络连接数,确定当前计数申请源更新数据库的模式为高性能模式。第二确定单元902,还用于在第二判断单元901的判断结果为否的情况下,确定确定当前计数申请源更新数据库的模式为实时模式。
计数单元704,用于若当前计数申请源更新数据库的模式为高性能模式,将当前计数申请源在服务器内运行产生的计数进行累加而得出累加值。
更新单元705,用于根据预设的频率将当前计数申请源的累加值更新到数据库。
具体地,如图10所示,更新单元705包括第三判断单元101、修改更新单元102。第三判断单元101,用于判断当前计数申请源在单位时间内计数的数量是否减少。修改更新单元102,用于若当前计数申请源在单位时间内计数的数 量减少,相应降低所述预设的频率,并根据降低后的预设的频率将当前计数申请源的累加值更新到数据库。修改更新单元102,还用于若当前计数申请源在单位时间内计数的数量增加,相应增加所述预设的频率,并根据增加后的预设的频率将当前计数申请源的累加值更新到数据库。
第三判断单元101,还用于判断CPU使用率或者内存使用率或者当前网络连接数是否增加。修改更新单元102,还用于CPU使用率或者内存使用率或者当前网络连接数增加,相应降低所述预设的频率,并根据降低后的预设的频率将当前计数申请源的累加值更新到数据库。修改更新单元102,还用于在第三判断单元’的判断结果为否的情况下,相应增加所述预设的频率,并根据增加后的预设的频率将当前计数申请源的累加值更新到数据库。
更新单元705,还用于实时将当前计数申请源在服务器内运行产生的计数更新到数据库。
图11为本申请另一实施例提供的一种计数器的示意性框图。该计数器110包括检测单元111、获取单元112、判断单元113、计数单元114、更新单元115、比较单元116、停止单元117。其中,检测单元111、获取单元112、判断单元113请参看前述实施例检测单元701、获取单元702、判断单元703描述的内容。
计数单元114,用于将当前计数申请源在服务器内运行产生的计数进行累加而得出累加值。
更新单元115,用于根据预设的频率将当前计数申请源的累加值更新到数据库。
获取单元112,还用于将当前计数申请源的累加值更新到数据库后,获取数据库中当前计数申请源的总量,并保存为当前总量。
比较单元116,用于若计数申请源更新数据库的模式为高性能模式时,将当前计数申请源的当前总量与当前累加值的和,与当前计数申请源设定的阈值进行比较。比较单元116,还用于若计数申请源更新数据库的模式为实时能模式时,根据获取的当前计数申请源在数据库中的当前总量与当前计数申请源设定的阈值进行比较。
停止单元117,用于若计数申请源更新数据库的模式为高性能模式时,若当前计数申请源根据当前总量与当前累加值的和,超过预设的阈值,停止对当 前计数申请源计数并发出预警。停止单元117,还用于若计数申请源更新数据库的模式为实时模式时,若当前计数申请源根据当前总量超过预设的阈值,停止对当前计数申请源计数并发出预警。
上述描述的计数器和单元的具体工作过程,可以参考前述方法实施例中的对应过程,达到的有益效果也可以参考前述方法实施例中中对应达到的有益效果,在此不再赘述。
上述描述的计数器可以实现为一种计算机程序数据的形式,该程序数据可以在如图12所示的计数器上运行。
图12为本申请又一实施例提供的一种计数器的示意性框图。该计数器120包括存储器121以及处理器122,上述存储器121以及处理器122通过总线123连接。其中:
存储器121,用于存储带有各种功能的数据。本申请实施例中存储器121存储的数据包括预设的频率、第一预设使用率、第二预设使用率、服务器最大网络连接数、预设数量、CPU使用率、内存使用率、当前网络连接数及单位时间内计数的数量等,以及其他可调用并运行的程序数据。具体实现中,本申请实施例的存储器121可以是系统存储器,比如,非易失性的(诸如ROM,闪存等)。具体实现中,本申请实施例的存储器121还可以是系统之外的外部存储器,比如,磁盘、光盘、磁带等。该存储器121为程序数据的运行提供环境,该程序数据被处理器122执行时,可使得处理器122执行上述计数方法。
处理器122,用于运行存储器121中存储的程序数据,执行上述计数方法的所有实施例的实现方式。
本申请还提供一种计算机可读存储介质,所述计算机可读存储介质存储有一个或者一个以上程序数据,所述一个或者一个以上程序数据可被一个或者一个以上的处理器执行,当所述一个或者一个以上程序数据被一个或者一个以上的处理器执行时,可实现上述计数方法的所有实施例。
所述计算机可读存储介质可以是设备的内部存储单元,例如设备的硬盘或内存。所述计算机可读存储介质也可以是设备的外部存储设备,例如所述设备上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡等。进一步地,所述计算机可读存储介质还可以既包括所述设备 的内部存储单元也包括外部存储设备。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。在本申请所提供的几个实施例中,应该理解到,所揭露的计数器和方法,可以通过其它的方式实现。例如,以上所描述的计数器实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。

Claims (20)

  1. 一种计数方法,其特征在于,所述方法包括:
    检测是否存在计数申请源;
    若存在计数申请源,获取当前计数申请源单位时间内计数的数量及服务器相关参数,所述服务器相关参数包括CPU使用率、内存使用率及当前网络连接数中的至少一种;
    根据所述计数的数量或所述服务器相关参数判断当前计数申请源更新数据库的模式,所述模式包括实时模式和高性能模式;
    若当前计数申请源更新数据库的模式为高性能模式,将当前计数申请源在服务器内运行产生的计数进行累加而得出累加值;
    根据预设的频率将当前计数申请源的累加值更新到数据库。
  2. 如权利要求1所述的方法,其特征在于,所述方法还包括:
    将当前计数申请源的累加值更新到数据库后,获取数据库中当前计数申请源的总量,并保存为当前总量;
    将当前计数申请源的当前总量与当前累加值的和与所述当前计数申请源设定的阈值进行比较;
    若超过设定的阈值,停止对当前计数申请源计数。
  3. 如权利要求1所述的方法,其特征在于,所述根据所述计数的数量判断当前计数申请源更新数据库的模式,包括:
    判断所述计数的数量是否超过预设数量;
    若超过预设数量,确定当前计数申请源更新数据库的模式为高性能模式;
    若所述计数的数量小于或者等于预设数量,确定当前计数申请源更新数据库的模式为实时模式。
  4. 如权利要求1所述的方法,其特征在于,根据所述服务器相关参数判断当前计数申请源更新数据库的模式,包括:
    判断CPU使用率是否大于第一预设使用率,或者内存使用率是否大于第二预设使用率,或者当前网络连接数是否等于服务器最大网络连接数;
    若是,则确定当前计数申请源更新数据库的模式为高性能模式;
    否则,确定当前计数申请源更新数据库的模式为实时模式。
  5. 如权利要求1所述的方法,其特征在于,根据预设的频率将当前计数申请源的累加值更新到数据库,包括:
    判断当前计数申请源在单位时间内计数的数量是否减少;
    若是,相应降低所述预设的频率,并根据降低后的频率将当前计数申请源的累加值更新到数据库;
    否则,相应增加所述预设的频率,并根据增加后的频率将当前计数申请源的累加值更新到数据库;或者
    判断CPU使用率或者内存使用率或者当前网络连接数是否增加;
    若是,相应降低所述预设的频率,并根据降低后的频率将当前计数申请源的累加值更新到数据库;
    否则,相应增加所述预设的频率,并根据增加后的频率将当前计数申请源的累加值更新到数据库。
  6. 一种计数器,其特征在于,所述计数器包括:
    检测单元,用于检测是否存在计数申请源;
    获取单元,用于若存在计数申请源,获取当前计数申请源单位时间内计数的数量及服务器相关参数,所述服务器相关参数包括CPU使用率、内存使用率及当前网络连接数中的至少一种;
    判断单元,用于根据所述计数的数量或所述服务器相关参数判断当前计数申请源更新数据库的模式,所述模式包括实时模式和高性能模式;
    计数单元,用于若当前计数申请源更新数据库的模式为高性能模式,将当前计数申请源在服务器内运行产生的计数进行累加而得出累加值;
    更新单元,用于根据预设的频率将当前计数申请源的累加值更新到数据库。
  7. 如权利要求6所述的计数器,其特征在于,所述计数器还包括比较单元、停止单元;其中,
    所述获取单元,还用于将当前计数申请源的累加值更新到数据库后,获取数据库中当前计数申请源的总量,并保存为当前总量;
    所述比较单元,用于将当前计数申请源的当前总量与当前累加值的和与所述当前计数申请源设定的阈值进行比较;
    所述停止单元,用于若超过设定的阈值,停止对当前计数申请源计数。
  8. 如权利要求6所述的计数器,其特征在于,所述判断单元包括第一判断单元、第一确定单元;其中,
    所述第一判断单元,用于判断所述计数的数量是否超过预设数量;
    所述第一确定单元,用于若所述计数的数量超过预设数量,确定当前计数申请源更新数据库的模式为高性能模式;
    所述第一确定单元,还用于若所述计数的数量小于或者等于预设数量,确 定当前计数申请源更新数据库的模式为实时模式。
  9. 如权利要求6所述的计数器,其特征在于,所述判断单元包括第二判断单元、第二确定单元;其中,
    所述第二判断单元,用于判断CPU使用率是否大于第一预设使用率,或者内存使用率是否大于第二预设使用率,或者当前网络连接数是否等于服务器最大网络连接数;
    所述第二确定单元,用于若CPU使用率大于第一预设使用率,或者内存使用率大于第二预设使用率,或者当前网络连接数等于服务器最大网络连接数,则确定当前计数申请源更新数据库的模式为高性能模式;
    所述第二确定单元,还用于在所述第二判断单元的判断结果为否的情况下,确定当前计数申请源更新数据库的模式为实时模式。
  10. 如权利要求6所述的计数器,其特征在于,所述更新单元包括第三判断单元、修改更新单元;其中,
    所述第三判断单元,用于判断当前计数申请源在单位时间内计数的数量是否减少;
    所述修改更新单元,用于若当前计数申请源在单位时间内计数的数量减少,相应降低所述预设的频率,并根据降低后的预设的频率将当前计数申请源的累加值更新到数据库;
    所述修改更新单元,还用于若当前计数申请源在单位时间内计数的数量增加,相应增加所述预设的频率,并根据增加后的预设的频率将当前计数申请源的累加值更新到数据库;或者
    所述第三判断单元,用于判断CPU使用率或者内存使用率或者当前网络连接数是否增加;
    所述修改更新单元,用于若CPU使用率或者内存使用率或者当前网络连接数增加,相应降低所述预设的频率,并根据降低后的预设的频率将当前计数申请源的累加值更新到数据库;
    所述修改更新单元,还用于在所述第三判断单元的判断结果为否的情况下,相应增加所述预设的频率,并根据增加后的预设的频率将当前计数申请源的累加值更新到数据库。
  11. 一种计数器,其特征在于,所述计数器包括存储器,以及与所述存储器相连的处理器;所述存储器用于存储程序数据;所述处理器用于运行所述存储器中存储的程序数据,以执行如下步骤:
    检测是否存在计数申请源;
    若存在计数申请源,获取当前计数申请源单位时间内计数的数量及服务器相关参数,所述服务器相关参数包括CPU使用率、内存使用率及当前网络连接数中的至少一种;
    根据所述计数的数量或所述服务器相关参数判断当前计数申请源更新数据库的模式,所述模式包括实时模式和高性能模式;
    若当前计数申请源更新数据库的模式为高性能模式,将当前计数申请源在服务器内运行产生的计数进行累加而得出累加值;
    根据预设的频率将当前计数申请源的累加值更新到数据库。
  12. 如权利要求11所述的计数器,其特征在于,所述处理器还执行如下步骤:
    将当前计数申请源的累加值更新到数据库后,获取数据库中当前计数申请源的总量,并保存为当前总量;
    将当前计数申请源的当前总量与当前累加值的和与所述当前计数申请源设定的阈值进行比较;
    若超过设定的阈值,停止对当前计数申请源计数。
  13. 如权利要求11所述的计数器,其特征在于,所述处理器在执行所述根据所述计数的数量判断当前计数申请源更新数据库的模式时,具体执行如下步骤:
    判断所述计数的数量是否超过预设数量;
    若超过预设数量,确定当前计数申请源更新数据库的模式为高性能模式;
    若所述计数的数量小于或者等于预设数量,确定当前计数申请源更新数据库的模式为实时模式。
  14. 如权利要求11所述的计数器,其特征在于,所述处理器在执行所述根据所述服务器相关参数判断当前计数申请源更新数据库的模式时,具体执行如下步骤:
    判断CPU使用率是否大于第一预设使用率,或者内存使用率是否大于第二预设使用率,或者当前网络连接数是否等于服务器最大网络连接数;
    若是,则确定当前计数申请源更新数据库的模式为高性能模式;
    否则,确定当前计数申请源更新数据库的模式为实时模式。
  15. 如权利要求11所述的计数器,其特征在于,所述处理器在执行所述根 据预设的频率将当前计数申请源的累加值更新到数据库时,具体执行如下步骤:
    判断当前计数申请源在单位时间内计数的数量是否减少;
    若是,相应降低所述预设的频率,并根据降低后的频率将当前计数申请源的累加值更新到数据库;
    否则,相应增加所述预设的频率,并根据增加后的频率将当前计数申请源的累加值更新到数据库;或者
    判断CPU使用率或者内存使用率或者当前网络连接数是否增加;
    若是,相应降低所述预设的频率,并根据降低后的频率将当前计数申请源的累加值更新到数据库;
    否则,相应增加所述预设的频率,并根据增加后的频率将当前计数申请源的累加值更新到数据库。
  16. 一种计算机可读存储介质,其特征在于,计算机可读存储介质存储有一个或者一个以上程序数据,所述一个或者一个以上程序数据可被一个或者一个以上的处理器执行,以实现以下步骤:
    检测是否存在计数申请源;
    若存在计数申请源,获取当前计数申请源单位时间内计数的数量及服务器相关参数,所述服务器相关参数包括CPU使用率、内存使用率及当前网络连接数中的至少一种;
    根据所述计数的数量或所述服务器相关参数判断当前计数申请源更新数据库的模式,所述模式包括实时模式和高性能模式;
    若当前计数申请源更新数据库的模式为高性能模式,将当前计数申请源在服务器内运行产生的计数进行累加而得出累加值;
    根据预设的频率将当前计数申请源的累加值更新到数据库。
  17. 如权利要求16所述的计算机可读存储介质,其特征在于,所述步骤还包括:
    将当前计数申请源的累加值更新到数据库后,获取数据库中当前计数申请源的总量,并保存为当前总量;
    将当前计数申请源的当前总量与当前累加值的和与所述当前计数申请源设定的阈值进行比较;
    若超过设定的阈值,停止对当前计数申请源计数。
  18. 如权利要求16所述的计算机可读存储介质,其特征在于,所述处理器 在执行所述根据所述计数的数量判断当前计数申请源更新数据库的模式时,具体实现如下步骤:
    判断所述计数的数量是否超过预设数量;
    若超过预设数量,确定当前计数申请源更新数据库的模式为高性能模式;
    若所述计数的数量小于或者等于预设数量,确定当前计数申请源更新数据库的模式为实时模式。
  19. 如权利要求16所述的计算机可读存储介质,其特征在于,所述处理器在执行所述根据所述服务器相关参数判断当前计数申请源更新数据库的模式时,具体实现如下步骤:
    判断CPU使用率是否大于第一预设使用率,或者内存使用率是否大于第二预设使用率,或者当前网络连接数是否等于服务器最大网络连接数;
    若是,则确定当前计数申请源更新数据库的模式为高性能模式;
    否则,确定当前计数申请源更新数据库的模式为实时模式。
  20. 如权利要求16所述的计算机可读存储介质,其特征在于,所述处理器在执行所述根据预设的频率将当前计数申请源的累加值更新到数据库时,具体实现如下步骤:
    判断当前计数申请源在单位时间内计数的数量是否减少;
    若是,相应降低所述预设的频率,并根据降低后的频率将当前计数申请源的累加值更新到数据库;
    否则,相应增加所述预设的频率,并根据增加后的频率将当前计数申请源的累加值更新到数据库;或者
    判断CPU使用率或者内存使用率或者当前网络连接数是否增加;
    若是,相应降低所述预设的频率,并根据降低后的频率将当前计数申请源的累加值更新到数据库;
    否则,相应增加所述预设的频率,并根据增加后的频率将当前计数申请源的累加值更新到数据库。
PCT/CN2018/082233 2017-04-10 2018-04-09 计数方法、计数器及存储介质 Ceased WO2018188542A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
US16/495,839 US11455293B2 (en) 2017-04-10 2018-04-09 Counting method, counter and storage medium
SG11201908133V SG11201908133VA (en) 2017-04-10 2018-04-09 Counting method, counter, and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710229564.6 2017-04-10
CN201710229564.6A CN107798036A (zh) 2017-04-10 2017-04-10 一种计数方法及计数器

Publications (1)

Publication Number Publication Date
WO2018188542A1 true WO2018188542A1 (zh) 2018-10-18

Family

ID=61531055

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/082233 Ceased WO2018188542A1 (zh) 2017-04-10 2018-04-09 计数方法、计数器及存储介质

Country Status (4)

Country Link
US (1) US11455293B2 (zh)
CN (1) CN107798036A (zh)
SG (1) SG11201908133VA (zh)
WO (1) WO2018188542A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107798036A (zh) * 2017-04-10 2018-03-13 平安科技(深圳)有限公司 一种计数方法及计数器
CN109445955B (zh) * 2018-09-13 2020-09-04 武汉斗鱼网络科技有限公司 一种计数方法及计数系统
CN111858587A (zh) * 2020-07-10 2020-10-30 北京青云科技股份有限公司 一种数据库数据的计数方法、装置、设备及存储介质
CN116450672B (zh) * 2022-01-05 2026-02-03 腾讯科技(深圳)有限公司 计数方法、用户基数统计方法、相应的装置和电子设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9215151B1 (en) * 2011-12-14 2015-12-15 Google Inc. Dynamic sampling rate adjustment for rate-limited statistical data collection
CN105471614A (zh) * 2014-09-11 2016-04-06 腾讯科技(深圳)有限公司 过载保护方法、装置及服务器
CN105630712A (zh) * 2014-10-28 2016-06-01 深圳市中兴微电子技术有限公司 计数器及计数方法
CN106130972A (zh) * 2016-06-22 2016-11-16 腾讯科技(深圳)有限公司 资源访问控制方法和装置
CN107798036A (zh) * 2017-04-10 2018-03-13 平安科技(深圳)有限公司 一种计数方法及计数器

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7804426B2 (en) * 2006-05-08 2010-09-28 Drivecam, Inc. System and method for selective review of event data
CN102063449A (zh) * 2009-11-12 2011-05-18 中国移动通信集团浙江有限公司 提高数据库中数据对象统计信息可靠性的方法及装置
CN105024933B (zh) * 2014-04-22 2019-01-29 腾讯科技(深圳)有限公司 请求包发送频率的控制方法及装置
US10186162B2 (en) * 2015-02-06 2019-01-22 ActivEd, Inc. Dynamic educational system incorporating physical movement with educational content
CN105095423B (zh) * 2015-07-15 2018-10-09 北京奇虎科技有限公司 计数数据写入方法和装置
CN105354258B (zh) * 2015-10-22 2019-11-15 努比亚技术有限公司 一种更新网站数据缓存的装置及方法
US9929970B1 (en) * 2015-12-03 2018-03-27 Innovium, Inc. Efficient resource tracking
CN106959889A (zh) * 2016-01-11 2017-07-18 阿里巴巴集团控股有限公司 一种服务器资源调整的方法和装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9215151B1 (en) * 2011-12-14 2015-12-15 Google Inc. Dynamic sampling rate adjustment for rate-limited statistical data collection
CN105471614A (zh) * 2014-09-11 2016-04-06 腾讯科技(深圳)有限公司 过载保护方法、装置及服务器
CN105630712A (zh) * 2014-10-28 2016-06-01 深圳市中兴微电子技术有限公司 计数器及计数方法
CN106130972A (zh) * 2016-06-22 2016-11-16 腾讯科技(深圳)有限公司 资源访问控制方法和装置
CN107798036A (zh) * 2017-04-10 2018-03-13 平安科技(深圳)有限公司 一种计数方法及计数器

Also Published As

Publication number Publication date
CN107798036A (zh) 2018-03-13
US11455293B2 (en) 2022-09-27
SG11201908133VA (en) 2019-10-30
US20200133936A1 (en) 2020-04-30

Similar Documents

Publication Publication Date Title
CN110611623B (zh) 限流方法和装置
CN109525500B (zh) 一种自调整阈值的信息处理方法及信息处理装置
WO2018188542A1 (zh) 计数方法、计数器及存储介质
US9372627B2 (en) Dynamic feedback-based throughput control for black-box storage systems
US9514039B2 (en) Determining a metric considering unallocated virtual storage space and remaining physical storage space to use to determine whether to generate a low space alert
WO2018014811A1 (zh) 风险识别方法、客户端设备及风险识别系统
CN102253883B (zh) 一种服务器性能评价的方法和系统
CN105872061B (zh) 一种服务器集群管理方法、装置及系统
US9389894B1 (en) Flexible processor association for virtual machines
CN106464733B (zh) 一种调整云计算中虚拟资源的方法及装置
CN109146236A (zh) 指标异常检测方法、装置、可读存储介质及电子设备
US10009416B2 (en) Perfect application capacity analysis for elastic capacity management of cloud-based applications
CN103841129B (zh) 云计算的资源信息采集服务器和客户端、信息处理方法
CN109492024A (zh) 数据处理方法、装置、计算机设备以及存储介质
CN110020769A (zh) 一种业务风险监控方法、装置及设备
CN103812911B (zh) 一种控制使用PaaS云计算平台服务资源的方法和系统
CN111352791A (zh) 一种系统应用的检测方法、装置、终端设备及存储介质
CN103309843A (zh) 服务器的配置方法和系统
CN113918382A (zh) 用于复位的方法、装置、设备和可读存储介质
US20150281008A1 (en) Automatic derivation of system performance metric thresholds
WO2019174185A1 (zh) 电子装置、动态码请求的处理方法及存储介质
JP2015184830A (ja) 配置制御プログラム、方法及び装置
CN108228414A (zh) 基于Linux的处理器进程参数监测方法和监测系统
CN110659898B (zh) 一种数据控制方法、装置及存储介质
CN112764892A (zh) 管理进程的方法、设备和计算机程序产品

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: 18783664

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 15/01/2020)

122 Ep: pct application non-entry in european phase

Ref document number: 18783664

Country of ref document: EP

Kind code of ref document: A1