Understanding Request Coalescing

What is Request Coalescing?

Request coalescing combines multiple simultaneous requests to the same resource into a single request going to the origin. If multiple requests come in at the same time, they will be automatically merged. Once the request from the origin completes, the response will be streamed in real-time to all waiting connections for that request path.

Request Coalescing happens on each of the bunny.net edge servers, meaning that multiple requests can still reach your server. The number of requests can further be reduced by combining Request Coalescing with the origin shield. This will effectively cause Bunny CDN to only send a single request at a time to the origin for that specific request path.

 

How does Request Coalescing work?

Request Coalescing works by using a special lock mechanism when sending requests to the origin. Traditionally, a CDN would send requests from the end-user to the origin and proxy the response back to that response. Request Coalescing on the other hand will, upon receiving a request, first, open a mutex lock. Then, the Request Coalescing system will send a single request to the origin. As soon as the origin responds, the mutex is released and all the waiting connections are automatically connected to the origin response.

 

The chart below illustrates this with 4 requests that are sent through the Request Coalescing system concurrently.

 

What are the benefits of Request Coalescing?

The primary benefit of request coalescing is the reduction of the load on your origin server, especially during large traffic spikes to the same resources such as live streaming, or very busy public APIs where the result can be cached to multiple users. By reducing the number of requests your server receives, Request Coalescing will help you lower the CPU and traffic load on your origin.

 

How does Request Coalescing handle dynamic data?

Request Coalescing will trigger on any uncached request hitting the CDN edge server. This is true for requests to both static and dynamic resources. It means that Request Coalescing should not be used in cases where the data being retrieved from the origin should be unique between users.

  Caching Notice

Using Request Coalescing in situations where dynamic content is returned such as APIs or dynamic websites might result in personal information being shared between different authenticated users sending requests at the same time.

Does Request Coalescing mean only one request will ever hit my server?

The short answer is no. Request Coalescing does not assure only a single request will ever be sent to the origin. It only combines uncached requests that are accessing a single resource at the same time. With Request Coalescing enabled, your origin could still receive a request to the same resource if the requests arrive sequentially.

 

 

Table of Contents

Was this article helpful?
0 out of 0 found this helpful