Getting started
Domains & Origins

Domains & Origins
Request settings
Cache settings
Custom VCL
Image optimization

Access Control Lists
Monitoring and testing
Securing communications
Security measures
Web Application Firewall

Logging endpoints
Non-Fastly services

Streaming logs
Debugging techniques
Common errors

Account info
Account management
User access and control


    Request collapsing

      Last updated August 28, 2019

    This guide describes Fastly's Request Collapsing feature, frequently used when creating advanced service configurations.

    The basics

    Request Collapsing causes simultaneous cache misses within a single Fastly datacenter to be "collapsed" into a single request to an origin server. While the single request is being processed by the origin, the other requests wait in a queue for it to complete. Two types of Request Collapsing exist:

    1. Collapsing on a single cache server
    2. Collapsing within the datacenter between cache servers

    Each cache server will automatically queue duplicate requests for the same hash and only allow one request to origin. You can disable this behavior by setting req.hash_ignore_busy to true in vcl_recv.

    Within a datacenter, not every cache stores every object. Only two servers in each datacenter will store an object: one as a primary and one as a backup. Only those two servers will fetch the object from origin.

    How it works

    In Fastly's version of Varnish, VCL subroutines often run on different caches during a request. For a particular request, both an edge node and a cluster node will exist (though a single cache can, in some cases, fulfill both of these roles). The edge node receives the HTTP request from the client and determines via a hash which server in the datacenter is the cluster node. If this cache determines it is the cluster node and has the object in cache, it fulfills both the edge node and the cluster node roles.

    Certain VCL subroutines run on the edge node and some on the cluster node:

    Determining if a cache is an edge or a cluster node

    The fastly_info.is_cluster_edge VCL variable will be true if the cache currently running the VCL is the edge node and false if it is the cluster node.


    Keep in mind the following limitations when using the Request Collapsing feature:

    1. Any req.http.* headers are not transferred from the cluster node back to the edge node. Remember this when writing advanced configurations that use headers to keep track of state. If you set a req.http.* header in any of the subroutines that run on the cluster node, expect that the change will not persist on the edge node.
    2. A single, slow request to origin can sometimes cause a great many other requests for the same object to hang and fail. Because many requests for a single object are being collapsed down to one, they all succeed or fail based on the request that reaches the origin.
    Back to Top