How to test UI performance with n users?

I am using Streamlit for a while now and love this library, thanks.

I have an application that displays Plotly graphs with 4 filters. It is deployed in Streamlit Cloud (but could be AWS, etc.)
I have two questions related to performance:

  1. I want to test UI performance with, say, 10/100/1000 users so that I could know how many servers will I need.
    One idea is to test only backend treatment (Pandas), but this is not very realistic because I want the Streamlit cache to be part of the game.
    I tried load testing, i.e. to send a lot of HTTP requests with Locust (I could use Gatling or Jmeter) but it is not what I want because I want users to use different filter buttons so that I could know how the cache scales.
    Another idea would be to mix UI testing (Selenium) with load testing (Jmeter, etc.) which I did, but this is not very realistic because I popped all of these users on my local machine, and it is very memory consuming… One realistic way would be to perform this on the cloud with spread users, for example with Blazemeter.
    Any idea on how to test UI performance with n users?

  2. Related to the previous question; I can’t find how the data is sent from the server to the client. In my case: I have 4 filters: if I understand well, each time a combo of these 4 filters is triggered, the data is filtered on server side (or already in cache if the combo exists) and only the data diff to be displayed in the graphs is sent to the client, in a JSON compressed format. But I can’t see this anywhere in the HTTP responses… Or maybe data is stored on the client-side also? I feel I am missing something.
    How the data is sent from the server to the client?

Thanks a lot :slight_smile:

1 Like


Hi @Aurelien_Massiot, welcome to the Streamlit community!

In this case, you have hit on a question that is pretty difficult to answer. The standard answer would be to use a framework like selenium, which allows you to automate using a headless browser to do various things. In theory, you could have multiple selenium sessions clicking on input widgets for various cases, and then you could ramp up multiple instances and watch the performance characteristics of the Streamlit app.

Of course, that’s easier said than done. Packages like seleniumbase give you a way to write these sorts of tests in Python, but you still have to figure out which inputs to change and how to parallelize the tests you’re doing. While it’s not exactly the question you are asking, I have written a blog post to show how to use seleniumbase with Streamlit for visual testing; extending this example to change specific inputs and parallelize workers to test UI performance should be possible.


1 Like

Hello @randyzwitch ,
Thanks for your answer! Indeed I already perform Selenium tests for UI testing.
Ok so that’s not that easy to perform this kind of UI-load testing :stuck_out_tongue:

I see that data is sent using sockets - maybe there is a way to send data via sockets and load test this way?

1 Like

Don’t know if there’s a way to test using sockets, but if you figure it out, please come back and let us know!