Riding Cave
Riding Cave

Reputation: 1069

Why do we use refetching dispatcher flush agents in AEM?

When do we use refetching dispatcher flush agents and what is the purpose of using them?

I didn't find much info about this in AEM documentation.

Upvotes: 0

Views: 1318

Answers (1)

toniedzwiedz
toniedzwiedz

Reputation: 18553

The reason for using a refetch flush agent is to make sure your pages are cached on the dispatcher immediately after replication.

With a plain flush agent, you would flush the cache and the flushed content would only be retrieved from the publisher again after it is first requested. This creates a potential risk because if your website suddenly gets a peak of high traffic, it's possible for many requests for previously flushed pages to hit the Publisher in a very short period of time. For example, you flush a lot of pages at night when the traffic is low and in the morning, your users start coming to the site to see what's new. In this scenario, it's likely for the Dispatcher to receive multiple concurrent requests for the same page and forward them to the Publisher so you're looking at more than a single request per page.

To quote the Adobe documentation:

Deleting cached files ins this manner is appropraite for web sites that are not likely to receive simultaneous requests for the same page.

Using a refetch flush agent allows you to pre-populate the cache as it instructs the Dispatcher to retrieve a page from the Publish instance immediately after the flush occurs. This way the Dispatcher is unlikely to call the Publisher to process multiple concurrent requests for the same content and you're in control of when the re-fetch happens. Any potential increase in traffic that happens later on will just result in pages being served from the Dispatcher cache without affecting the Publish instance.

Refetch agents give you more control over when the Publish instance is supposed to render the pages. You're in control of the replication events and you know when the pages will have to be rendered by the Publish instance. For example, you can do a refetch flush at night, when the traffic is low and make sure every page gets cached overnight before actual users start calling your site, increasing the load on the servers.

To quote the docs again:

Delete and immediately re-cache files when web sites are likely to receive simultaneous client requests for the same page. Immediate recaching ensures that Dispatcher retrieves and caches the page only once, instead of once for each of the simultaneous client requests.

A word of warning. You have to be very careful about using refetch agents when trying to replicate a large portion of content or if your custom AEM code is not very fast. If you activate a lot of pages at the same time, you may end up performing a DDOS attack on yourself with the dispatcher killing the Publisher with a very large number of requests. The effects will be different depending on the performance of your AEM code. Flushing all of your content with an immediate refetch at the same time is a very bad idea, especially if your site requires a lot of resources to render a page.

Upvotes: 2

Related Questions