RestRserve is an R web API framework for building high-performance microservices and app backends. The main difference with other frameworks (plumber, jug) is that it is parallel by design (thanks to Rserve).
YES - it means it will handle all the incomming requests in parallel - each request in a separate fork.
RestRserve is still work in progress - while we try hard to have stable API expect some breaking changes.
- Create a http API by simply setting up a handler (R function) for a given route - Hello-world
- Deploy applications with a couple of lines of the code. Easily stop them.
- Build high performance web API - more than 20000 requests per second on a laptop with 4 cores / 8 threads (Intel i7-7820HQ CPU), which is about 40x faster than plumber (but of course these numbers are for illustration only - everything depends on the user code!).
- Generate OpenAPI specification by parsing annotations in R code
- Expose Swagger UI
- Serve static files
RestRserve is a very thin layer on the top of Rserve - most of the credits should go to Simon Urbanek.
Creating application is as simple as:
library(RestRserve)
# create application
app = RestRserve::RestRserveApplication$new()
# register endpoints and corresponding R handlers
app$add_get(path = "/hello",
FUN = function(request, response) {
response$body = "Hello from RestRserve"
forward()
})
app$run(http_port = "8001")
Please follow quick start article on http://restrserve.org/ for more details.
- RestRserve is primarily tested on UNIX systems. While it works natively on Windows plase don't expect it to be as performant as on UNIX-like systems. If you really want to use it on Windows - consider to try Windows Subsystem for Linux and report to us.
- The main goal for RestRserve is to provide framework to create backend microservices with performance close to bare metall. So we haven't had a focus on the useful but not absolutely necessary things like uri templates. Contributions are very welcome.
- Keep in mind that every request is handled in a separate process (forked from parent Rserve instance). While this is absolutely awesome feature which allows to handle requests in parallel it aslo put some limitations on reusing certain objects - notably database connections.
- as already mentioned
Rserve
andRestRserve
process each request in a separate fork. In certain edge cases (usually badly designed user code) it is possible thatRserve
won't be able to create a fork (for example lack of RAM). In these casesRserve
will return 500 error. Keep in mind thatRserve
andRestRserve
can't control on how much resources will be needed to handle incoming request - everything depends on the user code. In order to limit number of connections/requests it is recommended to use specialized software such as HAproxy. - While
Rserve
is matured and very well tested software,RestRserve
is not - you can expect some minor bugs and minor API breaks
- Simon Urbanek (@s-u) for awesome Rserve and all the work on R itself and on his other packages
- Artem Klevtsov (@artemklevtsov) for useful suggestions and work on test coverage
- Jeff Allen (@trestletech) for his work on Swagger UI in plumber (from where we took inspiration for our implementation)
- Brodie Gaslam (@brodieG) for help with understanding on how to get traceback from try-catched function calls. Also thanks Hadley Wickham (@hadley) for evaluate::try_capture_stack function which we use for this purpose.