AWS Deep Dive — AppSync Caching

Gunjan
3 min readApr 22, 2023

--

Here we will talk about caching .

There are a few ways to cache data in AppSync.

  • Built-in cache: AppSync has a built-in cache that can be used to store data for a configurable amount of time. This is the simplest way to cache data in AppSync.For the built-in cache, the maximum amount of memory is 10 GB. The default is set to 1GB.
  • Custom cache: You can also use a custom cache to store data. This gives you more control over the caching behavior, but it is more complex to set up.
  • Third-party cache: There are a number of third-party caches that can be used with AppSync.

The best way to cache data in AppSync depends on specific needs. For a simple solution, the built-in cache is a good option.

The built-in cache data is stored in the AppSync service’s memory. The memory is shared by all of the APIs in the service. This means that if one API is using a lot of memory, it can affect the performance of the other APIs in the service.

The built-in cache is a good option for small APIs that do not need a lot of caching capacity. However, for larger APIs, it is recommended to use a custom cache.

If the system architecture need more control over the caching behavior, you can use a custom cache. And if the need is for cache with a lot of features, you can use a third-party cache.

Here are some additional details about each caching option:

  • Built-in cache: The built-in cache is a simple and easy-to-use option. It is automatically enabled when you create an AppSync API. The built-in cache stores data for a configurable amount of time. The default TTL is 30 minutes. The built-in cache is free to use. However, you will be charged for the data that is stored in the cache. The cost of storing data in the built-in cache is $0.00002 per GB per month.
  • Custom cache: A custom cache gives you more control over the caching behavior. You can choose the type of cache to use, the location of the cache, and the TTL for the cache. To use a custom cache, you need to create a custom resolver function. The custom resolver function will be responsible for fetching data from the cache and returning it to the client. The cost of using a custom cache depends on the type of cache you use and the amount of data you cache. For example, if you use Amazon ElastiCache for Redis, you will be charged for the memory that is used by the cache. The cost of memory in Amazon ElastiCache for Redis is $0.05 per GB per month.
  • Third-party cache: There are a number of third-party caches that can be used with AppSync. These caches offer a variety of features, so you can choose one that meets your needs. Some popular third-party caches include Redis, Memcached, and Aerospike. The cost of third party caching techniques varies.

Here are a few tips for avoiding problems with AppSync caching:

  • Configure the cache TTL to a reasonable value. The TTL is the amount of time that data is stored in the cache. If the TTL is too short, the cache may become stale. If the TTL is too long, the cache may use up too much memory.
  • Monitor the cache for errors and performance issues. You can use the AppSync console to monitor the cache. The console will show you the number of requests that are being made to the cache, the amount of data that is being stored in the cache, and the number of errors that are being reported by the cache.
  • Keep the cache up to date. You should regularly update the cache with the latest data from the underlying data sources. This will help to ensure that the cache is always up-to-date.

--

--

Gunjan
Gunjan

No responses yet