Versioning, conflict detection, and sync operations for DynamoDB data sources - Amazon AppSync
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Versioning, conflict detection, and sync operations for DynamoDB data sources

Amazon AppSync's advanced data management capabilities for DynamoDB leverages three key features: versioned data sources, conflict detection and resolution, and sync operations. These tools enable robust, scalable applications that efficiently handle concurrent data modifications and synchronization in distributed environments.

Versioned data sources form the foundation of Amazon AppSync's data management system. This feature automatically enhances DynamoDB items with versioning metadata, records changes made by Amazon AppSync mutations to a Delta table, and maintains "tombstones" for deleted items. Developers can configure retention periods for deleted items and change logs, optimizing storage while ensuring data consistency. Versioned data sources streamline the implementation of conflict detection and sync operations, providing a solid base for advanced data handling.

Conflict detection and resolution mechanisms safeguard data integrity when concurrent writes occur. Amazon AppSync offers three strategies: Optimistic Concurrency, Automerge, and Lambda-based resolution. Optimistic Concurrency rejects conflicting mutations, allowing clients to retry with updated data. Automerge automatically resolves conflicts based on data types, merging lists, performing set unions, and preserving existing scalar values. Lambda-based resolution enables custom logic for complex conflict scenarios. These options give developers flexibility in handling data conflicts, ensuring consistency across distributed systems.

Sync operations enable efficient data retrieval and updates in client applications. This feature allows clients to fetch all results from a DynamoDB table and subsequently retrieve only data altered since their last query. Amazon AppSync determines whether to access the Base table or Delta table based on the provided sync token, optimizing performance and reducing data transfer.