Streamlit unstable under heavy load

Hi folks!
Thanks for creating such an easy to use dashboarding tool. My team has used it to deploy a COVID-19 hospital capacity planning tool called CHIME http://predictivehealthcare.pennmedicine.org/2020/03/14/accouncing-chime.html

We’re running into an issue with our deploy that is very hard to reproduce unless the application is under heavy load. I’ve documented this issue here: https://github.com/pennsignals/chime/issues/52

Any advice on how to stabilize the app would be greatly appreciated. You can reach me directly on our slack at https://codeforphilly.org/chat?channel=covid19-chime-penn

I filed a github issue for this at https://github.com/streamlit/streamlit/issues/1227

Thanks!

Hey @beckerfuffle, welcome to Streamlit!

It looks like your issue was mitigated by switching away from pyplot to altair?

This looks like a race condition inside matplotlib; under heavy load, Streamlit is spins up many threads concurrently, and I wonder if (a) we’re mistaken about the thread-safety of matplotlib operations or (b) matplotlib is buggy in concurrent scenarios.

Are you able to move away from pyplot entirely? This should also reduce any server load you’re having, as pyplot charts are rendered server-side and delivered to the browser as images, and altair charts are sent as JSON to the browser, which then renders them locally.