Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added code to throttle high cpu usage. #1187

Closed
wants to merge 1 commit into from

Conversation

xirtameht
Copy link

Description

Added a HighCycleThrottle class which can be used by defining USE_EPOLL_SELECTOR_FIX as an environment variable. When this variable is defined, the HighCycleThrottle class will introduce a 1 ms delay when high cycling is detected and remove the 1 ms delay when running normal.

Related Issue

This is related to issue 896.

Motivation and Context

When running the WebSocketServer on AWS, we see times when the CPU Load goes to 100% and stays there for about 2 hours. This is caused when the selector.select() quits blocking causing excessive cycles through the code. After about 2 hours the selector.select() will start blocking again and the CPU load returns to normal.

CPU only goes to 20% instead of 100% with these code changes.
image

Logging issue:
image
Issue cleared:
image

How Has This Been Tested?

We ran this code on AWS until we saw the condition reported in the logs, observed the throttling, and saw the condition clear. This code has been running several weeks without any issues.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@xirtameht xirtameht closed this Oct 26, 2021
@xirtameht
Copy link
Author

We opted for detecting os instead of using env variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant