I am newbie to R plumber which is a REST server that can expose R function as rest API.
I would ask following questions:
(Bias: I'm the author of plumber)
- Is R plumber server strong enough to be adopted in production environment?
Plumber is still young, but I know of multiple people using Plumber in production now. Here's a writeup on one such example: https://www.mango-solutions.com/blog/production-r-at-ons
- The function,which is exposed as rest api, If the function does complex and time consuming logic, how to set the time out things to keep the connection alive?
There's not currently a way to force a timeout on a particular endpoint. It would just be up to the API author to ensure that the functions were kept lightweight enough that they would be able to return in a reasonable amount of time. Otherwise you'd want to kick off a separate process to handle a long-running task so that you could respond to the incoming request quickly.
- How many concurrent requests does R plumber support?
R in single-threaded, so at any given moment it can only be doing one thing (without special work-arounds). This holds true for Plumber, as well. Your Plumber API running in a single R process can only execute one function/endpoint at any given moment. Other incoming requests will be queued up until the R process is ready to start processing them.
The solution is to run multiple R processes in parallel and load-balance incoming traffic to those processes. Some more discussion: https://plumber.trestletech.com/docs/hosting/ and a solution: https://plumber.trestletech.com/docs/docker-advanced/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With