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.

Locust docker version 1.4.0 using 100% CPU on idle

See original GitHub issue

Test environment: Ubuntu 18.04.1 Docker version 19.03.6

Environment stays the same only the docker image version is changed. Running the docker container with the same locustifle.py which is an example from https://hub.docker.com/r/locustio/locust

from locust import HttpUser, task

class QuickstartUser(HttpUser):
    def on_start(self):
        self.client.post
("/login", json={"username":"foo", "password":"bar"})

    @task
    def hello_world(self):
        self.client.get("/hello")
        self.client.get("/world")

    @task(3)
    def view_item(self):
        for item_id in range(10):
            self.client.get(f"/item?id={item_id}", name="/item")

When running locustio/locust version 1.3.2 the idle CPU load is around 0.0% and stable.

Running locustio/locust version 1.4.0 the idle CPU load goes up to 100.0% at once when the container is started and stays between 96.7% and 100.0%.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
cyberwcommented, Nov 16, 2020

Aha, the problem is that when running docker, there is no interactive terminal. Add -it to your docker run command as a temp workaround.

1reaction
cyberwcommented, Nov 16, 2020

I can reproduce this in docker/Ubuntu and it also prints the following exception when shutting down. I’m 99% confident this is an issue with keyboard input (on Ubuntu, not MacOS, CentOS or Windows), not with wait times.

I will check with @DennisKrone if he can fix it.

docker run -p 8089:8089 -v $PWD:/mnt/locust locustio/locust -f /mnt/locust/quickstart.py
[2020-11-16 12:10:57,399] c07ede557d74/INFO/locust.main: Starting web interface at http://0.0.0.0:8089 (accepting connections from all network interfaces)
[2020-11-16 12:10:57,412] c07ede557d74/INFO/locust.main: Starting Locust 1.4.0
[2020-11-16 12:11:02,415] c07ede557d74/WARNING/root: CPU usage above 90%! This may constrain your throughput and may even give inconsistent response time measurements! See https://docs.locust.io/en/stable/running-locust-distributed.html for how to distribute the load over multiple CPU cores or machines
^CTraceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/locust/input_events.py", line 88, in input_listener_func
    input = poller.poll()
  File "/usr/local/lib/python3.8/site-packages/locust/input_events.py", line 36, in poll
    return sys.stdin.read(1)
  File "/usr/local/lib/python3.8/codecs.py", line 319, in decode
    def decode(self, input, final=False):
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
  File "/usr/local/lib/python3.8/site-packages/locust/input_events.py", line 98, in input_listener_func
    poller.cleanup()
  File "/usr/local/lib/python3.8/site-packages/locust/input_events.py", line 31, in cleanup
    termios.tcsetattr(self.stdin, termios.TCSANOW, self.tattr)
AttributeError: 'UnixKeyPoller' object has no attribute 'tattr'
2020-11-16T12:11:07Z <Greenlet at 0x7fcc45787e10: input_listener_func> failed with AttributeError

[2020-11-16 12:11:07,514] c07ede557d74/CRITICAL/locust.main: Unhandled exception in greenlet: <Greenlet at 0x7fcc45787e10: input_listener_func>
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/locust/input_events.py", line 88, in input_listener_func
    input = poller.poll()
  File "/usr/local/lib/python3.8/site-packages/locust/input_events.py", line 36, in poll
    return sys.stdin.read(1)
  File "/usr/local/lib/python3.8/codecs.py", line 319, in decode
    def decode(self, input, final=False):
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
  File "/usr/local/lib/python3.8/site-packages/locust/input_events.py", line 98, in input_listener_func
    poller.cleanup()
  File "/usr/local/lib/python3.8/site-packages/locust/input_events.py", line 31, in cleanup
    termios.tcsetattr(self.stdin, termios.TCSANOW, self.tattr)
AttributeError: 'UnixKeyPoller' object has no attribute 'tattr'
KeyboardInterrupt
2020-11-16T12:11:07Z
[2020-11-16 12:11:07,527] c07ede557d74/INFO/locust.main: Running teardowns...
[2020-11-16 12:11:07,527] c07ede557d74/INFO/locust.main: Shutting down (exit code 2), bye.
[2020-11-16 12:11:07,527] c07ede557d74/INFO/locust.main: Cleaning up runner...
[2020-11-16 12:11:07,528] c07ede557d74/WARNING/locust.runners: CPU usage was too high at some point during the test! See https://docs.locust.io/en/stable/running-locust-distributed.html for how to distribute the load over multiple CPU cores or machines
Read more comments on GitHub >

github_iconTop Results From Across the Web

Idle docker using 100% cpu
When idle cpu usage should remain low. Actual behavior. Occasionally when idle I notice that see my cpu go to 100% (I notice...
Read more >
Changelog Highlights — Locust 1.4.2 documentation
Fix 100% cpu usage when running in docker/non-tty terminal ... 0.13.4¶. Identical to previous version, but now built & deployed to Pypi using...
Read more >
Docker Python Interpreter Extremely High CPU at Idle
After moving to the 2020.2 EAP any project I use a Docker python interpreter keeps 300+% CPU usage at all times. If I...
Read more >
Setting the right requests and limits in Kubernetes - Learnk8s
How can you check the actual CPU and memory usage with the metrics server? Since the busybox container is idle, let's artificially generate...
Read more >
Run A Custom Code With Locust Performance Testing ...
Generating a custom load shape Extending Locust using event hooks. ... Locust docker version 1.4.0 using 100% CPU on idle #1629. Merged pull...
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