Shiny apps on gcloud run

Dear community,

I have created a shiny app on RStudio and I am deploying it on gcloud run using Docker.
I could deploy the aps on it but I am facing a problem that I cannot resolve.

The fact is the Shiny app is starting by using one request to the container instance. But then, if the user do specific tasks in the app, this will trigger new requests to be achieved.

So if I choose that a container can hold 3 requests maximum, three users can connect using one request. However, if one of these user is doing something in the app that implies a new request to perform something in the app, the instance is already full with three request and then there is an error.

Would someone know how to limit access to one instance to one user only regardless of the number of requests used?

Thank you for your help,
Mathieu

0 5 957
5 REPLIES 5

Hi,

I am not familiar with R Shiny as it is a third party tool so I can only provide best effort support.

I stumbled upon this post mentioning that Shiny is a stateful service. I would like to point out that Cloud Run is built to run stateless services. This means that in Cloud Run, each HTTP request should not depend on previous HTTP requests. According to the same article, Shiny is inherently a session based system, meaning that a user's past actions affect the current Shiny state.

To better understand the issue, can you go into more detail about your use case?

@Darrell_M  We have a Shiny R app deployed on GKE Standard and running into concurrency and disconnection issues. Any pointers on how to troubleshoot this issue? Would Google Cloud Run be a better choice?

Hi Darrell,

Thank you very much for your answer. It is quite clear to me now that I should not deploy my containerized Shiny app on Cloud Run because it is not stateless. Could you tell me where I could deploy the app, that could handle sessions?

Thanks again for your help,

Mathieu

Hi mquinodo,

I would like to rectify some things from my response. Perhaps you can still use Cloud Run and leverage the usage of Websockets, which opens up two way communication between the user and the browser. I also recommend going over the section "About sticky sessions (session affinity)" and verify if this is doable with your use case. It looks like if you do go this route, you will also need an external data storage to synchronize data.

If this is not feasible, other compute options that could handle sessions are:
Google Compute Engine, which allows you manage and create VMs. I also found a guide that may be useful to you.
Google Kubernetes Engine. This may be overkill depending on the size of your app.
Google App Engine Flex, which supports custom runtimes.

I hope this helps!

Hi Matthieu,

Just wanted to contribute to the conversation. It's been a while since you posted this but I thought I would share for everyone's benefit. I'm speaking without knowing your use case for your app but in my experience I used cloud run for a shiny app with no problems. My use case though, was a proof of concept which didn't have an expectation to serve more than 50 users at the beginning so it was cost effective for gauging the user experience and needs. After a few months of testing we collected feedback and once we had a better understanding of user usage we then moved to Google Compute Engine.

Out of curiosity, what did you end up doing? where did you deploy your app?

Regards,

Christian.