Hi everyone,
I am still learning Streamlit and recently deployed one of my small projects.
Everything works perfectly on my local computer, but after deployment the app feels much slower. Some pages take around 5-10 seconds to load, and charts also take more time than they do locally.
I already tried using st.cache_data for some functions and reduced a few unnecessary calculations, but I still don’t see much improvement.
Is this something normal after deployment, or am I missing some important optimization?
If anyone has experienced the same issue, I would really appreciate your suggestions or best practices.
Thanks in advance!
Welcome to the Streamlit community and thanks for your thoughtful question!
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: