Rerunning the entire script makes demos fast, but state and permissions are its weak points—three signals tell you it's time to switch architectures.

Key Takeaways
- Streamlit reruns the entire script whenever the UI needs to update, so demos come together quickly—but that's exactly why complex apps hit a ceiling fast
- st.cache_data lets slow data-loading functions avoid rerunning on every click, while Session State is wiped as soon as the user refreshes the tab
- st.login provides authentication via OIDC but not authorization; once enterprise customers need role-based access control, it's time to switch architectures
According to the official documentation, whenever the UI needs to update, Streamlit reruns the entire Python script from the first line to the last. This design is what lets you build a customer demo in an afternoon—and it's also one of the reasons the app hits a ceiling as soon as it needs to do more than display data.
For a Forward Deployed Engineer (FDE), this isn't academic. On-site with a customer, what you need most in the first week is often an interface running on real data that the business side can click around and give feedback on. Understanding what Streamlit is good at and where it breaks down is what lets you make promises to customers you can actually keep.
What was it built for?
Streamlit describes itself as a faster way to build and share data apps. Snowflake announced its intent to acquire Streamlit on March 2, 2022, with the press release calling it an open-source framework that helps developers and data scientists build and share data apps.
The words "data" and "share" precisely define its scope. No frontend to write, no API to set up, no routing to worry about. You write a Python script that reads data and draws a few widgets, and that script is the app itself.
The rerun model: why demos are fast and apps are slow
The Streamlit documentation is explicit: by default, the app reruns every time the user interacts with a widget. This makes the code easy to understand—no tangled callbacks, no UI state to synchronize. Read the script top to bottom and you know what the interface will display.
The cost is slow functions. Imagine a demo for a logistics company where the function that reads the orders file takes about 8 seconds. If the customer changes the filters ten times during the meeting, that's ten reruns—roughly 80 seconds staring at a loading spinner, enough to derail the demo's rhythm.
Streamlit provides caching precisely for this. The documentation notes that without caching, slow functions execute over and over, slowing down the app. For functions that return data, it recommends using
st.cache_data
:
import streamlit as st
import pandas as pd
@st.cache_data
def load_orders(path):
return pd.read_csv(path) # 很慢,但只有第一次真正执行
orders = load_orders("orders_sample.csv")
if "notes" not in st.session_state:
st.session_state["notes"] = [] # 用户在本次会话中的笔记In the logistics example, those 8 seconds are now paid only once; the next nine filter changes read the data from cache. One more thing: according to the documentation,
st.cache_data
every call to the function creates a fresh copy of the data.
This means modifying a DataFrame in your script won't corrupt the cache, but when the table is very large, the copying itself consumes resources.
The first thing to do in the customer's office after opening your laptop: before writing any widgets, wrap every data-loading function in
@st.cache_data
。
Three signals it's time to switch architectures
The first signal is state. Session State stores data across reruns; it's bound to each user session and not shared between users. The documentation is blunt: close or refresh the tab, and everything in Session State is gone.
For a demo, that's acceptable. But if the customer starts asking for multi-step workflows—say, an analyst approves a request in step one and a team lead reviews it in step two—one press of F5 can wipe out all the work. At that point you need persistent storage and an architecture that can actually manage state.
The second signal is access control. Streamlit has built-in
st.login
authentication based on OIDC, but the documentation is clear: OIDC supports authentication, not authorization. Knowing who the user is and knowing what the user can see are two different things; enterprise customers who need role-based access control are asking exactly the second question.
The third signal comes from the rerun model itself. Back to the logistics example: suppose the customer wants to select an order in the table, open a form to edit the shipping address, then return to the table with the filters unchanged.
Since every click reruns the entire script, you have to store the selected order, the filters, and the half-filled form in Session State yourself, then read them back at the start of every run.
Each additional sub-view adds several Session State keys that must stay consistent with each other; if even one key is off, the table shows the wrong order. When most of your time goes into keeping UI state consistent rather than building the features the customer needs, Streamlit is no longer the right choice.
Sharing is fast, but be careful with customer data
Streamlit Community Cloud lets you create, deploy, and manage apps for free from a GitHub repository. It's very convenient for internal demos or portfolios: push your code and you get a link you can send to others.
When customer data is involved, this should be a question you confirm with the customer first, not the default approach. Build public demos with fake data of the same structure, and run real data only in environments the customer has approved.
What to learn first, and how to present it when job hunting
Learn in this order: the rerun model, then
st.cache_data
, then Session State, and finally
st.login
and its limitations. Mastering these four things is enough to build a demo and to explain to a customer why the demo isn't yet the product.
Don't just write "familiar with Streamlit" on your resume. Instead, write something like: built a prototype on the customer's sample data in one day, agreed with the customer on the conditions for switching architectures, then migrated to a system with persistent state and authorization. The goal is to show the reader you can do both: deliver demos fast, and know when to stop.
A one-hour exercise: find the breaking points before the customer does
Take a fake orders CSV file and build a table with filters, recording the time for each filter change with the file-reading function
@st.cache_data
before and after adding caching. Then add order selection and an address-editing form, both stored in Session State. Finally, press F5 and note what disappears.
This exercise helps you avoid three common mistakes in first demos. One: forgetting to add caching, so the customer waits on every click. Two: putting the customer's real data on a public app because deployment is so easy. Three: seeing
st.login
and promising role-based access control on the spot.
An afternoon with Streamlit can win a customer's trust. Whether you keep that trust depends on telling the customer on demo day itself when it will be replaced by something else.
Was this article helpful?
Thanks for your feedback!