CN115543622B - Resource use controller with counting time stamp in distributed environment and control method - Google Patents

Resource use controller with counting time stamp in distributed environment and control method Download PDF

Info

Publication number
CN115543622B
CN115543622B CN202211237761.XA CN202211237761A CN115543622B CN 115543622 B CN115543622 B CN 115543622B CN 202211237761 A CN202211237761 A CN 202211237761A CN 115543622 B CN115543622 B CN 115543622B
Authority
CN
China
Prior art keywords
resource
thread
time
counting
permission
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
CN202211237761.XA
Other languages
Chinese (zh)
Other versions
CN115543622A (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.)
Tiandao Jinke Co ltd
Original Assignee
Tiandao Jinke 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 Tiandao Jinke Co ltd filed Critical Tiandao Jinke Co ltd
Priority to CN202211237761.XA priority Critical patent/CN115543622B/en
Publication of CN115543622A publication Critical patent/CN115543622A/en
Application granted granted Critical
Publication of CN115543622B publication Critical patent/CN115543622B/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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0751Error or fault detection not based on redundancy
    • G06F11/0754Error or fault detection not based on redundancy by exceeding limits
    • G06F11/076Error or fault detection not based on redundancy by exceeding limits by exceeding a count or rate limit, e.g. word- or bit count limit
    • 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/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • 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/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • G06F9/4887Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues involving deadlines, e.g. rate based, periodic
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention discloses a resource usage controller with a counting time stamp in a distributed environment, which generates the counting time stamp of the used resource through a self-developed resource usage counter, when a thread needs to use the resource, the counting time stamp is carried to request the resource competition authority, after the thread after the resource usage authority finishes the resource and returns the resource usage authority, the number of times of the resource usage counter for being used is accumulated by 1, and all servers in the distributed environment are informed to acquire the use authority of each thread waiting for using the resource to continuously compete the resource. The invention improves the effectiveness of the resource use control by using the counting time stamp. The invention also provides a resource use control method.

Description

Resource use controller with counting time stamp in distributed environment and control method
Technical Field
The invention relates to the technical field of computer resource allocation, in particular to a resource use controller with a counting time stamp in a distributed environment and a control method.
Background
With the subdivision of technical fields, the professional nature of the business is becoming stronger, and all technical points in a solution of an item usually need to be completed by cooperation of multiple enterprises, for example, a technical service provider provides face recognition technical service, B technical service provider provides natural language processing technical service, and the like, and these external services are also called external resources to be used by a computer. The number of external resources is usually limited, and the most common expression is current limiting, for example, the face recognition technology service provided by the a technology service provider can only access 100 times within 15 seconds at most, and the excessive access traffic is processed by current limiting exception.
The purpose of the resource use control is to coordinate each thread by controlling the number of threads accessing a specific resource at the same time so as to ensure reasonable use of the resource. In a distributed environment, when multiple servers access limited external resources, excessive access may cause partial access failure, so how to improve the efficiency of resource usage in the distributed environment is an important issue in the art.
Disclosure of Invention
The invention aims to improve the use efficiency of a plurality of servers to external resources in a distributed environment, and provides a resource use controller with a counting time stamp in the distributed environment.
To achieve the purpose, the invention adopts the following technical scheme:
there is provided a resource usage controller with a counting time stamp in a distributed environment, comprising:
a resource usage counter for recording the number of times and time that the resource is used;
the counting time stamp obtaining module is used for obtaining a counting time stamp of the resource to be used by the thread by using the thread start as an instruction, and applying resource use permission to the resource use counter after the thread obtains the counting time stamp;
the permission judging and thread processing module is used for judging whether the thread with the counting time stamp has permission to compete for the resource,
if yes, giving the thread permission to compete for the resources;
if not, suspending the thread;
after the thread competing for the resource usage right finishes using the resource and returns the resource usage right, the resource usage counter accumulates 1 for the number of times of the resource usage, and simultaneously informs all servers in the distributed environment to acquire each thread waiting for using the resource to continuously compete for the resource usage right.
The invention further provides a resource use control method with a counting time stamp in a distributed environment, which comprises the following steps:
providing a resource use counter, and recording the number and time of the resource use;
providing a technical timestamp acquisition module, taking thread starting as an instruction, acquiring a counting timestamp of the resource to be used by the thread by the resource use counter, and applying resource use permission to the resource use counter after the thread acquires the counting timestamp;
providing a permission and thread processing module to determine whether the thread with the count timestamp has permission to compete for the resource,
if yes, giving the thread permission to compete for the resources;
if not, suspending the thread;
after the thread competing for the resource usage right finishes using the resource and returns the resource usage right, the resource usage counter accumulates 1 for the number of times of the resource usage, and simultaneously informs all servers in the distributed environment to acquire each thread waiting for using the resource to continuously compete for the resource usage right.
The invention generates the counting time stamp of the used resource through the self-developed resource use counter, when the thread needs to use the resource, the counting time stamp is carried to request the resource competition authority, after the thread after the resource use authority finishes the resource and returns the resource use authority, the resource use counter accumulates the used times of the resource by 1, and informs all servers in the distributed environment to acquire the use authority of each thread waiting for using the resource to continuously compete the resource. The invention improves the effectiveness of the resource use control by using the counting time stamp.
Drawings
In order to more clearly illustrate the technical solution of the embodiments of the present invention, the drawings that are required to be used in the embodiments of the present invention will be briefly described below. It is evident that the drawings described below are only some embodiments of the present invention and that other drawings may be obtained from these drawings without inventive effort for a person of ordinary skill in the art.
FIG. 1 is a logic diagram of an implementation of a method for controlling resource usage with count time stamps in a distributed environment according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method for controlling resource usage with counting time stamp in a distributed environment according to an embodiment of the present invention;
FIG. 3 is a block diagram of a resource usage controller with count time stamps in a distributed environment according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the internal structure of the count timestamp acquisition module;
FIG. 5 is a schematic diagram of the internal structure of the permission determination and thread processing module.
Detailed Description
The technical scheme of the invention is further described below by the specific embodiments with reference to the accompanying drawings.
Wherein the drawings are for illustrative purposes only and are shown in schematic, non-physical, and not intended to be limiting of the present patent; for the purpose of better illustrating embodiments of the invention, certain elements of the drawings may be omitted, enlarged or reduced and do not represent the size of the actual product; it will be appreciated by those skilled in the art that certain well-known structures in the drawings and descriptions thereof may be omitted.
The same or similar reference numbers in the drawings of embodiments of the invention correspond to the same or similar components; in the description of the present invention, it should be understood that, if the terms "upper", "lower", "left", "right", "inner", "outer", etc. indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, only for convenience in describing the present invention and simplifying the description, rather than indicating or implying that the apparatus or elements being referred to must have a specific orientation, be constructed and operated in a specific orientation, so that the terms describing the positional relationships in the drawings are merely for exemplary illustration and should not be construed as limiting the present patent, and that the specific meaning of the terms described above may be understood by those of ordinary skill in the art according to specific circumstances.
In the description of the present invention, unless explicitly stated and limited otherwise, the term "coupled" or the like should be interpreted broadly, as it may be fixedly coupled, detachably coupled, or integrally formed, as indicating the relationship of components; can be mechanically or electrically connected; can be directly connected or indirectly connected through an intermediate medium, and can be communication between the two parts or interaction relationship between the two parts. The specific meaning of the above terms in the present invention will be understood in specific cases by those of ordinary skill in the art.
The resource usage controller with the counting time stamp in the distributed environment provided by the embodiment of the invention, as shown in fig. 3, comprises a resource usage counter 1, a counting time stamp obtaining module 2 and a permission judging and thread processing module 3.
The resource usage counter 1 is used for recording the number of times external resources are used and the usage time;
the count timestamp obtaining module 2 is configured to obtain, with the thread start as an instruction, a count timestamp of the external resource to be used by the thread last time by using the resource usage counter 1, for example, the external resource to be used by the thread is a face recognition technology, and the count timestamp of the external resource to be used last time recorded by the resource usage counter 1 is 2022-01-20:12:15:18, where the obtained count timestamp is 2022-01-20:12:15:18. After the thread acquires the counting time stamp, the thread applies the resource use permission to the resource use counter 1 with the counting time stamp.
The permission judging and thread processing module 3 is used for judging whether the thread with the counting time stamp has permission to compete for resources,
if yes, giving the thread permission to compete for resources;
if not, the thread is suspended.
After the thread of the resource usage right runs out of the resource and returns the resource usage right, the resource usage counter 1 accumulates 1 the number of times of the external resource being used, and simultaneously notifies all servers in the distributed environment to acquire each thread waiting for using the external resource to continue competing for the resource usage right.
Specifically, as shown in fig. 4, the count timestamp acquisition module includes:
the standard time obtaining unit 21 is configured to obtain, when the thread starts, a local time of the third party service component as a standard time. Because the local time of multiple servers in the distributed environment may not be consistent, in order to ensure the accuracy of time control over the use of resources, the time represented in the count timestamp generated by the resource usage counter uniformly adopts the local time of the third party service component when counting. The third party service component adopts a distributed lock service component or redis server which is mature in the prior art.
The timestamp identifier obtaining unit 22 is configured to obtain, when the thread is started, a timestamp identifier corresponding to a resource to be used by the thread stored in the third party service component. The timestamp identification is used for distinguishing which time range the counting time of the number of times the external resource is used by the resource usage counter belongs to, such as counting the number of times the external resource is used in 2022-01-20 12:15:15 to 2022-01-20-12:15:30 within 15 seconds, the application takes 2022-01-20-12:15:15 as the timestamp identification, all the counts within the 15 seconds are associated with the timestamp identification, such as counting the thread using the external resource once at two time points 2022-01-20:12:15:18 and 2022-01-20-12:15:21 respectively, and then the timestamp identifications corresponding to the two counts are 2022-01-20-12:15:15. To facilitate invocation of the timestamp identification by multiple servers in a distributed environment, the timestamp identification is preferably also stored in the third party service component.
A time range obtaining unit 23, configured to obtain, when the thread is started, a time range corresponding to a resource to be used by the thread stored in the third party service component, where the time range is defined as a variable scope in the present application, and 15 seconds is a time range as described in the background art;
a time difference calculation unit 24 is connected to the standard time acquisition unit 21 and the time stamp identification acquisition unit 22, respectively, for calculating a time difference of the standard time and the time indicated by the time stamp identification. For example, when the local time, i.e. standard time, of the third party service component acquired during thread starting is 2022-01-20:12:15:20, and the acquired time stamp mark indicates that the time is 2022-01-20:12:15:15, the time difference is 5 seconds.
A judging unit 25 respectively connected to the time range acquiring unit 23 and the time difference calculating unit 24 for judging whether the time difference is equal to or smaller than the acquired time range,
if yes, judging that the counting time of the number of times of using the resource is still in a preset time range, and taking the current time of the resource using counter as a counting time stamp to be carried by the thread;
if not, judging that the counting time of the number of times of using the resource exceeds the preset time range, and resetting the counting time stamp by adopting the current time of the third service component.
For example, if the calculated time difference is 5 seconds and the preset time range is 15 seconds, it is determined that the count time of the number of times the resource is used is still within the preset 15-second time range. Assuming that the local time of the resource usage counter is 2022-01-20:12:15:21 when this determination is made, this time is taken as the count timestamp to be carried by the thread.
The internal structure of the permission judging and thread processing module, as shown in fig. 5, includes:
the current limit number obtaining unit 31 is configured to obtain, with the instruction of submitting the resource usage right by the thread, the current limit number that the resource to be used by the thread stored in the third party service component is allowed to be used in the corresponding time range, where the current limit number is denoted as variable time in this application, for example, the number of accesses limited in 15 seconds described in the background art is 100 times.
The count value obtaining unit 32 is configured to obtain, with the application of the resource usage permission submitted by the thread as an instruction, a count value of the number of times the resource to be used by the thread has been used at a time point indicated by a count timestamp carried by the thread by the resource usage counter. In order to facilitate the data call of each server in the distributed environment, the count value is preferably stored in the third-party service component, and compared with the count value stored in the server, the information interaction between the servers is avoided, and the occupation of the computing resources of the servers is reduced.
A permission judging and thread processing unit 33 respectively connected to the current limit number obtaining unit 31 and the count value obtaining unit 32 for judging whether the obtained count value is smaller than a preset current limit number,
if yes, the thread is given the authority to compete for the resource, namely the thread is informed of the use authority that the thread can compete for the resource;
if not, suspending the thread, and after suspending, adding the thread into a monitoring queue by a server initiating the thread to monitor.
In order to reduce the probability of resource errors in use, the same resource can be used by only one thread at the same time, so that multiple threads with competing rights need to compete for the use sequence of the same resource. In the application, the competition is realized by adopting a redis distributed lock, the principle of the realization of the distributed lock is that a plurality of servers can call setnx commands simultaneously by utilizing the single-thread characteristic of redis, only one server can call resources successfully, a result 1 is returned after success, and other servers which are not successful in competition return a result 0.
After the thread gains the resource usage right, the resource is acquired and used, after the usage is finished, the resource usage right is returned, namely, the resource usage counter is informed of the returned usage right, and the number of times of the resource is accumulated by 1 after the resource usage counter receives the notification of the returned resource usage right.
After the resource usage right returns, the resource usage counter adopts socket broadcast to inform all servers in the distributed environment, after the server receives the notification, the server acquires a first waiting thread from the monitoring thread queue, and the waiting threads lifted by other servers continue to compete for the usage right of the resource, the threads with competition failure continue to be monitored, and the threads with competition success acquire the resource and use the resource.
To facilitate shared invocation of data by the servers, the time frames and the amount of throttling described above are stored as initialization data for the resource in a third party service component. When the capacity of the resource used simultaneously is increased, the initialization data can be directly modified in the third party service component, so that the method is more convenient.
In addition, after a thread is suspended, there may be a case where resource usage rights cannot be obtained again for some reason, resulting in a large number of threads being blocked. To address this problem, the resource usage controller preferably further comprises a listener for de-suspending the thread when it is heard that the duration of time the thread is suspended exceeds a preset duration threshold.
The counting rules and timing rules of the local counting system may not be consistent with the rules of the external resource provider, and counting differences between the two parties may occur. To avoid the impact of these differences on the effectiveness of resource usage control, a certain number of buffers may be left to deal with such problems. For example, if the external resource side limits the current for 100 times within 15 seconds, 90 times of calls within 15 seconds can be set in the application, and 10% buffer is reserved for handling the inconsistent problem.
In order to ensure that the resource usage counter is free from errors as far as possible, the resource usage counter is in a master-slave working mode, when a monitoring program discovers that a host is down, a slave is actively switched into the host, and data between the master and the slave is shared and stored in a data synchronization mode.
The embodiment also provides a resource usage control method with a technical timestamp in a distributed environment, as shown in fig. 1 and fig. 2, including:
step S1, a resource usage counter records the number of times and time of the resource usage;
step S2, a time stamp obtaining module takes thread start as an instruction, obtains a counting time stamp of a resource to be used by a thread by a resource use counter, and applies resource use permission to the resource use counter after the thread obtains the counting time stamp;
step S3, the authority and thread processing module judges whether the thread with the counting time stamp has the authority of competing for resources,
if yes, giving the thread permission to compete for resources;
if not, suspending the thread;
and S4, after the threads competing for the resource use permission run out of the resource and return the resource use permission, accumulating the number of times of the resource used by the resource use counter by 1, and simultaneously notifying all servers in the distributed environment to acquire each thread waiting for the resource use to continuously compete for the resource use permission.
In step S2, the method for obtaining the count timestamp of the resource to be used by the thread by the resource usage counter specifically includes:
providing a standard time acquisition unit to acquire the local time of the third party service component as standard time when the thread is started;
providing a timestamp identifier acquisition unit to acquire a timestamp identifier corresponding to a resource to be used by a thread stored in a third party service component when the thread is started;
providing a time range obtaining unit to obtain a time range corresponding to the resource to be used by the thread stored in the third party service component when the thread is started;
providing a time difference calculating unit to calculate the time difference between the standard time and the time of the timestamp identification;
providing a judging unit for judging whether the time difference is smaller than or equal to the time range,
if yes, judging that the counting time of the number of times of the resource use is still in a preset time range, and taking the current time of the resource use counter as a counting time stamp to be carried by the thread;
if not, judging that the counting time of the number of times of using the resource exceeds the preset time range, and resetting the counting time stamp by adopting the current time of the third party service component.
In step S3, the method for determining whether the thread with the count timestamp has the authority to contend for the resource includes:
providing a current limiting quantity obtaining unit, and obtaining the current limiting quantity of the resources to be used by the threads stored in the third-party service components, which are allowed to be used in a corresponding time range, by taking the application of the resource using permissions submitted by the threads as an instruction;
providing a count value acquisition unit, and acquiring a count value of a time point indicated by a count timestamp carried by a thread by a resource use counter for the number of times the thread has used the resource to be used;
providing a permission judging and thread processing unit to judge whether the acquired count value is smaller than the current limiting number,
if yes, giving the thread permission to compete for resources;
if not, the thread is suspended.
It should be understood that the above description is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be apparent to those skilled in the art that various modifications, equivalents, variations, and the like can be made to the present invention. However, such modifications are intended to fall within the scope of the present invention without departing from the spirit of the present invention. In addition, some terms used in the specification and claims of the present application are not limiting, but are merely for convenience of description.

Claims (6)

1. A resource usage controller with a count timestamp in a distributed environment, comprising:
a resource usage counter for recording the number of times and time that the resource is used;
the counting time stamp obtaining module is used for obtaining a counting time stamp of the resource to be used by the thread by using the thread start as an instruction, and applying resource use permission to the resource use counter after the thread obtains the counting time stamp;
the permission judging and thread processing module is used for judging whether the thread with the counting time stamp has permission to compete for the resource,
if yes, giving the thread permission to compete for the resources;
if not, suspending the thread;
after the thread competing for the resource use permission finishes using the resource and returns the resource use permission, the resource use counter accumulates 1 for the used times of the resource, and simultaneously informs all servers in a distributed environment to acquire each thread waiting for using the resource to continue competing for the resource use permission;
the counting timestamp obtaining module comprises the following components:
the standard time acquisition unit is used for acquiring the local time of the third party service component as standard time when the thread is started;
the time stamp identifier obtaining unit is used for obtaining a time stamp identifier corresponding to the resource to be used by the thread stored in the third party service component when the thread is started;
the time range obtaining unit is used for obtaining a time range corresponding to the resource to be used by the thread stored in the third party service component when the thread is started;
the time difference calculation unit is respectively connected with the standard time acquisition unit and the time stamp identification acquisition unit and is used for calculating the time difference between the standard time and the time represented by the time stamp identification;
a judging unit respectively connected with the time range obtaining unit and the time difference calculating unit for judging whether the time difference is smaller than or equal to the time range,
if yes, judging that the counting time of the number of times of using the resource is still in the preset time range, and taking the current time of the resource using counter as the counting time stamp to be carried by the thread;
if not, judging that the counting time of the number of times of using the resource exceeds the preset time range, and resetting the counting time stamp by adopting the current time of the third party service component;
the permission judging and thread processing module comprises:
the current limiting quantity obtaining unit is used for obtaining the current limiting quantity of the resources to be used by the threads stored in the third-party service component, which is allowed to be used in a corresponding time range, by taking the application of the resource using permissions submitted by the threads as an instruction;
the counting value acquisition unit is used for acquiring a counting value of the number of times that the resource to be used by the thread is used at a time point indicated by the counting timestamp carried by the thread by the resource use counter by taking the application of the resource use permission submitted by the thread as an instruction;
the permission judging and thread processing unit is respectively connected with the current limiting quantity obtaining unit and the count value obtaining unit and is used for judging whether the obtained count value is smaller than the preset current limiting quantity,
if yes, giving the thread permission to compete for the resources;
if not, suspending the thread.
2. The counting time stamped resource usage controller in a distributed environment of claim 1, wherein the third party service component is a distributed lock service component or a redis server.
3. The resource usage controller with counting time stamp in a distributed environment as recited in claim 1 wherein said resource usage counter informs all of said servers using socket broadcast.
4. The resource usage controller with counting time stamp in a distributed environment as recited in claim 1, further comprising:
and the monitor is used for removing the suspension of the thread when the duration of the suspension of the thread exceeds a preset duration threshold.
5. A method for controlling resource usage with a count timestamp in a distributed environment, comprising:
providing a resource use counter, and recording the number and time of the resource use;
providing a counting time stamp obtaining module, taking thread starting as an instruction, obtaining a counting time stamp of the resource to be used by the thread by the resource use counter, and applying resource use permission to the resource use counter after the thread obtains the counting time stamp;
providing a permission and thread processing module to determine whether the thread with the count timestamp has permission to compete for the resource,
if yes, giving the thread permission to compete for the resources;
if not, suspending the thread;
after the thread competing for the resource use permission finishes using the resource and returns the resource use permission, the resource use counter accumulates 1 for the used times of the resource, and simultaneously informs all servers in a distributed environment to acquire each thread waiting for using the resource to continue competing for the resource use permission;
the method for obtaining the counting time stamp of the resource to be used by the thread by the resource use counter comprises the following steps;
providing a standard time acquisition unit to acquire the local time of the third party service component as standard time when the thread is started;
providing a timestamp identifier obtaining unit to obtain a timestamp identifier corresponding to the resource to be used by the thread stored in the third party service component when the thread is started;
providing a time range obtaining unit to obtain a time range corresponding to the resource to be used by the thread stored in the third party service component when the thread is started;
providing a time difference calculation unit to calculate a time difference between the standard time and the time represented by the timestamp identification;
providing a judging unit for judging whether the time difference is less than or equal to the time range,
if yes, judging that the counting time of the number of times of using the resource is still in the preset time range, and taking the current time of the resource using counter as the counting time stamp to be carried by the thread;
if not, judging that the counting time of the number of times of using the resource exceeds the preset time range, and resetting the counting time stamp by adopting the current time of the third party service component;
the method for judging whether the thread with the counting time stamp has the authority to compete for the resource comprises the following steps:
providing a current limiting quantity obtaining unit, and obtaining the current limiting quantity of the resources to be used by the threads stored in the third-party service component, which is allowed to be used in a corresponding time range, by taking the application of the resource using permissions submitted by the threads as an instruction;
providing a count value acquisition unit, taking the application of the resource use permission submitted by the thread as an instruction, and acquiring the count value of the number of times that the resource to be used by the thread is used at a time point indicated by the count timestamp carried by the thread by the resource use counter;
providing a permission judging and thread processing unit to judge whether the acquired count value is smaller than the preset current limiting number,
if yes, giving the thread permission to compete for the resources;
if not, suspending the thread.
6. The method for counting time stamped resource usage control in a distributed environment of claim 5, wherein the third party service component is a distributed lock service component or a redis server.
CN202211237761.XA 2022-10-11 2022-10-11 Resource use controller with counting time stamp in distributed environment and control method Active CN115543622B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211237761.XA CN115543622B (en) 2022-10-11 2022-10-11 Resource use controller with counting time stamp in distributed environment and control method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211237761.XA CN115543622B (en) 2022-10-11 2022-10-11 Resource use controller with counting time stamp in distributed environment and control method

Publications (2)

Publication Number Publication Date
CN115543622A CN115543622A (en) 2022-12-30
CN115543622B true CN115543622B (en) 2024-03-12

Family

ID=84733820

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211237761.XA Active CN115543622B (en) 2022-10-11 2022-10-11 Resource use controller with counting time stamp in distributed environment and control method

Country Status (1)

Country Link
CN (1) CN115543622B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004252670A (en) * 2003-02-19 2004-09-09 Fujitsu Ltd Contention detection system and contention detection method of shared resource
CN106407016A (en) * 2016-10-19 2017-02-15 腾讯科技(深圳)有限公司 Method and device for simulating multi-threading resource competition
CN106462674A (en) * 2014-06-11 2017-02-22 阿姆Ip有限公司 Resource access control using validation token
CN111262795A (en) * 2020-01-08 2020-06-09 京东数字科技控股有限公司 Service interface-based current limiting method and device, electronic equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004252670A (en) * 2003-02-19 2004-09-09 Fujitsu Ltd Contention detection system and contention detection method of shared resource
CN106462674A (en) * 2014-06-11 2017-02-22 阿姆Ip有限公司 Resource access control using validation token
CN106407016A (en) * 2016-10-19 2017-02-15 腾讯科技(深圳)有限公司 Method and device for simulating multi-threading resource competition
CN111262795A (en) * 2020-01-08 2020-06-09 京东数字科技控股有限公司 Service interface-based current limiting method and device, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"基于并串结合机制的数据竞争消除系统设计与实现";沙晗等;《微电子学与计算机》(第07期);第96-99+104页 *

Also Published As

Publication number Publication date
CN115543622A (en) 2022-12-30

Similar Documents

Publication Publication Date Title
US9336054B2 (en) Method and apparatus for configuring resource
CN106681811B (en) Multithreading scheduling method and device based on thread pool
EP3270287A1 (en) Scheduling method and system for video analysis tasks
CN107241281B (en) Data processing method and device
CN107426274B (en) Method and system for service application and monitoring, analyzing and scheduling based on time sequence
US8627325B2 (en) Scheduling memory usage of a workload
JP2004021982A (en) Method and system for dynamically allocating computer system resource
CN111338791A (en) Method, device and equipment for scheduling cluster queue resources and storage medium
CN111290917A (en) YARN-based resource monitoring method and device and terminal equipment
CN110647392A (en) Intelligent elastic expansion method based on container cluster
CN110471749A (en) Task processing method, device, computer readable storage medium and computer equipment
CN109117280A (en) The method that is communicated between electronic device and its limiting process, storage medium
CN111464331A (en) Control method and system for thread creation and terminal equipment
CN115543622B (en) Resource use controller with counting time stamp in distributed environment and control method
CN110750498B (en) Object access method, device and storage medium
CN109284193A (en) A kind of distributed data processing method and server based on multithreading
CN108647102A (en) Service request processing method, device and the electronic equipment of heterogeneous system
CN113157426A (en) Task scheduling method, system, equipment and storage medium
CN114756356A (en) Task processing method, work node device, main node device and storage medium
CN109144739A (en) A kind of method and system of multi-user's contention control based on Argus video monitoring
CN114157717A (en) Micro-service dynamic current limiting system and method
CN114218041A (en) Dynamic process monitoring method, device, equipment and storage medium
WO2017070869A1 (en) Memory configuration method, apparatus and system
CN108874325B (en) Data printing method and system
WO2020220534A1 (en) Middleware-based data processing method and related apparatus

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