Optimisation wins with CloudFlare

Sahana Bhat
Practo Engineering
Published in
3 min readFeb 13, 2018

In today’s fast paced world, speed beats everything else, especially when it comes to the Internet. Users expect content to be accessible over the Internet in a flash. If you are someone who has ever hosted a website which caters to users across geographic locations and/or wants the best possible end user response times, chances of you having used a Content Delivery Network are high.

At Practo, we take end user experience very seriously and so, CDN has been an important part of our system. We recently migrated our services to use CloudFlare as the CDN. For the curious, here is the blog that explains the reasons and the after effects of the migration. This blog will focus on some key features of CloudFlare that helped us achieve superior user experience.

Soon after migrating our services to CloudFlare, we saw high latency in requests made from locations which were far away from our origin servers, in other words, requests from a different continent. While exploring options to counter this issue, we came across a CloudFlare offering called Railgun. Railgun server has two main responsibilities. First, it maintains persistent TCP connections with CloudFlare datacenter servers so that the overhead of establishing a new TCP connection for every request is eliminated, thereby reducing the overall latency of requests. Secondly, compressed response content is cached in memory and only the changes in content in the consequent requests are transmitted over the internet.

Here are some fun facts of Railgun

  • ~500ms to 1000ms (depending on the route of the requests) per request is reduced because of the persistent TCP connection (except, of course, in the initial request which establishes the TLS handshake + TCP connection).
  • For frequently accessed pages, the delta of the response content can fit into a single TCP packet.

We waited for a couple of days for the Railgun magic to be quantifiable. However, though this new setup improved response times to some extent, we did not see the improvement we desired. We’ll shortly see why.

While our Railgun experiments were in progress, just about the same time, CloudFlare announced Argo, a solution for internet route optimisation. Enabling Argo on our domain worked like a charm. Our response times were back to the desired numbers almost immediately.

Argo is a smart routing algorithm which does real-time analysis of internet routes. The solution detects congestion in networks and routes the requests through congestion free or lesser congested networks. With better routes for requests to travel over the internet, the request latency reduces drastically, in turn improving response time.

Initial page load times on various setups (as seen by GoogleBot)

Thanks to Argo, ~60-70% of our requests find a smart route leading to ~2X improvement in average response times.

~70% of our requests find a smart route

So, how did Argo help when Railgun couldn’t?

Though Railgun establishes a persistent connection between CloudFlare data centers and origin server, the connection is still established over the open internet. This means that there is every possibility that each request travels through an unoptimised and congested route. And this is where Argo helped — to route the requests through the fastest route at the current time.

Argo has, by far, been our favourite and one of the most useful CloudFlare feature. If you are looking for superior response times for your customers across the globe, Argo is definitely worth a try!

Follow us on twitter for regular updates. If you liked this article, please hit the applause icon to recommend it and help other Medium users find it.

--

--