question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

100% CPU usage when working with a high number of workspaces

See original GitHub issue

We noticed a flaw in the Java SDK. When interacting with a large number of workspaces, the rate-limiting algorithm consume 100% CPU. After profiling our server we noticed that 96% of the CPU is spent on BaseMemoryMetricsDataStore$MaintenanceJob.run(). Particularly the methods updateCurrentQueueSize and updateNumberOfLastMinuteRequests. I believe this is because our app deals with a large number of workspaces (~8,000) and the maintenance job runs every 50ms.

As a temporary solution, we are considering turning off stats on MethodConfig.

Any other suggestion to mitigate/fix the issue?

The Slack SDK version

1.18.0

Java Runtime version

(Paste the output of java -version)

OS info

Linux

Steps to reproduce:

Create an app that unfurl links from ~8,000 workspaces.

Expected result:

Reasonable CPU usage.

Actual result:

100% CPU usage after running for 16h. The CPU usage progressively increases until the server restarts.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sidneyamanicommented, Mar 2, 2022

Hey Kazuhiro,

Thanks so much for the fix. We’ve been running it in production for a week and the CPU is sitting around 10% now. The CPU still increases linearly but the slope is a lot gentler. We haven’t reenabled stats yet though. I’ll let you know if reenabling stats causes leads to any unexpected behaviour.

1reaction
seratchcommented, Feb 17, 2022

Hi @sidneyamani, I’ve merged the PR #934 and released a new version - v1.19.0 onto the Maven Central repository.

I hope the version works very well for your app. Also, if the default configuration isn’t great enough for you, you can adjust the behavior by:

  • Set rateLimiterBackgroundJobIntervalMillis to a longer value than 1,000 milliseconds (the default)
  • statsEnabled: false to either SlackConfig or MethodsConfig etc.

Refer to the release note for more details. https://github.com/slackapi/java-slack-sdk/releases/tag/v1.19.0

The first one won’t cause any big problem. The only downside would be the rate limiter in this SDK can be more conservative on the intervals between the same API calls. As for the second one, with this way, your app will be responsible for handling rate-limited error patterns.

Thanks again for reporting this issue. I hope the fix I applied this time helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[SOLVED] How to fix CPU usage 100% issue - Driver Easy
A complete guide to troubleshooting high CPU usage issue on Windows 10 · Try these fixes · Fix potential Windows stability issues ·...
Read more >
How to Fix High CPU Usage - Intel
1. Reboot. First step: save your work and restart your PC. “Turn it off and on again” is classic troubleshooting advice for a...
Read more >
How to Fix High CPU Usage in Windows - AVG
5 ways to fix high CPU usage · 1. Identify the process that's causing 100% CPU usage · 2. Close unnecessary applications or...
Read more >
How Fix High CPU Usage 100% on Windows 10 (steps that ...
Often times users experience see 100 percent or high CPU usage in the Task Manager. This is somewhat similar to the high disk...
Read more >
Troubleshoot a Windows WorkSpace that is marked as ...
High CPU usage on the WorkSpace. The agent or service that responds to the WorkSpaces service isn't running. The computer name of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found