Hi, I’m a college student studying data science, and I created a streamlit app in my free time that I am hoping to deploy to large audiences (several hundred simultaneous users). I’ve never used locust before, but I would like to test the app’s ability to host hundreds of concurrent users. The app is a game where the users will be clicking various buttons, triggering a random generator, entering and submitting answers, receiving feedback, and adding results to a leaderboard (sqlite database).
Apologies if this is a silly question, but I can’t seem to find answers anywhere online - how do I use locust to test my app? I have been having trouble finding the right endpoints to test. Or, is there some other way to test my app?
Hey @jasmine2, this sound exciting! I am looking forward to seeing your game
As for testing, you could theoretically try to connect to the Streamlit server’s websocket endpoint (registered in Tornado here) and mimic the browser, e.g. by checking in the browser’s network console the /stream
endpoint and see what messages are sent to/from the Streamlit server. You could for example copy them and hard-code the messages in your test script to mimic button clicks etc. We have done something similar for internal load tests, but it is pretty involved and not necessarily straightforward to set it up.
Another way might be to try out something like playwright, write a test script and start it multiple times to simulate many concurrent clients loading your app and interacting with your app.
In this folder you find some test scripts we are using for e2e tests (not stress tests): streamlit/e2e_playwright at develop · streamlit/streamlit · GitHub
Here the limitating factor likely is how many playwright process you can host simultaneously. If you have access to a server (farm) or Kubernetes cluster, it might be easier to scale it out. On a single machine you probably are not able to simulate hundreds of users as the playwright process itself requires some resources too.
I hope this helps somehow, even though its not a straightforward way.
1 Like