AWS AppSync’s server-side data caching capabilities backed by Amazon ElastiCache for Redis, makes data available in a high speed, in-memory cache, improving performance and decreasing latency.
If you want to connect AppSync with DynamoDB, you can use Unit Resolvers which provide a direct resolver connection to DynamoDB. Unit resolvers run against the Database, thereby providing a singular response and request mapping template using Apache Velocity Template Language (VTL). A request will be taken as input, and then outputs a JSON document with instructions for the resolver.
To learn more about Unit Resolvers, work through the how to configure resolvers developer guide.
Caching within AppSync works at two levels:
Caching across the full API:
This means, If the data is not in the cache, it is retrieved from the data source and populates the cache until the time to live (TTL) expiration. All subsequent requests to the API are returned from the cache. This means that data sources aren’t contacted directly unless the TTL expires.
Caching per resolver level (including pipeline resolvers):
With this setting, each resolver must be explicitly opted in for it to cache responses.
Note: This is important as the other GraphQL endpoints don’t require caching in AppSync and with this situation, you can explicitly cache at the database level i.e. DynamoDB DAX.
This reduces the need to directly access data sources, whether that be Lambda, DynamoDB, Serverless Aurora, HTTP or more.
For certain endpoints you may look to utilise AppSync caching. The AppSync API resolves to DynamoDB through Lambda for its data, and you'd use DAX as a cache sitting in front of the database. You can utilise DAX to cache at the database level here.
I hope this helps.
How to use JS SDK V3 to getItem from DAX: "@aws-sdk/client-dax" instead of "amazon-dax-client"Accepted Answerasked 7 months ago
How to get connection duration metric from logs for AppSync subscription?asked 3 months ago
Feature request: Support for DynamoDB Transactions in AppSyncAccepted Answerasked 3 years ago
Implenting Batching + per request caching (dataloader) in AppSyncasked 8 months ago
Unauthenticated AppSync Resolversasked 2 months ago
API Gateway integration with DAXasked 7 months ago
Why doesn't Appsync use DAX for caching rather than ElasticCache for Redis?asked 2 months ago
Using PartiQL with DAX client for dynamodbAccepted Answerasked 4 months ago
Identity permissions for a background service with Appsyncasked 3 years ago
AppSync fails to use Lambda Authorizer for Secondary Authorizationasked 5 months ago