Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basic questions about R plumber [closed]

Tags:

r

plumber

I am newbie to R plumber which is a REST server that can expose R function as rest API.

I would ask following questions:

  1. Is R plumber server strong enough to be adopted in production environment?
  2. 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?
  3. How many concurrent requests does R plumber support?
like image 349
Tom Avatar asked Dec 03 '22 12:12

Tom


1 Answers

(Bias: I'm the author of plumber)

  1. 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

  1. 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.

  1. 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/

like image 58
Jeff Allen Avatar answered Jan 03 '23 17:01

Jeff Allen