jeffreyhorner / rapache

R embedded inside Apache
http://www.rapache.net/
Apache License 2.0
137 stars 33 forks source link

Question: concurrent requests? #50

Closed lautiamkok closed 6 years ago

lautiamkok commented 6 years ago

I understand that R is single-threaded and it does not support concurrent requests. This is the same issue when we use rplumber:

R is a single-threaded programming language, meaning that it can only do one task at a time. This is still true when serving APIs using Plumber, so if you have a single endpoint that takes two seconds to generate a response, then every time that endpoint is requested, your R process will be unable to respond to any additional incoming requests for those two seconds.

What about rapache? Does it support concurrent requests? Can I use rapache as a server for rplumber?

jeroen commented 6 years ago

Yes rapache is multi threaded, it spawns R procs using apache2 prefork mpm. I don't think you are supposed to run plumber on rapache because you need to buy the rstudio connect server.

jeffreyhorner commented 6 years ago

rapache is not really multi threaded, but it can work with an apache multi processing module (MPM) that is multi threaded, such as worker and event but it is not recommended. The recommendation is to use the prefork MPM which spawns a number of child apache processes which have their own rapache module. That gives you concurrency. http://httpd.apache.org/docs/2.4/mpm.html