Cloudflare's Railgun - Railgun
What is Railgun
Railgun is defined by Cloudflare as a software that “accelerates and secures delivery of dynamic content, through compression and WAN network optimization of communication between Cloudflare data centers and an origin server, speeding up requests that can’t be served directly from Cloudflare cache.”
It’s a very interesting technology that helps cache content by only serving bytes
of changed page versions, creating a single persistent connection, and caching dynamic content. The goal is to speed up a given website. Google has calculated that a search that’s slowed by just four tenths of a second would mean they would lose 8 million searches per day (source). It is clear that enterprise sites require speed in order to succeed.
Install
Documentation can be found here. You will want to start by enabling the Cloudflare repo:
sudo rpm --import https://pkg.cloudflare.com/pubkey.gpg
sudo rpm -ivh http://pkg.cloudflare.com/cloudflare-release-latest.el7.rpm
Next, you’ll want to install railgun-stable and memcached.
sudo yum install railgun-stable memcached
Then, enable memcached and railgun on boot.
sudo systemctl enable memcached
Memcache Configuration
For this install, I opted to run memcached on the network. There would be some performance increases if you were to run it as a .sock, but it was a bit out of scope for what I thought was nessisary for my install.
My /etc/sysconfig/memcached
is as follows:
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="2048"
OPTIONS="-l ::1"
After that, I start memcached with sudo systemctl start memcached
.
Railgun Configuration
First, you’ll want to use the Cloudflare webpage to enable Railgun for your domain. This can be done at the following link.
Then, you’ll enable railgun for boot.
sudo systemctl enable railgun
Then I edit /etc/railgun/railgun.conf
with some basic info:
wan.ip = [2604:a880:1:20::3010:8001]
activation.token = [my token]
activation.railgun_host = www.thebrodeo.com
memcached.servers = [::1]:11211
After that, I start railgun.
sudo systemctl start railgun
I monitored if there were any problems with the install with tail -f /var/log/messages
. If there are any connection issues they will appear in those logs.
If all goes to plan, you will see a CF-RAY and cf-railgun HTTP response header. You can also check through the Cloudflare webpage or using the tool rg-diag -url [domain]
.