I have built a multipage streamlit app that pulls data from SQL server. The app works very fine on my local system and was successfully deployed on streamlit cloud. However, after deployment, the app fails after few minutes of usage. Find the error page below;
and here is the link to my github repo for the app;
Please I will appreciate any quick help with this issue, I have added cache and set the data run from SQL to every 24hours using the @st.experimental_memo(ttl) to avoid data the app.
I have also copied a part of the log below, the error i am getting does not contain any information that points in any direction as to what could be responsible for this.
/***/home/appuser/venv/lib/python3.9/site-packages/pandas/io/sql.py:761: UserWarning: pandas only support SQLAlchemy connectable(engine/connection) ordatabase string URI or sqlite3 DBAPI2 connectionother DBAPI2 objects are not tested, please consider using SQLAlchemy
warnings.warn(
/home/appuser/venv/lib/python3.9/site-packages/pandas/io/sql.py:761: UserWarning: pandas only support SQLAlchemy connectable(engine/connection) ordatabase string URI or sqlite3 DBAPI2 connectionother DBAPI2 objects are not tested, please consider using SQLAlchemy
warnings.warn(
[11:47:59] Streamlit server consistently failed status checks
[11:47:59] Please fix the errors, push an update to the git repo, or reboot the app. ***/
Upgrade to a newer version of streamlit and use st.cache_data and st.cache_resource rather than st.experimental_memo and st.cache. I don’t know if st.cache is causing the issue, but it seems like it might be.
Try setting showErrorDetails = true in your config for testing purposes, to see if that shows any useful details about what is actually failing.
Try to limit to only cache the functions which are actually returning either a reusable resource like a database connection, or are actually returning data.
Do you know how much data you are typically loading from the database?
I have updated my streamit to the latest version 1.20.0, and I have been able to use cache_data. But I noticed the app crashes anytime more than one user attempt to use the app. This error persist;
Thank you for your help so far, I have read all these documentation and it still does not provide any new information to help resolve this error.
I will really appreciate if someone can help look through my code and identify what could be responsible for the app crashing. I need to at least know what’s causing the error so I can debug appropriately.
I can confirm that the app works fine with just 2 users, the app crashes once a third user attempt to use the app. Could this be related to resource limit on the streamlit app??
I just need to be certain if it’s a resource limit issue or if there are some adjustments I can do to my algorithm to fix this issue. Please help.
I have confirmed that the problem with the app crashing with multiple users is because I did not not use session_state to ensure that the computations are not calculated with each run. I have been trying to add session_state to my code but I keep getting KeyError: 'st.session_state has no key ".
Can anyone help to add session_state to my code ??? Please
The typical pattern with session_state is something like this:
Initialize the entry in st.session_state to some default value, if it hasn’t been set yet:
if "some_key" not in st.session_state:
st.session_state["some_key"] = None # Or whatever default value you want
Update the session state if something happens
if user_submitted_thing is not None:
st.session_state["some_key"] = user_submitted_thing
Use that value from session state
data = get_data(thing=st.session_state["some_key"])
The order and details of 2 and 3 will vary, but typically those are the three thing you will do – first initialize the value, update it in certain conditions, and use the value directly from session state
Just following up with this thread as I think a current problem I have might be somewhat relevant to this thread.
I have an app that has been working fine for a while now, except it has been needing to be rebooted frequently, ever since I made one change to a line that filtered the data, so that less data was being excluded. The app still functions as it should besides the semi-frequent crashes (once to a few times per day).
I am wondering what might be the cause of this? Is there a certain size limit to data that makes the app reboot? To me it seems unlikely to be this because it works fine most of the time, but curious what some possible explanations might be.
@Tommy_Ruppert The issue with my app most likely was due to the amount of data i was pulling and it appears the streamlit cloud has a resource limitation in this regard. I deployed my app on the azure app service instead of the streamlit cloud and since then, my app has been working very fine even with multiple users. I hope this response helps.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.