Compressing large data before storing it in DynamoDB
We are all aware of DynamoDB's storage limitations for the item's size. Suppose that we get into a situation where storing large attributes in an item is a must. In that case, it's always a good choice to compress these attributes, and then save them in DynamoDB. In this recipe, we are going to see how to compress large items before storing them.
Getting ready
To get started with this recipe, you should have your workstation ready with Eclipse or any other IDE of your choice.
How to do it…
There are numerous algorithms with which we can compress the large items, for example, GZIP, LZO, BZ2, and so on. Each algorithm has a trade-off between the compression time and rate. So, it's your choice whether to go with a faster algorithm or with an algorithm, that provides a higher compression rate.
Consider a scenario in our e-commerce website, where we need to save the product reviews written by various users. For this, we created a ProductReviews
...