Custom load balancing for RStudio Server Pro


RStudio Server Pro gives you the ability to load balance by session, by user hash, or by server load. But it also gives you the ability to add your own custom load balancing script to make load balancing decisions. Specifics can be found in the RStudio Server admin guide.

First, configure RStudio Server Pro to accept custom load balancing in /etc/rstudio/load-balancer:

balancer = custom

Second, create a new bash script at:


This script will be passed two environment variables: RSTUDIO_USERNAME — The user on behalf or which the new R session is being created. RSTUDIO_NODES — Comma separated list of the IP address and port of available nodes. The script should return the node to start the new session on using its standard output. Note that the format of the returned node should be identical to its format as passed to the script (i.e., include the IP address and port).

The example below load balances by randomly selecting an RStudio node for each new session: 

#!/usr/bin/env bash

# Assuming input is comma-separated, no spaces

# reads node list into an array

# selects random node from array and returns it to stdout
Have more questions? Submit a request


Powered by Zendesk