The invention provides an efficient task scheduling method based on a Golang
coroutine and multiple channels. The efficient task scheduling method comprises the following steps: constructing a three-level
channel scheduling architecture; the method comprises the following steps of: defining a scheduler structural body; priority
processing and
dynamic load balancing of instructions are achieved through a three-level gradient buffering mechanism; calculating the number of required working coroutines in real time by using a
dynamic capacity expansion and contraction
algorithm model, and adjusting the size of a
coroutine pool in real time; calculating
timeout time by utilizing a dynamic
timeout formula, and automatically triggering a
deadlock prevention mechanism when task
execution time exceeds a calculated value; a fault-tolerant scheduling strategy is adopted, a complex task is decomposed into a plurality of independent fragments which can be processed in parallel, and
processing results of the fragments are submitted in a result channel non-blocking mode; and meanwhile, when a first effective result is detected by using a quick
response strategy, immediately cancelling the remaining unprocessed fragments and returning the result. Through the technical means based on Golang coroutines and multiple channels, efficient, low-
delay and high-
concurrency task scheduling is achieved, and the requirements of high-
concurrency and high-real-time application scenes are met.