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

Number of requests lower than expected in web UI #3000

Closed
2 tasks done
michie1 opened this issue Nov 28, 2024 · 5 comments · Fixed by #3001
Closed
2 tasks done

Number of requests lower than expected in web UI #3000

michie1 opened this issue Nov 28, 2024 · 5 comments · Fixed by #3001
Labels

Comments

@michie1
Copy link

michie1 commented Nov 28, 2024

Prerequisites

Description

I have a test.js file which counts the amount of requests processed. I start the server with node test.js. A delay of 1 second for each response is added.

const http = require('http');

let requestCount = 0;

const server = http.createServer((req, res) => {
  setTimeout(() => {
    console.log(requestCount);
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end(`Request count: ${requestCount}`);
    requestCount++; // Increment the request counter
  }, 1000);
});

const PORT = 3000;
server.listen(PORT, () => {
    console.log(`Server running at http://localhost:${PORT}`);
});

When I start locust with only a single master node with one user, within 17 requests the amount differs between what Locust is saying (15) in the web UI and what I see in the web server logs (17). Even after clicking the "Stop" button and waiting several seconds the number in the UI stays on 15. When running --headless the number is correct.

Command line

locust

Locustfile contents

from locust import HttpUser, task


class HelloWorldUser(HttpUser):
    @task
    def hello_world(self):
        self.client.get("/")


### Python version

3.10

### Locust version

2.32.2

### Operating system

Ubuntu 22.04.5 WSL
@michie1 michie1 added the bug label Nov 28, 2024
@cyberw
Copy link
Collaborator

cyberw commented Nov 28, 2024

Can you add a log statement (or just a print statement) before and after every request made?

While it isnt impossible that there's something wrong with locust this is kind of a basic feature, so I'd be real suprised if it is a locust issue - perhaps the responses just arent reaching locust.

@michie1
Copy link
Author

michie1 commented Nov 28, 2024

image
You can see after hitting the "Stop button" nodejs received request 16, but the Locust UI shows 15 and it should show 17 (because I start with i = 0 & requestCount = 0).

from locust import HttpUser, task

i = 0


class HelloWorldUser(HttpUser):
    @task
    def hello_world(self):
        global i
        print("before", i)
        self.client.get("/")
        print("after", i)
        i += 1

@cyberw
Copy link
Collaborator

cyberw commented Nov 28, 2024

I can reproduce this too! Maybe the UI stops updating too early. @andrewbaldwin44 can you maybe have a look (dont wanna interrupt what you're doing right now, but when you have the time)

@michie1 michie1 changed the title Number of requests lower then expected in web UI Number of requests lower than expected in web UI Nov 28, 2024
@michie1
Copy link
Author

michie1 commented Dec 2, 2024

Confirmed it works for a single worker node, but not for multiple. I'll raise a new issue.

@andrewbaldwin44
Copy link
Collaborator

Interesting, I did a few tests and I couldn't reproduce any issues with multiple workers. But definitely open an issue and I will take a look!

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

Successfully merging a pull request may close this issue.

3 participants