st.session_state memory consumption during multi-user scaling
0 reputation · 10 Jan 2024, 22:42 UTC
Streamlit utilizes st.session_state to persist user-specific data, such as large DataFrames or machine learning model weights, across script reruns. Because this state is stored on the server side, each active user session consumes a portion of the available system RAM.
In deployments with a high volume of concurrent users or applications handling substantial datasets per session, there is a risk of server-side memory exhaustion. While the state is cleared upon browser refresh or session timeout, the immediate impact on resource allocation during peak usage remains a design concern.
- What are the recommended strategies for managing the memory footprint of
st.session_statewhen storing large objects? - Are there documented mechanisms to implement custom expiration policies or memory limits for individual session states?