Add Load Tests Using Locust
We are looking to add load tests to Reflex, to show how many connections we can handle and what this does cpu utilization. Will use this library https://github.com/locustio/locust. This will probably need some plugin like https://github.com/SvenskaSpel/locust-plugins/blob/master/examples/socketio_ex.py to handle websocket interactions since it's all pretty vanilla http out of the box.
Some things we want to test for:
- idle websocket connections
- rps events handled (no state modification)
- rps state modifications with delta (probably router_data)
- rps (small) substate modifications
These probably need to be with and without redis (but that shouldn't affect how the tests are written)
Hi, I would love to work on this issue. Could you please assign it to me?
Yes will do!
Hi, I would love to work on this issue. Could you please assign it to me?
Hi are you still working on this ticket another contributors is interested so please let me know, if not I will un assign and hand it over.
Hey Alex, you can assign this issue to other contributors. Thanks!
Hi @Alek99, can I take this up?
Hi @Alek99 I was looking at how we could go about doing this. I came up with two ways to write these tests.
- Write loadtest cases as tasklists with before_start methods in locust which will setup the backend using app harness and then carry out the load tests.
- The second option is to spin up an example reflex app and then execute our load tests manually.
The second way is faster and much simpler. So I will prefer going ahead with that approach as of now. Will try the first approach, once we are done with all our test cases. RFC on this.
Sure I'll assign it to you, yes second approach sounds good!
@Alek99 I have created load tests for reflex by using the reflex init command to generate a sandbox application. Requesting you for comments on the approach or the code style.
Please note that the PR is still WIP. There are still a few small changes pending to make it compatible with our ruff linter config.