Has anyone deployed to Google Cloud Platform?

So far I haven’t had any success getting Streamlit to run an application in GCP. I can get Streamlit deployed to both AppEngine and CloudRun and started up. But in both environments even something as basic as “streamlit hello” displays a “Please wait…” message in an st.info() bar and then hangs on the internal connection to “healthz”, eventually failing with a 404 Error.
Github issue.

Any suggestions welcomed!

Thanks

Kevin

3 Likes

Hi @knorthover, I definitely got it going on GKE myself. I haven’t tried AppEngine or CloudRun, but I’d love to help. My guess is that there might be something boing on with Websocket. It seems to work just fine on GKE, but I am deploying directly with Kubernetes, so it might be a different networking setup. I really appreciate you filing the bug, so I will follow up from there. Also, thanks for uploading all your configuration and Dockerfile.

Matteo

1 Like

Thanks Matteo.
For now I’ve deployed on an internal server box. My users are enthusiastic about the application (a dashboard for our call center).

I don’t know enough about tornado to know where the problem is occurring but it seems that Cloud Run and AppEngine (I believe they are basically the same stack) are taking over control of the websocket connections.
Kevin

1 Like

I’m getting the same issue on app engine. I’m very eager to get streamlit working with either app engine or cloud function.

I’m mainly focus on ML, not good at eng and infra. Streamlit is awesome because I don’t have to be an expert on web dev eng. If Streamlit can be easily deployed to app enigne or cloud function then I don’t have to be an infra expert (e.g. kubernetes & docker) as well .

Matteo, just to confirm, you have been deploying it successfully in GKE?

If so, did you need to do anything special for websockets in GKE for it to work?. We are trying hard but failing at it.

Thanks in advance,

Toni.

Yeah, I did not do anything special. How are you doing it? A Service of type LoadBalancer should do it. I also have a setup through an “envoy”-based proxy, but that may require more effort.

We figured it out. We needed to disable CORS. After that it just worked!

Knowing that it worked for you encouraged us to keep trying :slight_smile:

2 Likes

Thanks for those last tips. I’ve now got a test app working in AppEngine using this suggestion https://stackoverflow.com/a/59052809 and disabling CORS.

Cloud Run still gives the same error

I’ll attach the Dockerfile and app.yaml files to the Github issue.

1 Like

Thanks so much for the solution for app engine!

Hi Antoni,
what did you to to disable CORS? I am using

CMD streamlit run --server.port 8080 --server.enableCORS false app.py

in the Dockerfile but it still does not work.

I’ve found this helpful and following these steps works to get a docker build that can be deployed in GKE. https://maelfabien.github.io/project/Streamlit/

It’s possible to get an app to run in AppEngine (as I posted a while back) but they generally stop after a little while because AppEngine doesn’t support a persistent websocket connection. GKE is the recommended approach.

Thank you. It’s a bit longer process, but on GKE it works.

Hi! Do you know if it’s possible to deploy using Google App Engine’s standard environment? I’ve deployed a simple streamlit app with the flex environment (with minimum requirements to run it) but the standard env is way cheaper. Thank you!

Jairo
As far as I know AppEngine will still not run Streamlit for any length of time. That was certainly my experience and I abandoned that approach some months back. The issue is Websocket support and timeout.

GKE deployment is mostly straightforward, it gets more complicated if you want to use the Identity Aware proxy to secure access to your pages. We did increase the Websocket timeouts for our GKE configurations.

These two blog posts are helpful

3 Likes

Thanks for your prompt reply @knorthover ! I’ll give it a try. Btw, do you think that deployment on AWS would be easier (say, using EC2) than GCP?

It’s interesting because I’ve used the Google App Engine to deploy my simple app with a flex env and it’s worked for a couple of months. I do see however an error once in a while that may have to do with the websocket issue discussed in this forum.

Jairo
I’ve no experience with AWS. All I can tell you is that my summer intern, who has deployed apps on AWS, has just been learning about Google Cloud and tells me GCP is much easier.
Kevin

2 Likes