Single-thread CPU pinning causes RabbitMQ connection timeout
warningResource ContentionUpdated Dec 28, 2021(via Exa)
How to detect:
Even with a single worker thread, if the thread pins the CPU for longer than the RabbitMQ heartbeat interval, the connection can time out and close. This depends on kernel thread scheduling and Python's sys.setswitchinterval. If the pinned thread is picked repeatedly on context switch, it prevents heartbeat communication.
Recommended action:
1) Increase RabbitMQ heartbeat timeout to accommodate longer CPU-bound operations. 2) Ensure no single thread can pin the CPU for longer than the heartbeat timeout by refactoring code to introduce explicit pauses. 3) Lower sys.setswitchinterval to increase thread switching frequency and prevent prolonged CPU pinning.