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

Issue of 100% CPU usage when closing WebSocket connections. #2516

Closed
2 tasks done
Maestro-III opened this issue Dec 14, 2023 · 0 comments
Closed
2 tasks done

Issue of 100% CPU usage when closing WebSocket connections. #2516

Maestro-III opened this issue Dec 14, 2023 · 0 comments
Labels

Comments

@Maestro-III
Copy link

Maestro-III commented Dec 14, 2023

Prerequisites

Description

Custom WebSocket stress test script, environment: 20 cores, 32GB RAM, 1000M bandwidth. Run the script in this environment. Only log in one user and do not send messages, just need to stay online. When clicking STOP on the web UI interface, after 20-30 seconds, a warning appears: 'CPU usage above 90%!'. If using --headless, this problem obviously doesn't occur. However, consider a situation where, during automated loading, this might be unfriendly.

Command line

locust -f mylocustfile.py

Locustfile contents

#!/usr/bin/env python
# -*- coding: utf-8 -*-



class WebSocketUser(HttpUser):
    wait_time = between(1, 2) 

    def on_message(self, ws, message):

    @staticmethod
    def on_close(ws, close_status_code, close_msg):
    
    @staticmethod
    def on_open(ws):
         

    @task
    def pft(self):
        ws = websocket.WebSocketApp('wss:xxxxxxxxxxxxxxxxx&transport=websocket',
                                    on_message=self.on_message,
                                    on_error=self.on_error,
                                    on_close=self.on_close)
        ws.on_open = self.on_open
        self.run_forever_with_retry(ws)
        self.active_websockets.append(ws)

Python version

3.9.12

Locust version

2.20.0

Operating system

Linux \ mac

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

No branches or pull requests

1 participant