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.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.