简体   繁体   English

使用R作为宁静的服务

[英]Use R as a restful service

Currently I have a shiny web app that can do some calculations on a 3GB data.frame loaded in memory. 目前,我有一个shiny Web应用程序,可以对内存中加载的3GB data.frame进行一些计算。

Now instead of implementing this feature on shiny web app, I need to make it a restful service that pipelines its calculation to another app in JSON format, so that people can use it by sending http request with url like http://my-app.com/function 现在,除了在shiny Web应用程序上实现此功能之外,我还需要使其成为一个宁静的服务,以JSON格式将其计算通过管道传输到另一个应用程序,以便人们可以通过发送带有http:// my-app的 url的http请求来使用它.com / function

I'm trying opencpu right now, but I don't quite understand how can I load and keep the large data in memory so that I can use api of opencpu to call functions in package just to do calculations, not to load the large data from disk every time I send http request. 我正在尝试使用opencpu ,但是我不太了解如何加载大数据并将其保存在内存中,以便我可以使用opencpu api调用程序包中的函数只是为了进行计算,而不是加载大数据每当我发送http请求时都会从磁盘中获取。

One workaround might be to use hbase as in memory database and use rhbase to load the data. 一个解决办法可能是使用hbase作为内存数据库,并使用rhbase加载数据。 But before I invest time in learning it I want to know if it is a reasonable choice for 3GB data.frame since it might add more overhead in serialization and other stuff that offset its speed benefit. 但是在我花时间学习它之前,我想知道对于3GB data.frame是否是一个合理的选择,因为它可能会增加序列化的开销以及其他抵消其速度优势的内容。

What would be a better way to implement this functionality? 什么是实现此功能的更好方法? Solutions using packages other than opencpu are also welcome, and it's better to be free. 也欢迎使用非opencpu软件包的解决方案,最好是免费的。

You may want to look at Plumber . 您可能想看看Plumber You decorate your R functions with comment code (that can include you loading data) and it makes it available via a REST API. 您可以使用注释代码(可以包括加载数据)来修饰R函数,并使其通过REST API可用。

您应该将数据放入程序包中,然后将此程序包添加到服务器配置中以preload

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM