locustio / locust

Write scalable load tests in plain Python 🚗💨
https://locust.cloud
MIT License
24.72k stars 2.96k forks source link

How to use Locust for UI performance testing? #1184

Closed mektebi closed 4 years ago

mektebi commented 4 years ago

Hi,

I would like to use Locust for UI performance testing. How to use Locust for UI performance testing? How can I get the loading time of the HTML elements?

Thanks

cyberw commented 4 years ago

Have a look at the webdriver locust class in https://github.com/SvenskaSpel/locust-plugins

Right now it doesnt actually measure the loading time, but with some knowledge of selenium you could be able to log that. Feedback/PRs are very welcome :)

mektebi commented 4 years ago

@cyberw I'll appreciate it if you could log measuring the loading time

cyberw commented 4 years ago

Sorry, I’m not using any webdriver tests right now so I wont have time to do it (at least not any time soon)

heyman commented 4 years ago

@mhdmaktabi I wouldn't expect Locust to work well for measuring UI performance. It's not what it was built for. There are good tools for that built into both Firefox and Chrome.

cyberw commented 4 years ago

What I was thinking about was using Chrome's own measurements, getting them from selenium and then logging them to locust.

Using something like this to start with https://www.lambdatest.com/blog/how-to-measure-page-load-times-with-selenium/

heyman commented 4 years ago

I don't really see the point of doing this in Locust. You won't be able to create much load if every single Locust user needs to create and control a whole Browser instance (each one using significant amount of memory and CPU).

It's two fundamentally different things to measure the client side performance of a website, and load test a server side app.

cyberw commented 4 years ago

Headless chrome is quite efficient nowadays. I've been able to simulate 50 concurrent users doing maybe 20 page loads/s (triggering around 500 http requests/s + some websockets, etc) on my laptop.

Using a full browser is useful in a lot of cases, mainly because it is less prone to miss some types of issues (like a change in the front end/client side javascript causing a backend api being hit more than before), but also to complement a "normal" test to give "real" user-perceived load times.

But on the other hand, selenium is very unstable, particularly under high load, so you get some other problems instead :)

heyman commented 4 years ago

Sorry you'll have to google that yourself. Good luck!

mektebi commented 4 years ago

Hi @cyberw

I couldn't run more than 20 headless chrome. how did you run 50 headless chrome? I need to simulate 500 users to test UI performance under load.

cyberw commented 4 years ago

My laptop is relatively high performance, maybe 20 is all you'll be able to get. It probably depends a lot on the complexity of the pages you are loading.

500 will not be possible without running distributed with a bunch of really massive load generators.