The invention discloses a
dynamic load balancing method and
system based on session
granularity and bit
mask mapping. The method comprises the following steps: S100, initializing a
system; s200,
thread management: adding a session created by an application to a task thread; s300, load monitoring: starting a
timer at regular time, collecting load data of each thread, detecting whether a thread load exceeds a preset threshold value or not, if yes, triggering a balancing decision, and if not, directly triggering a session execution operation; s400, equilibrium
decision making: searching for the most idle target migration task, and selecting a migration candidate session; s500, migration execution: removing from the source task, adding to the target task, and updating the bit
mask state of the session; s600, session execution: each task thread executes the session allocated to the task thread according to the
bitmap state in the main loop of the task thread, updates the
execution time and the number of times, and regularly checks the use condition of the stack; and S700, the
system exits. According to the invention, the problems of increased
response delay, insufficient adaptability, unstable system and the like caused by resource competition during session concurrence can be solved.