Apigee cache L1 and L2 written synchronously?

Case:

1) proxy-1 is called by a client. It writes an entry into a cache resource using populate cache policy.

Internals according to the documentation specified here :

http://docs.apigee.com/api-services/content/cache-internals.

a) Entry is written in local Message processors (lets say MP1).

b) Entry is also written in L2 Cache(cassandra)

2) proxy-2 is called that tries reads the key in 2 ms after the write.

Internals according to the documentation specified here :

a) The Load balancer redirects the call to a different Message processor (MP2 )

b) The system looks first for the entry in the in-memory L1 cache of the message processor handling the request.

c) If there's no corresponding in-memory entry, the system looks for the entry in the L2 persistent cache.

Questions:

1) Would proxy-2 be able to fetch the record?

Which one of the below is true?

2) The write operation into L1(under local MP1) and L2 cache happens in sequence during the execution of populate cache and only after both L1 and L2 are updated, the executed stack is moved to the next operation.

or

2) The write operation into L1(under local MP1) is done and the executed stack is moved to the next operation. The write to L2 happens in asynchronous fashion.

1 4 896
4 REPLIES 4

@krupal patel, I believe that it is the behavior 2. It will not be efficient to block the stack while it writes to L2. Also, as a database Cassandra is meant to have eventual consistency and not ACID like RDBMS. So the sync with eventually happen (and quite quickly), but may not be within 2ms.

In any case, this is just a question of 2 calls (or 1 per MP) that miss the cache and subsequently all MPs will respond with cached data.

hi @krupal patel please find the excerpt from documentation as here, the link is :

http://docs.apigee.com/api-services/content/cache-internals

hope this clarifies the doubt:

  • When a policy updates or invalidates an existing cache entry (InvalidateCache, PopulateCache, or ResponseCache policy):
    1. The message processor receiving the request sends a broadcast to update or delete the entry in L1 cache on itself and all other message processors in all regions.
      • If the broadcast succeeds, each receiving message processor updates or removes the entry in L1 cache.
      • If the broadcast fails, the invalidated cache value remains in L1 cache on the message processors that didn't receive the broadcast. Those message processors will have stale data in L1 cache until the entry's time-to-live expires or is removed when message processor memory limits are reached.
    2. The broadcast also updates or deletes the entry in L2 cache.

Hi, above docs didn't speak about what step to be taken if broadcast fails or how to avoid broadcast failure in application code itself or with support team.

I am facing intermittent old cache value returned after refreshing the cache with new value.

I am using an environment cache to store user's entitlement details in environment cache. So when entitlement update happens, I refresh the cache via web hook strategy from 3rd party application.

I have set cache expiration of 24 hours but in real time I cant wait or ask the customer to wait for 24 hours to reflect new entitlements.

Any idea or workaround to overcome this...

Restarting MPs will not work out for my use case.

I am facing intermittent old cache value returned after refreshing the cache with new value.

Please ask a new question, and avoid askng new questions in comments on questions from years ago. If you like you can link to this old question, if it provides some relevant information for your new question.