Since a while ago I started moving all the services that I currently have towards serverless systems, I also started looking for...
Fastly, the varnish-based CDNmacklus
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:
- CloudFlare : most used, for its free service for small sites.
- CloudFront : the AWS CDN, very easy to configure.
- Akamai : The premium CDN, for large and high-cost projects.
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.
The main features of Fastly are:
- Well-extended network of servers: that guarantees a very fast response, especially in the Latin American area.
- Configuration versioning: To clearly see changes between versions, move from one to another in seconds, etc.
- Purged in real time: Removing an item from the cache It is automatic and almost instantaneous.
- ESI support (Edge Side Includes): To separate our website into logical “pieces” and update the cache only of those pieces that change.
- Brotli and gzip compression: To reduce the transfer and increase the loading speed.
- VCL-based configuration (Varnish Configuration Language): If we have used Varnish before it is very easy to go to Fastly.
- Extended VCL functions: To simplify the configuration, with date support, regex, etc.
- Statistics s in real time: requests, cache coverage, requests, errors, etc.
- Configurable content cache: We can define the cache times of our CDN to our taste (by object, url, type, tag, etc)
- Dictionaries and dynamic ACLs: To vary in real time who can access or what condition we must apply.
- Log flow: Fastly dynamically sends the logs of our visits to the provider we indicate, such as S3, loggly, Azure, Google Cloud, etc
- Optimizations for video and images: To optimize the presentation of images and videos in real time.
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 cost of the SSL service: Whether you want to use your own certificate, or if you want to use Fastly’s own share, prices start at $ 100, which for a small site It is a cost that can be higher than the cache itself, although we can reduce it using SAN Certificates
- The entry barrier: If we do not have knowledge of the VCL configuration format, we must learn to handle this syntax in order to handle our CDN
- The cost of support: Although the community is fast and efficient, the cost of its professional support service is very high, which again represents an entry barrier for medium or small-sized projects.
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.