Full script run times are very inconsistant

Summary

Hello,

Greetings from HelloFresh Berlin. I hope this message finds you well.

We are currently facing some challenges with the performance of our Streamlit app and were hoping to seek your valuable support and insights from the Streamlit forum.

Our app’s running time is displaying significant inconsistency with noticeable variations during each run. This complexity arises from the deployment of our app on AWS/Docker. We have thoughtfully integrated all functionalities by utilizing a Python wheel stored within the Docker image.

Additionally, we have observed a lag before the app initializes and starts running. The time it takes to populate fields and charts upon startup is also longer than desired.
Moreover, when modifications are made to widget values, there is a delay of a couple of seconds before the app resumes running.

We have particularly noticed that side tab widgets tend to load rather slowly. Interestingly, the subsequent run change how widget looks , then the widget reappears
this happen when you switch between side tabs also

Another observation pertains to the app’s behavior with multiple side tabs. Regrettably, the app does not recall the user’s last active tab, necessitating the user to navigate back each time. We understand that this could be slightly frustrating for our users.

We kindly request your assistance in identifying the potential reasons for these issues and seeking advice on how we could go about improving the overall performance of our Streamlit app.

We deeply appreciate your support and look forward to your valuable insights.

Warm regards,
LP
HelloFresh Berlin

Hi there!,
While I may not be an expert, I think that a lot of your problems can be solved using caching and adding session state values:
Caching might be the solution to the slow running of the app, though more context is required for knowing if it can be implemented here:

Regarding the widget reappearing, streamlit reruns the script on every user interaction or state change. This, combined with the slow speed, might be causing the widget to ‘reappear’ during the switch.

About the user’s last active tab, you can store the previous page in the session state of the user:

This might be a bit of a hack as a solution, but you can use the switch_page() option in the streamlit-extras library to navigate back to the stored page. (Streamlit-extras is (I believe) a third-party extension module for streamlit):

These are a few personal tips I use, maybe someone else can give you a better answer :slight_smile:
Cheers,
Moiz

2 Likes

Hi there @LP99 ,

Without actual code it is very difficult to understand why this is happening to your app. However, regarding the performance issues:

  • If you experience poor performance when running the app locally, the issue is most likely in the code and/or dependencies. Profile and optimize your code - and as suggested by @momos, use caching and session state to improve performance further.

  • If you experience poor performance only after Docker/AWS deployment, then the issue can be in (1) your Docker build, or (2) your AWS deployment settings. For example, are you building the Docker image on an M1 Mac? Because this can cause issues:

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.