Set limit of active/simultaneous users


I am working on a Streamlit app which (from time to time) runs some expensive computations. Since the computation runs on the GPU and the memory is quite limited I’m looking for a way to limit the number of “active” (i.e. simultaneous) users to one.

The definition of “active” can be quite flexible here, depending on what is possible, i.e. it could be defined as “one user is logged in” or “one user has the application open”. Any ideas how this could be achieved easily?

1 Like

Hey @mibaumgartner,

If you’re hosting your app with Streamlit Community Cloud, you might consider using st.experimental_user in conjunction with session state – that said, there isn’t a built-in way to do this, so I can’t guarantee that this would work perfectly for this specific use case, but I think that would probably be your best bet.

1 Like

Thanks for the quick answer, I’ll give it a try!

Hello, I was just wondering if there are any updates on this topic? Also what if we are using EC2 and not streamlit cloud .

There still isn’t a built-in way to handle this. If you are using a service other than Streamlit Community Cloud, you can refer to that service’s documentation on how to set concurrency limits.