I have a web application that depends upon a set of R analytics. These R analytics read data from a database and perform machine learning, so have high CPU use.
The R analytics are accessed through HTTP using endpoints set up by the R-plumber REST library, all hosted in a docker container on an Azure Linux App Service. As R is single threaded and can only process one request at a time, it cannot handle multiple requests in parallel, they must be executed sequentially.
At the moment the web application and the R analytics container sit on the same appserviceplan (so same underlying VM), and when an API request is made that requires heavy CPU load, it can affect the performance the web application for other users.
I feel I need to move the R analytics API and underlying computational libraries to another hosting service on Azure, but I'm not sure what the best (and most cost effective) option would be.
Ideally the hosting service would keep a small set of containers idle, and when the HTTP request came in, allocate the request to a free container to perform the processing. If lots of requests were coming in, it would create extra containers elastically to scale with the load, but for a low number of requests, it would scale down automatically. That is what I'm imagining, but I have no experience of Kubernetes and was hoping there would be a easy way to set this up. I looked at Azure Container Instances, but it just seems to be for one container with little control for scaling out.
What (Azure) solution would be best in this scenario?