Deploy Bokeh apps on Cloud Run

I recently realized that Cloud Run on GCP started supporting WebSockets, so I wrote up an article to share how I was able to deploy and successfully run a Bokeh app: https://yogesh.replnotes.com/posts/deploy-bokeh-cloud-run

I find Cloud Run to be a more affordable solution compared to setting up a dedicated virtual machine instance, especially if your app doesn’t get a lot of traffic. I hope this article helps anyone else who might be looking into options for deploying their apps!

1 Like

Thanks for sharing @yogeshkd . I am looking for better deployment. I am currently running awesome-Panel.org on azure web services for containers. I am running it on a very low end dev server as anything else would be quite costly. Will take a look at this. Please let us know how this works longer term. Thanks.

Hi @yogeshkd

Something that would be interesting to add to the article would be how to configure a custom domain name.

Thank you for the suggestion, @MarcSkovMadsen. I was planning on embedding my application in another, so it never crossed my mind. I’ve added a section on configuring a custom domain to the same article: https://yogesh.replnotes.com/posts/deploy-bokeh-cloud-run

1 Like

Thanks @yogeshkd

How would Google Cloud Run compare for smaller use cases and larger use cases compared to Heroku on price and performance?

I don’t know how to quantify large and small but to me it looks like Google Cloud Run is very interesting for smaller demonstration use cases which could expect faster start up times, better performance and still something close to free. Is that correct?

Would it be possible to simplify and refactor the commands into a script that deploys in a few simple steps. I’m thinking the Bokeh/ Panel community does not have a ~3 step process for deploying into something (close to) free similar to what the Streamlit community has. Maybe this could be turned into such a thing?

I think your article is very interesting for the Panel community as well. So I’ve shared it at Deployment on Google Cloud Run - Showcase - HoloViz Discourse

Thanks for sharing the article with the Holoviz community. I didn’t know it existed!

I’ll caveat my response by noting that I have less than one year of experience and that my applications have never had large traffic. For use cases that do not have steady traffic, Cloud Run is far cheaper with a generous free tier compared to something like a Heroku Dyno. I haven’t yet crossed the free tier in my usage. The downside with using Cloud Run is that there is a little bit of latency (1-2 seconds, in my experience) for the first request after the application is scaled down to zero instances. You can set the minimum number of instances to 1 but that negates the pricing advantage. The upside is that depending on your average container uptime, you can generally go for much higher vCPUs and memory to improve performance as billing happens based on vCPU-seconds (CPU) and GiB-seconds (memory). For a large use case, if you expect the container instances to rarely go down to zero, it’s considerably cheaper to have a dedicated VM on GCP or Heroku, especially assuming that a data science-related application will require significant RAM/CPU. GCP has a very useful calculator, if you are curious to run some numbers through it: Google Cloud Pricing Calculator

When I started researching for this article, I intended to hopefully get to a few commands to easily deploy an application so I am definitely interested in taking a stab at that soon. I should note that once the initial GCP project setup is complete, the subsequent deployment is only one command: gcloud builds submit. I foresee a few challenges when trying to automate the initial setup. I haven’t yet found a way to set the required project permissions from a script. That’s why the first couple of steps rely on going to the GCP console. Not entirely sure if that was by design since those permissions have implications on billing. I’ll update here when I have something more streamlined!

1 Like