Macklus.Net

Macklus.Net


For fun and profit

Fastly, the varnish-based CDN

macklusmacklus

También puedes leer este apunte en castellano pulsando aquí.

A CDN (or content distribution network) is a computer network dedicated to distributing the contents of its customers. By having the CDN servers in many different locations, they always serve the clients from the nearest server, thus being faster than doing it in the normal way.

In addition, the CDN is able to save the content for as long as we want, which allows us to reduce the load on our servers, since it is not necessary to generate all the content with each new request.

Some of the best known CDN solutions are:

Although each CDN has characteristics that distinguish them from the others, in general the operation (and even the way of working) is very similar between them, so choosing one or the other will depend on the characteristics of the project that we are going to implement.

Although not the best known, Fastly is one of the most powerful CDNs I have been able to work with. Although it can be very complex to configure (depending on what we want to do) the flexibility and power it offers makes it a very professional option when carrying out projects at any scale.

Fastly’s features

The main features of Fastly are:

While for me the main features of Fastly is its configuration with VCL, which allows anyone who knows Varnish to use Fastly without problems, in addition to many other advantages such as using a self-explanatory language, easy to read and understand , powerful, which simplifies the use of almost unlimited configurations and conditions and allows you to manage all the points of the request in a very simple way.

Fastly’s bad side

Although Fastly is a very powerful product, it also has characteristics that we can consider as negative, such as:

The most powerful side of Fastly

Fastly’s real power is seen when we program a site with ESI support, and unlimited cache time. ESI is a tag system that allows us to divide a web page into different parts (for example, header, menu, footer, content , right menu, etc). Each of these pieces can take a different cache time, and we can remove from the cache only the piece that we have changed.

That is, if we only change the content of a side menu, it makes no sense to regenerate and send all the content again, but only the content that has changed. Fastly is able to manage both ESI (divide the web into pieces) and cache times (the time a piece is saved before requesting it from the server again), and it will only ask us for content that has expired or has been changing , so the load against the server is very low.

As an example, I currently manage an online medium with Fastly that serves more than 2 and a half million pages, of a very heavy application, with only 1 front server, serving between 10 and 20 requests per minute, although from The CDN is serving more than 1000 requests per minute. As Fastly purging is almost immediate, we can keep an infinite cache and go warning Fastly of the elements that have changed, so that it refreshes them again. The total cost of traffic and requests in the CDN does not exceed $ 100, which for a business project is a totally acceptable cost.

If you want to try this CDN, you can register and use up to $ 50 free to see how it works.

macklus
Author