Using Rackspace Servicenet with Rails
One of the reasons that I use Rackspace Cloud Files and Cloud Servers is that the data transferred between the two is free. As such, it struck me as odd when I discovered the network interface which handles such communication hadn’t been used on my server. Upon some further digging, it was in fact clear that I had been charged for all of my data between the two.
The trick is that a different host name must be connected to for the requests to be processed over the internal network (and hence for free). Luckily, the ‘cloudfiles’ Ruby gem has a poorly documented way to do this. All you have to do is set an environmental variable named “RACKSPACE_SERVICENET”.
I accomplished this by adding the following code to the end of my production environmental configuration file:
# Enable Rackspace Servicenet usage # Uses eth1 to send free traffic to Cloud Files ENV['RACKSPACE_SERVICENET'] = "true"