The Magic Of Railgun And How It Can Speed Up Your Website
PostedWednesday August 23rd 2017
Railgun sounds like a sci-fi super weapon that orbits a planet ready to destroy it at a moment’s notice, but it’s actually a whole lot cooler than that.
CloudFlare Railgun is an awesome feature that we offer for free on all of our hosting packages. To get it independently of VentraIP Australia costs $200 a month per domain, so it is a really great feature that we are proud to offer at no cost to our customers!
So What Exactly Is Railgun?
The biggest factor that affects the speed of a website when being viewed by an international visitor is distance. For example, when someone from the USA tries to view your website, it needs to navigate lots and lots of routers to reach our servers in the Sydney or Melbourne data centres. This takes time as it finds it way through the sea of routers that makes up the internet.
How do you solve this problem? CloudFlare has servers all around the world, and using Railgun, CloudFlare will serve the cached content of your site from the nearest geographical location of your visitor. This means around two out of three requests are served from a much closer location and thus the site is a lot faster when coming from international locations.
So if I am in Boston, USA and request your website which is hosted in Sydney, a significant portion of your site is served from CloudFlare’s Boston server, rather than having to grab the entire website from Sydney.
How does it work?
The non-technical answer: Magic.
The technical answer: Railgun increases speed in two ways:
Serving cached content from a CloudFlare server, which is geographically close to the visitor
Caching your website content itself to make it faster and smaller to be served from those closer servers.
Let’s look at each part that makes up CloudFlare
The Listener and Sender:
The server side of Railgun works in two parts: a listenerand a sender.
The listeneris installed on our server, and it communicates with CloudFlare serving requests using the ‘encrypted, binary Railgun protocol’.
The senderis installed on CloudFlare’s end in data centres spanning the world and maintains a connection with the listener.
Railgun’s caching mechanism compares the page version and decides what exactly must be transmitted to the sender. Not only will it compress the content that can be compressed, it is smart and works out what needs to be sent from the origin server and what needs to be sent by CloudFlare’s server.
So it means only recent changes made to the website are sent from the origin server, everything else is sent via the closest server it can find.
CloudFlare proudly notes that this method achieves typically a 99.6% compression rate, resulting in a speed increase of your site of around 700% and 90% increase in the Time To First Byte (TTFB) response.
The level of compression is so small that entire response often fits inside a single TCP packet…which is pretty cool.
So let’s look at what happens when someone tries to visit your Railgun enabled site:
A HTTP (website) request is made to Cloudflare, they identify that you are using Railgun and the HTTP request is routed to the senderto be dealt with.
The sendercompresses the request into a binary chunk that is then passes it to the corresponding listener.
The listenerservices the request and performs a request to the origin server (our server) for anything that isn’t locally cached to CloudFlare.
Sounds great, will it work for my site?
Yes, all websites types and forms will benefit from the magic of the Railgun.
Let’s enable it!
So there is one important thing to note when enabling Railgun:
You must have signed up for your free CloudFlare account through your cPanel > CloudFlare.
This is because when you sign up in that fashion, your account is attached to our parent account so you can use Railgun.