CN116127494A - Control method and related device for concurrent access of users - Google Patents

Control method and related device for concurrent access of users Download PDF

Info

Publication number
CN116127494A
CN116127494A CN202310322379.7A CN202310322379A CN116127494A CN 116127494 A CN116127494 A CN 116127494A CN 202310322379 A CN202310322379 A CN 202310322379A CN 116127494 A CN116127494 A CN 116127494A
Authority
CN
China
Prior art keywords
token
access
tokens
target
token bucket
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.)
Pending
Application number
CN202310322379.7A
Other languages
Chinese (zh)
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.)
Yundy Intelligent Technology Co ltd
Original Assignee
Yundy Intelligent Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Yundy Intelligent Technology Co ltd filed Critical Yundy Intelligent Technology Co ltd
Priority to CN202310322379.7A priority Critical patent/CN116127494A/en
Publication of CN116127494A publication Critical patent/CN116127494A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/604Tools and structures for managing or administering access control systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2221/00Indexing scheme relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/21Indexing scheme relating to G06F21/00 and subgroups addressing additional information or applications relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/2141Access rights, e.g. capability lists, access control lists, access tables, access matrices

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Health & Medical Sciences (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Automation & Control Theory (AREA)
  • Storage Device Security (AREA)

Abstract

The invention relates to the field of data processing, and discloses a control method and a related device for concurrent access of users, which are used for improving the efficiency of concurrent access of users. The method comprises the following steps: obtaining access rights and priorities of a plurality of target users, and carrying out token distribution on the plurality of target users according to the access rights and priorities to obtain the number of tokens; acquiring at least one first token according to the number of tokens corresponding to each target user, caching the at least one first token to a preset token bucket, and setting the maximum capacity of the token bucket; when the target user accesses the shared resource, at least one second token with the target number is acquired from the token bucket; after the target user finishes accessing the shared resource, releasing at least one second token, and placing the at least one second token back into the token bucket; and periodically checking the number of tokens in the token bucket, and dynamically adjusting the number of tokens in the token bucket and the acquisition rate according to the access state.

Description

Control method and related device for concurrent access of users
Technical Field
The present invention relates to the field of data processing, and in particular, to a method and an apparatus for controlling concurrent access of a user.
Background
In modern computer systems, multiple users often need to access shared resources, such as databases, web services, etc., simultaneously. In order to ensure the stability and security of the system, these concurrent accesses must be effectively controlled. Common methods include using concurrent control mechanisms such as locks, semaphores, etc., but these methods have problems such as inefficiency and susceptibility to deadlock.
Disclosure of Invention
The invention provides a control method and a related device for concurrent access of users, which are used for improving the efficiency of concurrent access of users.
The first aspect of the present invention provides a method for controlling concurrent access of users, where the method for controlling concurrent access of users includes:
obtaining access rights and priorities of a plurality of target users, and carrying out token distribution on the plurality of target users according to the access rights and the priorities to obtain the number of tokens corresponding to each target user;
obtaining at least one corresponding first token according to the number of tokens corresponding to each target user, caching the at least one first token to a preset token bucket, and setting the maximum capacity of the token bucket;
when the target user accesses the shared resource, acquiring at least one second token with a target number from the token bucket;
Releasing the at least one second token after the target user completes access to the shared resource, and placing the at least one second token back into the token bucket;
and periodically checking the number of tokens in the token bucket, and dynamically adjusting the number of tokens in the token bucket and the acquisition rate according to the access state of the target user.
With reference to the first aspect, in a first implementation manner of the first aspect of the present invention, the obtaining access rights and priorities of a plurality of target users, and performing token allocation on the plurality of target users according to the access rights and priorities, to obtain a number of tokens corresponding to each target user, includes:
obtaining access rights and priorities of a plurality of target users, wherein the access rights comprise: low authority and high authority, the priority includes: high priority and low priority;
performing token distribution on the plurality of target users according to the access rights and the priorities;
when the authority of the target user is low and the priority is high, the token quantity of a first preset value is distributed;
and when the authority of the target user is high and the priority is low, allocating the token quantity with a second preset value.
With reference to the first aspect, in a second implementation manner of the first aspect of the present invention, the obtaining at least one corresponding first token according to the number of tokens corresponding to each target user, caching the at least one first token into a preset token bucket, and setting a maximum capacity of the token bucket includes:
acquiring at least one corresponding first token according to the number of tokens corresponding to each target user;
caching the at least one first token to a preset token bucket, and acquiring the maximum concurrent access amount of the token bucket;
and setting the maximum capacity of the token bucket according to the maximum concurrent access amount.
With reference to the first aspect, in a third implementation manner of the first aspect of the present invention, when the target user accesses the shared resource, the obtaining at least one second token of the target number from the token bucket includes:
when the target user accesses the shared resource, carrying out token quantity distribution on the target user based on a preset token distribution strategy to obtain a target quantity;
and acquiring the token acquisition frequency of the token bucket, and acquiring at least one second token of the target number from the token bucket according to the token acquisition frequency.
With reference to the first aspect, in a fourth implementation manner of the first aspect of the present invention, after the target user completes access to the shared resource, releasing the at least one second token, and placing the at least one second token back into the token bucket includes:
after the target user finishes accessing the shared resource, carrying out recovery strategy matching on the at least one second token to obtain a target recovery strategy;
releasing the at least one second token based on the target reclamation policy;
and carrying out token life cycle management on the at least one second token, and placing the at least one second token back into the token bucket.
With reference to the first aspect, in a fifth implementation manner of the first aspect of the present invention, the periodically checking the number of tokens in the token bucket and dynamically adjusting the number of tokens and the acquisition rate of the token bucket according to the access state of the target user includes:
periodically checking the number of tokens in the token bucket to generate a periodic check result;
collecting monitoring indexes of the token bucket, and generating access states of the target users according to the monitoring indexes;
And dynamically adjusting the number of tokens of the token bucket and the acquisition rate according to the access state.
The second aspect of the present invention provides a control device for user concurrent access, where the control device for user concurrent access includes:
the acquisition module is used for acquiring access rights and priorities of a plurality of target users, and carrying out token distribution on the plurality of target users according to the access rights and the priorities to obtain the number of tokens corresponding to each target user;
the caching module is used for acquiring at least one corresponding first token according to the number of tokens corresponding to each target user, caching the at least one first token to a preset token bucket, and setting the maximum capacity of the token bucket;
a processing module, configured to obtain a target number of at least one second token from the token bucket when the target user accesses the shared resource;
the release module is used for releasing the at least one second token after the target user finishes accessing the shared resource, and placing the at least one second token back into the token bucket;
and the adjusting module is used for periodically checking the number of tokens in the token bucket and dynamically adjusting the number of tokens in the token bucket and the acquisition rate according to the access state of the target user.
A third aspect of the present invention provides a control device for concurrent access by a user, including: a memory and at least one processor, the memory having instructions stored therein; and the at least one processor invokes the instructions in the memory to enable the control device for concurrent access of the user to execute the control method for concurrent access of the user.
A fourth aspect of the present invention provides a computer readable storage medium having instructions stored therein which, when run on a computer, cause the computer to perform the above-described control method of concurrent access by a user.
In the technical scheme provided by the invention, the access rights and the priorities of a plurality of target users are obtained, and the token distribution is carried out on the plurality of target users according to the access rights and the priorities to obtain the number of tokens; acquiring at least one first token according to the number of tokens corresponding to each target user, caching the at least one first token to a preset token bucket, and setting the maximum capacity of the token bucket; when the target user accesses the shared resource, at least one second token with the target number is acquired from the token bucket; after the target user finishes accessing the shared resource, releasing at least one second token, and placing the at least one second token back into the token bucket; the method comprises the steps of periodically checking the number of tokens in a token bucket, dynamically adjusting the number of tokens in the token bucket and the acquisition rate according to the access state. When a user needs to access a shared resource, a sufficient number of tokens must be obtained from the token bucket for access. Because the number of tokens and the acquisition rate of each user are limited, the situation that resources are excessively occupied or a certain user monopolizes resources for a long time can be effectively avoided. The situation that resources are excessively occupied or a certain user monopolizes the resources for a long time can be effectively avoided. Simple realization, high efficiency, difficult occurrence of deadlock and the like. The method supports dynamic adjustment of the number of tokens and the acquisition rate, and adapts to various different user access requirements.
Drawings
FIG. 1 is a schematic diagram of an embodiment of a method for controlling concurrent access of users according to an embodiment of the present invention;
FIG. 2 is a flow chart of setting the maximum capacity of a token bucket in an embodiment of the invention;
FIG. 3 is a flow chart of obtaining at least one second token of a target number in an embodiment of the present invention;
FIG. 4 is a flow chart of releasing at least one second token in an embodiment of the invention;
FIG. 5 is a schematic diagram of an embodiment of a control device for concurrent access by a user according to an embodiment of the present invention;
fig. 6 is a schematic diagram of an embodiment of a control device for concurrent access by a user according to an embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a control method and a related device for concurrent access of users, which are used for improving the efficiency of the concurrent access of the users. The terms "first," "second," "third," "fourth" and the like in the description and in the claims and in the above drawings, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments described herein may be implemented in other sequences than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or apparatus.
For easy understanding, the following describes a specific flow of an embodiment of the present invention, referring to fig. 1, and one embodiment of a method for controlling concurrent access of users in an embodiment of the present invention includes:
s101, acquiring access rights and priorities of a plurality of target users, and distributing tokens to the plurality of target users according to the access rights and priorities to obtain the number of tokens corresponding to each target user;
it can be understood that the execution body of the present invention may be a control device that is accessed by a user concurrently, and may also be a terminal or a server, which is not limited herein. The embodiment of the invention is described by taking a server as an execution main body as an example.
Specifically, the server allocates different numbers of tokens to each user, and determines the number of tokens according to the access rights and the priority. The server determines, for each user in the system, the number of tokens it has based on its access rights and priority. Typically, users with high access rights and low priority will be assigned fewer tokens, while users with low access rights and high priority will be assigned more tokens. Specifically, in the concurrent access control method, the step involves how to allocate different numbers of tokens to each user, so as to ensure that the concurrent access can be effectively controlled in the subsequent access process, and avoid the situation that resources are excessively occupied or a certain user monopolizes resources for a long time.
S102, acquiring at least one corresponding first token according to the number of tokens corresponding to each target user, caching the at least one first token into a preset token bucket, and setting the maximum capacity of the token bucket;
specifically, the server places these tokens into a token bucket and sets the maximum capacity of the bucket. In this step, tokens assigned by all users are placed in one token bucket, while the maximum capacity of the token bucket is set. A token bucket may be thought of as a cache pool of tokens for storing all available tokens. Specifically, the server puts tokens assigned by all users into one token bucket, and sets the maximum capacity of the token bucket. The purpose of this step is to centrally manage all available tokens so that subsequent access procedures can acquire and release tokens therefrom.
S103, when the target user accesses the shared resource, at least one second token with the target number is obtained from the token bucket;
specifically, when a user needs to access the shared resource, a certain number of tokens are taken out of the token bucket, and if the number of tokens is insufficient, the user needs to wait for other users to release the tokens. In this step, when a user needs to access a shared resource, it must acquire a certain number of tokens from the token bucket to access. If the number of tokens is insufficient, it is necessary to wait for the other users to release tokens. Typically, each user can only acquire a certain number of tokens within a period of time, so as to prevent that a certain user monopolizes too many tokens to cause other users to be unable to access the shared resource. When a user needs to access the shared resource, a certain number of tokens are fetched from the token bucket, and if the number of tokens is insufficient, the user needs to wait for other users to release the tokens. The purpose of this step is to ensure that each user can obtain sufficient access rights when accessing the shared resource, while avoiding situations where the resource is over-occupied or where a certain user has been monopolizing the resource for a long time.
S104, after the target user finishes accessing the shared resource, releasing at least one second token, and placing the at least one second token back into the token bucket;
specifically, after the user completes the access to the shared resource, the corresponding number of tokens is released and put back into the token bucket. In this step, when a user completes access to the shared resource, it needs to release a corresponding number of tokens and put them back into the token bucket so that other users can continue to access the shared resource. Specifically, after the user accesses the shared resource, the used token is put back into the token bucket. The purpose of this step is to ensure that each user can release its acquired access rights in time after using the shared resource so that other users can continue to access.
S105, checking the number of tokens in the token bucket regularly, and dynamically adjusting the number of tokens in the token bucket and the acquisition rate according to the access state of the target user.
Specifically, the server periodically checks the number of tokens in the token bucket, and dynamically adjusts the number of tokens and the acquisition rate according to the access condition of the user. In this step, the system needs to periodically check the number of tokens in the token bucket and dynamically adjust the number of tokens and the acquisition rate according to the access situation of the user. For example, if a user's access frequency is higher and duration is longer, the system may increase the user's token number and acquisition rate to increase its access efficiency. Conversely, if a user's access frequency is lower or duration is shorter, the system may reduce the user's token number and acquisition rate to save resources. Specifically, the server monitors the status of the token bucket to timely handle when an abnormal situation occurs. The purpose of this step is to ensure that the token bucket can always be in a normal operating state, avoiding system crashes or service unavailability due to excessive occupation of resources or other problems.
In the embodiment of the invention, access rights and priorities of a plurality of target users are obtained, and token distribution is carried out on the plurality of target users according to the access rights and priorities to obtain the number of tokens; acquiring at least one first token according to the number of tokens corresponding to each target user, caching the at least one first token to a preset token bucket, and setting the maximum capacity of the token bucket; when the target user accesses the shared resource, at least one second token with the target number is acquired from the token bucket; after the target user finishes accessing the shared resource, releasing at least one second token, and placing the at least one second token back into the token bucket; the method comprises the steps of periodically checking the number of tokens in a token bucket, dynamically adjusting the number of tokens in the token bucket and the acquisition rate according to the access state. When a user needs to access a shared resource, a sufficient number of tokens must be obtained from the token bucket for access. Because the number of tokens and the acquisition rate of each user are limited, the situation that resources are excessively occupied or a certain user monopolizes resources for a long time can be effectively avoided. The situation that resources are excessively occupied or a certain user monopolizes the resources for a long time can be effectively avoided. Simple realization, high efficiency, difficult occurrence of deadlock and the like. The method supports dynamic adjustment of the number of tokens and the acquisition rate, and adapts to various different user access requirements.
In a specific embodiment, the process of executing step S101 may specifically include the following steps:
(1) Obtaining access rights and priorities of a plurality of target users, wherein the access rights comprise: low rights and high rights, the priority includes: high priority and low priority;
(2) Performing token distribution on a plurality of target users according to the access rights and the priorities;
(3) When the authority of the target user is low and the priority is high, the token quantity of a first preset value is distributed;
(4) And when the authority of the target user is high and the priority is low, allocating the token quantity of a second preset value.
Specifically, the server needs to evaluate the access rights and priorities of each user before assigning tokens. Access rights generally refer to the scope of which resources the user can access, e.g., read, modify, etc. The priority refers to the relative priority that the user has when multiple users access the shared resource at the same time. Typically, users with high access rights and low priority will be assigned fewer tokens, while users with low access rights and high priority will be assigned more tokens. One simple allocation method is to determine the initial number of tokens for each user based on their access rights and priorities, and then use a dynamic adjustment algorithm to continuously adjust the number of tokens for each user during subsequent accesses. In this way, users with high access rights and low priority will be assigned a smaller initial number of tokens, but as their access frequency increases, the system can gradually increase their number of tokens, increasing their access efficiency. Otherwise, the user with low access authority and high priority is allocated more initial tokens, but if the access frequency starts to decrease, the system can gradually decrease the number of tokens and save resources. In addition to the access rights and priority based allocation method, other factors may be considered to determine the initial number of tokens per user. For example, the number of tokens may be determined based on the number of accesses by the user over a period of time, access duration, bandwidth occupancy, and the like. In this way, users who access the system frequently will be assigned more tokens to increase their access efficiency, while users who access the system less will be assigned fewer tokens to save resources. The method needs to count and analyze the access behaviors of the user, and is relatively suitable for a system needing long-time operation. It should be noted that when assigning tokens to each user, it must be ensured that each user is able to obtain enough tokens to meet their access needs. Otherwise, a situation that a certain user cannot access the shared resource occurs, and normal operation of the system is affected. Therefore, when the token is distributed, the access requirement of the user needs to be fully known, and the token is reasonably distributed according to the actual situation.
In a specific embodiment, as shown in fig. 2, the process of executing step S102 may specifically include the following steps:
s201, acquiring at least one corresponding first token according to the number of tokens corresponding to each target user;
s202, caching at least one first token to a preset token bucket, and acquiring the maximum concurrent access quantity of the token bucket;
s203, setting the maximum capacity of the token bucket according to the maximum concurrent access amount.
In particular, when implementing a token bucket algorithm, a server typically sees a token bucket as a queue, where each token represents a certain number of access rights. When a user needs to access a shared resource, it must acquire a certain number of tokens from the token bucket to access. If the number of tokens is insufficient, it is necessary to wait for the other users to release tokens until a sufficient number of tokens are acquired. In designing token bucket algorithms, the following aspects need to be considered: the capacity of the token bucket determines the upper limit of the number of tokens that can be stored therein. In general, the capacity of the token bucket should be able to meet the requirements of the maximum concurrent access in the system and should be matched to the hardware configuration of the system, network bandwidth, etc. If the capacity of the token bucket is too small, the system cannot meet the access requirement of the peak period; if the capacity of the token bucket is too large, system resources are wasted. Token generation rate, which is how many new tokens can be generated per second by the instruction token bucket. Typically, the rate of generation of tokens should be matched to the processing power of the system to ensure that the system is able to respond to user requests in a timely manner. If the generation rate of the token is too slow, the waiting time of the user is too long; if the token generation rate is too fast, system resources are wasted. The consumption rate of tokens, which refers to how many tokens each user can consume per second. Typically, the consumption rate of the token should be matched to the processing power of the system to ensure that each user is able to obtain sufficient access rights. If the consumption rate of the token is too slow, the user access efficiency is low; if the consumption rate of the token is too high, the resources are excessively occupied, and the normal operation of the system is affected. The initial state of the token bucket comprises parameters such as the number of tokens contained in the token bucket, the generation rate and the like. Before the system is started, the initial state of the token bucket needs to be reasonably set so as to meet the access requirement of the system. In general, the initial state of the token bucket should have an appropriate buffering capacity to cope with the access peak at system start-up. Overall, the token bucket algorithm is a very efficient concurrent access control method, and is widely used in many fields such as network services, financial transaction systems, and the like. By reasonably setting parameters of the token bucket, the concurrent access of a plurality of users in the system can be effectively controlled, and the stability and the safety of resources are ensured.
In a specific embodiment, as shown in fig. 3, the process of executing step S103 may specifically include the following steps:
s301, when a target user accesses shared resources, carrying out token quantity distribution on the target user based on a preset token distribution strategy to obtain target quantity;
s302, acquiring token acquisition frequency of a token bucket, and acquiring at least one second token of a target number from the token bucket according to the token acquisition frequency.
Specifically, when implementing the above steps, the server needs to consider the following aspects: token allocation policy, which refers to how tokens are allocated from a token bucket to each user. Typically, how many tokens each user should obtain can be determined based on factors such as access needs, priority, and historical access records. For example, for users who frequently access the system, the system may assign more tokens to increase its access efficiency; for users with lower access rights, the system may assign fewer tokens to save resources. Token acquisition frequency, which refers to how many tokens can be acquired per second per user. Typically, each user can only acquire a certain number of tokens within a period of time, so as to prevent that a certain user monopolizes too many tokens to cause other users to be unable to access the shared resource. The system can dynamically adjust the acquisition frequency according to the access requirement of each user, the historical access record and other factors so as to improve the resource utilization rate of the system. And (3) managing a waiting queue, and when the number of the tokens is insufficient, the user needs to enter the waiting queue to wait. In the waiting queue, the waiting time and priority of each user need to be managed so that the user with higher priority can be allocated with the token in time when the token is available. For example, a first-in-first-out (FIFO) or priority-based waiting queue management algorithm may be employed in the waiting queue to ensure that all users are able to get fair treatment. Timeout and retry mechanisms, which require timeout and retry processing if the user waits too long or other anomalies occur during the wait. For example, if a certain user waiting time exceeds a preset maximum waiting time, the system can automatically remove the waiting time from the waiting queue and send a timeout prompt message to the user. If a user fails or other anomalies occurs while acquiring a token, the system may attempt to reacquire the token to increase access success. In conclusion, the server can effectively control concurrent access by reasonably setting a token allocation strategy, acquiring frequency and a management and overtime retry mechanism of a waiting queue, so that the stability and the safety of the system are ensured.
In a specific embodiment, as shown in fig. 4, the process of executing step S104 may specifically include the following steps:
s401, after the target user completes access to the shared resource, carrying out recovery strategy matching on at least one second token to obtain a target recovery strategy;
s402, releasing at least one second token based on the target recycling strategy;
s403, carrying out token life cycle management on the at least one second token, and placing the at least one second token back into a token bucket.
Specifically, when implementing the above steps, the server needs to consider the following aspects: recycling policy of tokens, which refers to how used tokens are put back into the token bucket. Typically, how many tokens should be recovered by each user may be determined based on the number of tokens used by the user, the duration of access, and historical access records. For example, for users with fewer tokens and shorter access times, the system may immediately reclaim all of their tokens; for users with more tokens and longer access time, their tokens can be recycled in stages to avoid over-occupation of resources due to too fast recycling. The release frequency of tokens, which refers to how many tokens each user can release per second. Typically, each user can only release a certain number of tokens for a period of time, so as to prevent a certain user from occupying token bucket resources too much to enable other users to access shared resources. The system can dynamically adjust the release frequency according to the access requirement of each user, the historical access record and other factors so as to improve the resource utilization rate of the system. Lifecycle management of tokens, which refers to how the generation, distribution, use, and reclamation processes of tokens are managed to ensure that each token can function in the intended manner. In the life cycle management process, the problems of state transition, exception handling, log recording and the like of the token need to be noted so as to be capable of timely checking and repairing when the problems occur. And an exception handling mechanism, wherein in the process of recovering the token, network faults, program crashes and other abnormal conditions can occur. In order to avoid that these abnormal conditions affect the normal operation of the system, a corresponding abnormal handling mechanism needs to be designed. For example, in the event of a network failure, the system may cache unrecovered tokens and attempt to recover again after the network recovers; when the program crashes, the system can automatically restart the program and recover the state of the token according to the recorded running log. In sum, the server can effectively manage the tokens in the token bucket by reasonably setting the recovery strategy and the release frequency of the tokens and the lifecycle management and exception handling mechanism, so that the access right of each user can be timely released after the use is finished, and the stability and the safety of the system are ensured.
In a specific embodiment, the process of executing step S105 may specifically include the following steps:
(1) Periodically checking the number of tokens in the token bucket to generate a periodic checking result;
(2) Collecting monitoring indexes of the token bucket, and generating access states of target users according to the monitoring indexes;
(3) And dynamically adjusting the number of tokens of the token bucket and the acquisition rate according to the access state.
Specifically, when implementing the above steps, the server needs to consider the following aspects: the monitoring index of the state of the token bucket refers to a specific index for monitoring various states in the token bucket. For example, indicators of the number of tokens currently available in the token bucket, token generation rate, token consumption rate, waiting queue length, response time, etc. may be monitored. By monitoring the indexes, the problems in the token bucket can be found in time, and corresponding measures are taken for processing. The collection and analysis of monitoring data requires the collection and analysis of data of various indexes when monitoring the state of the token bucket in real time. Typically, data analysis can be performed by means of data science and technology and artificial intelligence algorithms to mine potential problems and anomalies. For example, machine learning algorithms may be used to predict future access volume and resource requirements to adjust the parameters and configuration of the token bucket based on the prediction. The processing mechanism of the abnormal situation may generate some abnormal situations, such as insufficient resources, network faults, program crashes and the like, in the process of monitoring the state of the token bucket. To avoid these anomalies affecting the system, it is necessary to design a corresponding anomaly handling mechanism. For example, in the event of a network failure, the system may automatically switch to run on the standby server; when the resources are insufficient, prompt information can be sent to the user, and the request frequency is reduced so as to save the resources. The log recording and alarming mechanism is used for timely recording the change condition of each index in the process of monitoring the state of the token bucket and carrying out problem investigation and fault diagnosis according to the recorded data. Meanwhile, a corresponding alarm mechanism needs to be set so that developers and system administrators can be notified in time when serious problems occur. For example, various alarm modes such as mail, short message, telephone and the like can be set so that alarm information can be received in time at any time and any place. In sum, the server can effectively monitor the state of the token bucket by reasonably setting monitoring indexes, data analysis, an exception handling mechanism, a log recording and alarming mechanism and the like, so that the system can be ensured to discover and solve the existing problems in time, and the stability and the safety of the system are improved.
The method for controlling the concurrent access of the user in the embodiment of the present invention is described above, and the following describes a device for controlling the concurrent access of the user in the embodiment of the present invention, referring to fig. 5, and one embodiment of the device for controlling the concurrent access of the user in the embodiment of the present invention includes:
the obtaining module 501 is configured to obtain access rights and priorities of a plurality of target users, and perform token allocation on the plurality of target users according to the access rights and priorities, so as to obtain a number of tokens corresponding to each target user;
the caching module 502 is configured to obtain at least one corresponding first token according to the number of tokens corresponding to each target user, cache the at least one first token to a preset token bucket, and set a maximum capacity of the token bucket;
a processing module 503, configured to obtain a target number of at least one second token from the token bucket when the target user accesses a shared resource;
a releasing module 504, configured to release the at least one second token after the target user completes access to the shared resource, and put the at least one second token back into the token bucket;
And the adjusting module 505 is configured to periodically check the number of tokens in the token bucket, and dynamically adjust the number of tokens in the token bucket and the acquisition rate according to the access state of the target user.
The access rights and the priorities of a plurality of target users are obtained through the cooperative cooperation of the components, and the token distribution is carried out on the plurality of target users according to the access rights and the priorities to obtain the number of tokens; acquiring at least one first token according to the number of tokens corresponding to each target user, caching the at least one first token to a preset token bucket, and setting the maximum capacity of the token bucket; when the target user accesses the shared resource, at least one second token with the target number is acquired from the token bucket; after the target user finishes accessing the shared resource, releasing at least one second token, and placing the at least one second token back into the token bucket; the method comprises the steps of periodically checking the number of tokens in a token bucket, dynamically adjusting the number of tokens in the token bucket and the acquisition rate according to the access state. When a user needs to access a shared resource, a sufficient number of tokens must be obtained from the token bucket for access. Because the number of tokens and the acquisition rate of each user are limited, the situation that resources are excessively occupied or a certain user monopolizes resources for a long time can be effectively avoided. The situation that resources are excessively occupied or a certain user monopolizes the resources for a long time can be effectively avoided. Simple realization, high efficiency, difficult occurrence of deadlock and the like. The method supports dynamic adjustment of the number of tokens and the acquisition rate, and adapts to various different user access requirements.
The control device for concurrent user access in the embodiment of the present invention is described in detail above in fig. 5 from the point of view of a modularized functional entity, and the control device for concurrent user access in the embodiment of the present invention is described in detail below from the point of view of hardware processing.
Fig. 6 is a schematic structural diagram of a control device for user concurrent access provided in an embodiment of the present invention, where the control device 600 for user concurrent access may have a relatively large difference due to different configurations or performances, and may include one or more processors (central processing units, CPU) 610 (e.g., one or more processors) and a memory 620, and one or more storage media 630 (e.g., one or more mass storage devices) storing application programs 633 or data 632. Wherein the memory 620 and the storage medium 630 may be transitory or persistent storage. The program stored in the storage medium 630 may include one or more modules (not shown), each of which may include a series of instruction operations in the control device 600 for concurrent access to the user. Still further, the processor 610 may be configured to communicate with the storage medium 630 and execute a series of instruction operations in the storage medium 630 on the control device 600 accessed concurrently by the user.
The control device 600 for concurrent user access may also include one or more power supplies 640, one or more wired or wireless network interfaces 650, one or more input/output interfaces 660, and/or one or more operating systems 631, such as Windows Server, macOS X, unix, linux, freeBSD, and the like. It will be appreciated by those skilled in the art that the configuration of the control device for concurrent user access shown in fig. 6 does not constitute a limitation of the control device for concurrent user access, and may include more or fewer components than shown, or may combine certain components, or may be arranged in a different arrangement of components.
The invention also provides a control device for concurrent access of users, which comprises a memory and a processor, wherein the memory stores computer readable instructions, and the computer readable instructions, when executed by the processor, cause the processor to execute the steps of the control method for concurrent access of users in the above embodiments.
The present invention also provides a computer readable storage medium, which may be a non-volatile computer readable storage medium, or may be a volatile computer readable storage medium, where instructions are stored in the computer readable storage medium, when the instructions are executed on a computer, cause the computer to perform the steps of the control method for concurrent access by the user.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied essentially or in part or all of the technical solution or in part in the form of a software product stored in a storage medium, including instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a read-only memory (ROM), a random access memory (randomacceS memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. The method for controlling the concurrent access of the user is characterized by comprising the following steps of:
obtaining access rights and priorities of a plurality of target users, and carrying out token distribution on the plurality of target users according to the access rights and the priorities to obtain the number of tokens corresponding to each target user;
obtaining at least one corresponding first token according to the number of tokens corresponding to each target user, caching the at least one first token to a preset token bucket, and setting the maximum capacity of the token bucket;
when the target user accesses the shared resource, acquiring at least one second token with a target number from the token bucket;
Releasing the at least one second token after the target user completes access to the shared resource, and placing the at least one second token back into the token bucket;
and periodically checking the number of tokens in the token bucket, and dynamically adjusting the number of tokens in the token bucket and the acquisition rate according to the access state of the target user.
2. The method for controlling concurrent access of users according to claim 1, wherein the steps of obtaining access rights and priorities of a plurality of target users, and performing token allocation on the plurality of target users according to the access rights and priorities, to obtain a number of tokens corresponding to each target user, include:
obtaining access rights and priorities of a plurality of target users, wherein the access rights comprise: low authority and high authority, the priority includes: high priority and low priority;
performing token distribution on the plurality of target users according to the access rights and the priorities;
when the authority of the target user is low and the priority is high, the token quantity of a first preset value is distributed;
and when the authority of the target user is high and the priority is low, allocating the token quantity with a second preset value.
3. The method for controlling concurrent access of users according to claim 1, wherein the obtaining at least one corresponding first token according to the number of tokens corresponding to each target user, caching the at least one first token in a preset token bucket, and setting a maximum capacity of the token bucket includes:
acquiring at least one corresponding first token according to the number of tokens corresponding to each target user;
caching the at least one first token to a preset token bucket, and acquiring the maximum concurrent access amount of the token bucket;
and setting the maximum capacity of the token bucket according to the maximum concurrent access amount.
4. The method for controlling concurrent access of users according to claim 1, wherein the obtaining a target number of at least one second token from the token bucket when the target user accesses the shared resource comprises:
when the target user accesses the shared resource, carrying out token quantity distribution on the target user based on a preset token distribution strategy to obtain a target quantity;
and acquiring the token acquisition frequency of the token bucket, and acquiring at least one second token of the target number from the token bucket according to the token acquisition frequency.
5. The method for controlling concurrent access of users according to claim 1, wherein said releasing the at least one second token and placing the at least one second token back into the token bucket after the target user completes access to the shared resource comprises:
after the target user finishes accessing the shared resource, carrying out recovery strategy matching on the at least one second token to obtain a target recovery strategy;
releasing the at least one second token based on the target reclamation policy;
and carrying out token life cycle management on the at least one second token, and placing the at least one second token back into the token bucket.
6. The method for controlling concurrent access of users according to claim 1, wherein the periodically checking the number of tokens in the token bucket and dynamically adjusting the number of tokens and the acquisition rate of the token bucket according to the access status of the target user comprises:
periodically checking the number of tokens in the token bucket to generate a periodic check result;
collecting monitoring indexes of the token bucket, and generating access states of the target users according to the monitoring indexes;
And dynamically adjusting the number of tokens of the token bucket and the acquisition rate according to the access state.
7. A control device for concurrent access of a user, wherein the control device for concurrent access of a user comprises:
the acquisition module is used for acquiring access rights and priorities of a plurality of target users, and carrying out token distribution on the plurality of target users according to the access rights and the priorities to obtain the number of tokens corresponding to each target user;
the caching module is used for acquiring at least one corresponding first token according to the number of tokens corresponding to each target user, caching the at least one first token to a preset token bucket, and setting the maximum capacity of the token bucket;
a processing module, configured to obtain a target number of at least one second token from the token bucket when the target user accesses the shared resource;
the release module is used for releasing the at least one second token after the target user finishes accessing the shared resource, and placing the at least one second token back into the token bucket;
and the adjusting module is used for periodically checking the number of tokens in the token bucket and dynamically adjusting the number of tokens in the token bucket and the acquisition rate according to the access state of the target user.
8. The apparatus for controlling concurrent access of users according to claim 7, wherein the obtaining module is specifically configured to:
obtaining access rights and priorities of a plurality of target users, wherein the access rights comprise: low authority and high authority, the priority includes: high priority and low priority;
performing token distribution on the plurality of target users according to the access rights and the priorities;
when the authority of the target user is low and the priority is high, the token quantity of a first preset value is distributed;
and when the authority of the target user is high and the priority is low, allocating the token quantity with a second preset value.
9. A control device for concurrent access by a user, the control device for concurrent access by a user comprising: a memory and at least one processor, the memory having instructions stored therein;
the at least one processor invoking the instructions in the memory to cause the control device of the user concurrent access to perform the control method of the user concurrent access of any of claims 1-6.
10. A computer readable storage medium having instructions stored thereon, which when executed by a processor, implement the method of controlling concurrent access by a user according to any of claims 1-6.
CN202310322379.7A 2023-03-29 2023-03-29 Control method and related device for concurrent access of users Pending CN116127494A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310322379.7A CN116127494A (en) 2023-03-29 2023-03-29 Control method and related device for concurrent access of users

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310322379.7A CN116127494A (en) 2023-03-29 2023-03-29 Control method and related device for concurrent access of users

Publications (1)

Publication Number Publication Date
CN116127494A true CN116127494A (en) 2023-05-16

Family

ID=86303022

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310322379.7A Pending CN116127494A (en) 2023-03-29 2023-03-29 Control method and related device for concurrent access of users

Country Status (1)

Country Link
CN (1) CN116127494A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117650950A (en) * 2024-01-30 2024-03-05 浙江省电子信息产品检验研究院(浙江省信息化和工业化融合促进中心) Secure communication method and apparatus

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117650950A (en) * 2024-01-30 2024-03-05 浙江省电子信息产品检验研究院(浙江省信息化和工业化融合促进中心) Secure communication method and apparatus
CN117650950B (en) * 2024-01-30 2024-04-19 浙江省电子信息产品检验研究院(浙江省信息化和工业化融合促进中心) Secure communication method and apparatus

Similar Documents

Publication Publication Date Title
US8886866B2 (en) Optimizing memory management of an application running on a virtual machine
US7516292B2 (en) Method for predicting and avoiding danger in execution environment
EP2633403B1 (en) System and method of active risk management to reduce job de-scheduling probability in computer clusters
US9292448B2 (en) Dynamic sizing of memory caches
US8583756B2 (en) Dynamic configuration and self-tuning of inter-nodal communication resources in a database management system
US9495201B2 (en) Management of bottlenecks in database systems
CN106452818B (en) Resource scheduling method and system
US20060136761A1 (en) System, method and program to automatically adjust allocation of computer resources
CN102063338B (en) Method and device for requesting exclusive resource
JP2012094030A (en) Computer system and processing control method
JPWO2005041038A1 (en) Information system, load control method, load control program, and recording medium
US8914582B1 (en) Systems and methods for pinning content in cache
CN107943559A (en) A kind of big data resource scheduling system and its method
CN110727508A (en) Task scheduling system and scheduling method
CN116127494A (en) Control method and related device for concurrent access of users
CN112100034A (en) Service monitoring method and device
CN114389955B (en) Method for managing heterogeneous resource pool of embedded platform
Zhang et al. Workload consolidation in alibaba clusters: the good, the bad, and the ugly
US9164765B2 (en) Method for managing a processor, lock contention management apparatus, and computer system
US20090187614A1 (en) Managing Dynamically Allocated Memory in a Computer System
JP2006323872A (en) Preliminary resource provision method of logical partition and computer system
CN117149414A (en) Task processing method and device, electronic equipment and readable storage medium
CN103778002A (en) Method and device for recycling critical resources in multi-core system
JP2006524853A (en) System for determining the unreturned standby resource usage rate
CN115422010A (en) Node management method and device in data cluster and storage medium

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