I am building a price comparison site that will have around 50,000 products. I have built product pages, price tracking. Up until this point my access patterns have allowed DynamoDB to be read heavy (good for costs). However, I have reached the point where I want to implement filtering of products and create my product catalogue (listing) pages.
I have 2 critical criteria:
- Prices must be correct (they are updated daily)
- I must not go bankrupt
I am struggling to create partition keys and sort keys that do both.
Access patterns:
AP1: Get product by category
AP2: Get product by category and sub-category
AP3: Get product by category, sub-category, rating and price
My initial idea was to have duplicate items for category products with a 1 day TTL to ensure price freshness.
AP1 Partition Key:
CATEGORY##
AP1 Sort Key:
PRODUCTGROUP###PRODUCT#
AP2 Partition Key:
CATEGORY###
AP2 Sort Key:
PRODUCTGROUP###PRODUCT#
AP3 Partition Key:
CATEGORY####RATING####PRICE##
AP3 Sort Key:
PRODUCTGROUP###PRODUCT#
Each item also contains updatedAt, lowestCurrentPrice, highestCurrentPrice, regularPrice, rating1, rating2, rating3, ratingScore, valueForMoney attributes and GSIs to allow for ordering in different ways.
AP1 and AP2 would have an estimated cost of $41 per month. However, when you introduce AP3 with its large number of duplicates, costs skyrocket to $94000 per month.
Each Rating has 5 options, price filtering is chunked into $50 sections which is 40 options. This is unfortunately sometimes ending up with 5 * 5 * 5 * 40 = 5000 filter variations. Which is 5000 duplicates for 1 product, writing every day.
Does anyone have a better way of doing partition keys and sort keys for product catalogues that would for for filtering or am I missing something?
Edit 1: Clarification on product number - there are 50000 products currently each with (on average) 8 size variations, 5 colour variations, 3 suppliers. Around 6 million DDB items before you add in historic prices, price changes, on a per variation-supplier level.
