Integrate Caching and Content Delivery Flashcards
Basic request/response lifecycle
User makes request.
If the CDN (.azureedge.net) doesn’t have the file, it goes to the origin server and requests the file.
The file is cached and remains cached until the Time To Live specified in the HTTP header. If the origin server doesn’t specify, the default is 7 days.
The file gets cached in the CDN and can be used for other user requests
What are the 2 ways you control how your files are cached in the CDN?
- Caching rules (global or custom)
2. Query string caching
Azure Redis Cache is…
In-memory cache.
CDN is storage account in Point of Presence (POP) servers.
How much time does it usually take for propagation to complete for Azure CDN Standard from Akamai profiles?
1 minute. For Azure CDN Standard from Verizon profiles, propagation usually completes in 10 minutes.
What are the two types of caching rules offered by Azure CDN?
Global and custom.
Custom overrides global.
What is the difference between global and custom caching rules in Azure CDN?
Global: Only one per CDN endpoint. Affects all requests to the endpoint.
Custom: One or many rules allowed. Allow you to specify caching behavior for specific file or path in your app. Override global caching rule
What are the 4 pricing tiers in Azure CDN?
Azure CDN Standard from Microsoft
Azure CDN Standard from Akamai
Azure CDN Standard from Verizon
Azure CDN Premium from Verizon.
Describe the 4 options for global caching rules.
Can override HTTP headers sent by clients.
4 options:
1. Bypass Cache: no items are cached at all even if caching headers set
2. Override: override headers setting default cache duration for all items
3. Set if missing: applies a custom TTL if the cache control header has not been set by the requesting client
4. Not set: honors any cache control headers that have been set, but won’t change the TTL value
Explain query string caching in CDNs.
Define how requests that contain query strings are dealt with.
- Ignore them (default) : CDN passes the query string from the requesting client through to the origin server on the first request and caches the asset that’s returned. Subsequent requests ignore the query string until the cached asset expires.
- Bypass query string: Any requests containing query strings are not cached at all by the CDN, and asset is retrieved directly from origin server and passed directly to the client
- Cache every unique URL: every unique URL is treated as an asset with its own cache and its own time to live. Don’t use this mode if your URLs contain query string values that change with every request. This would result in poor performance.
What are some common uses for Redis cache?
User session storage for distributed apps
Database caching (specific queries to the database)
Content caching
Distributed transactions
Message broker
What are some considerations you should make when determining tier of Azure Redis cache?
Overall cache size (amount of data stored in cache)
General network performance (low, moderate, high)
# of client connections
What are the 3 ways an item can be removed from Redis cache?
- TTL (scheduled deletion - “volatile item”)
- Manual removal using a client library
- Eviction (happens under memory pressure. Can’t control this). Can control the policy of how this happens.
What is the default eviction policy in Azure Redis cache?
volatile-lru (least recently used) - evaluates (and deletes) the lease recently used volatile items
Besides volatile-lru, what are the other eviction policy options?
Allkeys-lru - evaluates (and deletes) all items for lru (not just items that have a TTL)
No eviction
Volatile-random: selects at random volatile item to be removed
Allkeys-random: selects items at random from both volatile and non-volatile
Volatile-ttl: remove items with the shortest ttl remaining
When deciding what data to cache in Redis, what are some considerations?
Repeatedly accessed data (especially if it remains unchanged - this allows you to cache static and/or dynamic data if dynamic remains unchanged)
Data source performance: querying data from sql is significantly slower than retrieving from Redis cache
Data contention: if you have multiple processes within App all competing for access to the same data, then you should definitely consider that data for caching
Location of the data: if your db is on-prem or in another location, data should be considered for caching
True or false: Out of the box, an item in Azure Redis cache doesn’t have a TTL. It exists until it is forcefully removed.
True
What are 2 guiding principles when determining the cache period for items in Azure Redis cache?
Consider rate of change of the underlying data (long expiry for static data; short expiry for volatile data)
Consider the risk of using outdated data. Lower TTL if data changes often.
what are some common caching patterns (Redis)?
- Cache-aside: store most frequently accessed data so that it’s available without having to query the db
- Content cache: cache static content (kind of like CDN)
- User session (store in Redis instead of session cookie or local storage)
- Job and message queuing
- Distributed transactions (everything must complete for the transaction to move forward)
What factors would you use to estimate Redis cache size?
- # of co-existing objects you’ll have
- Size of cached objects
- Number of cached requests your app will make to the cache. Standard C3 tier of Redis Cache can process 100,000 requests/second. Drops to 90,000 requests/sec over SSL.
- Cache expiration policy. If items expire too quickly, they won’t be available when they’re required.
True or false: the Redis benchmark utility is available through the Azure portal
False. It’s available through the Redis CLI. Allows you to simulate load on your Redis instance.
Dynamic site acceleration is a CDN optimization method that is available, and utilizes what Microsoft service?
Azure Front Door Service
Which of the following services must be used to control how files are cached for a web request that contains a query string? Odata Redis Front Door None
Front Door
If you want to automate the creation and management of CDN profiles and endpoints which of the following services is most appropriate to be used?
Azure CDN Library for .NET
Files that are cached before a rule change maintain their origin cache duration setting. To reset their cache duration you must purge the file.
True