Load balancing R requests coming to RServe Load balancing R requests coming to RServe apache apache

Load balancing R requests coming to RServe


I'm unsure if this is achieveable with Apache mod_proxy. I think it will only work with HTTP protocol. Maybe you can try a proof of concept setup with nginx. It supports load balancing of ordinary TCP and UDP connections. It also allows you todefine load balancing methods (e.g. round-robin, etc.).

The configuration would be:

stream {    upstream myapp1 {        server 192.168.0.1:6311;        server 192.168.0.2:6311;        ...        server 192.168.0.6:6311;    }    server {        listen 80;        proxy_connect_timeout 1s;        proxy_timeout 3s;        proxy_pass backend;    }}

You can find more information in the nginx documentation: https://www.nginx.com/resources/admin-guide/tcp-load-balancing/ and here:https://nginx.org/en/docs/stream/ngx_stream_core_module.html


If you haven't already done so and since you are already working in Java, start off by connecting to your RServe servers from Java and run a simple "hello world" script on them, as given in the CRAN examples

Once the RServe instances are working fine, then you need to either load balance from Java or create one Java program per server and let Apache load balance between them. In either case your Java programs will need to serve http because you still need a link between html and RServe.


Looks like more people are looking for a solution to load balancing R scripts.Here is a working solution to loadbalance R via Rserve and HAproxy TCP load balancer.

Thumps up if it helps.

https://stackoverflow.com/a/39052040/1057093