Streamlit app works fine locally but becomes slow after deployment

Welcome to the Streamlit community and thanks for your thoughtful question! :rocket: It’s very common for Streamlit apps to feel slower after deployment, especially on Streamlit Community Cloud, because the cloud environment has stricter resource limits (CPU, RAM) than most local machines. This can lead to longer load times, especially for pages with heavy data processing or large charts. Using st.cache_data is a great start, but there are additional optimizations you can try.

Best practices include: (1) only loading and displaying the data you need (avoid loading entire datasets if possible), (2) pre-processing or filtering data outside the app, (3) using efficient data formats like Parquet instead of CSV/JSON, (4) caching expensive computations and database/API calls with st.cache_data (and setting a TTL if the data updates), and (5) profiling your code to find bottlenecks. For large datasets, Streamlit recommends displaying only subsets and leveraging pagination or filtering. These tips are detailed in the official docs, performance FAQ, and blog posts.

If you’d like a step-by-step breakdown or code examples for any of these areas, just let me know! Also, please share a minimum reproducible example or your repo if you’d like targeted debugging help. Community members—feel free to jump in with your own tips and experiences!

Sources: