A method and device for limiting traffic
The embodiment of the invention discloses a method and a device for limiting traffic. A specific embodiment of the method comprises the following steps: for a thread in a thread pool, receiving a request sent by the thread; obtaining state data of the thread, the state data comprising an initializat...
Gespeichert in:
1. Verfasser: | |
---|---|
Format: | Patent |
Sprache: | chi ; eng |
Schlagworte: | |
Online-Zugang: | Volltext bestellen |
Tags: |
Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
|
Zusammenfassung: | The embodiment of the invention discloses a method and a device for limiting traffic. A specific embodiment of the method comprises the following steps: for a thread in a thread pool, receiving a request sent by the thread; obtaining state data of the thread, the state data comprising an initialization timestamp in a flow control period, a request number of released tokens which are not consumed and a number of global consumed tokens; based on the state data of the thread, determining whether to release in a batch consumption token mode; and in response to determining to release in a batch consumption token mode, releasing a request sent by the thread to the cloud for processing. According to the embodiment, a batch token consumption mode is adopted to reduce the competitive relationship between threads for consuming tokens, the phenomenon that a CPU waits or idles is effectively avoided, and the waste of CPU resources is reduced. Meanwhile, in a high-concurrency scene, the performance cost caused by current |
---|