Traditional applications used to have one database for everything. With modern applications, you will often face multiple data sources, each with a different purpose and optimization. AWS services are typically well integrated with each other, however there are easier ways than accessing all data sources directly from your application.
What is AWS AppSync?
AWS AppSync is a fully managed service that allows you to connect to multiple databases, microservices, APIs, and other data sources, with the following benefits:
- Secure data access: you can define fine-grained access control policies, and use multiple concurrent authentication modes
- Performance: built-in caching, subscriptions to real-time updates, and client-side data stores with offline capabilities
- Automatic scaling: AppSync takes care of scaling the GraphQL execution engine up and down to meet customer demands
- Fewer network requests: with GraphQL you can retrieve the relevant data in a single request, counteracting the N+1 problem when fetching all your items with subsequent requests to get the details for each one of them
- Flexibility: you can add, modify, and swap your data sources in AppSync without modifying your application code
- Development speed: you can combine the data from different sources with a single GraphQL query – this is much faster than creating a backend for each data source
Flexibility and performance
GraphQL provides enormous flexibility when accessing data sources, and with its built-in caching can provide great performance. However, there are some cases where you should pay attention to how the data source is structured. If you use DynamoDB with a single table design, you will have to compromise. Nested GraphQL resolvers will provide maximum flexibility, but reintroduce the N+1 problem. If you want maximum performance, you need to restructure your GraphQL resolvers into broader, more complex resolvers, optimized for your known access pattern. Check out Alex DeBrie’s blog about GraphQL, DynamoDB, and single-table design for more details about this particular case.
Conclusion
AWS AppSync is a great tool to access multiple data sources and speed up your application development. It is future-proof and provides great performance and scalability.
References
- Simplify data access with GraphQL APIs (1:23). (n.d.). Amazon Web Services, Inc. Retrieved April 29, 2022, from https://aws.amazon.com/appsync/
- Rump, R. (2018, July 20). Common Entity Framework Problems: N + 1. Brent Ozar Unlimited®. Retrieved April 29, 2022, from https://www.brentozar.com/archive/2018/07/common-entity-framework-problems-n-1/
- DeBrie, A. (2022, April 22). GraphQL, DynamoDB, and Single-table Design. Alex DeBrie – Serverless & AWS. Retrieved April 29, 2022, from https://www.alexdebrie.com/posts/dynamodb-graphql/