I am trying to come out with high level architecture for product search in big scalable ecommerce application like amazon/best buy etc.
Use case :- Search any item in free text. Say user search product "galaxy white" , it can be mobile phone, air condition, garment brand , beaty product etc. I need to display all products in page. Just leave ranking product out of scope for now.
Design data points:-
- There will be sharded database with each shard containg particular product category.
- Similarly there will be distributed cache servers (may be redis or memcached) where each server will contain a specific product category data. for example one server can contain mobile data with key as brand name and value as again map.This nested map will contain model as key and product detail as key. Product detail can further contain list of sellers etc.
- We will also cached the Product_category_map which will contain most sought after product names as key and product categories as value list. It may be loaded on server startup and may be updated after some regular interval of time say 4 hours. For example :- Map will contain "galaxy" as key and value as {"Mobile", "garment"}
- Now when user search for product "galaxy white", it will search for cached Product_category_map, if it finds there,it will get product categories name as value
- If it is not found in step 4, parallel call(map reduce) will go to all sharded DB for fetching product category
- Once product categories are found, it will fetch the all matching products from cache i.e. from respective cache server for each category and then apply further filtering like description/colour/other_attribute is white in this case.
- Another alternative approach to step 6 can be , fetch matching products from sharded DB for each category. Here i can use DB index for filtering on white attribute
I want to confirm below points
- Approach in point 3 . When user types some text, shoild I construct the Product_category_map cache in advance , fetch it from there . I am not sure whether it is good approach to cach all product name against their category or it should fetch the categories from sharded DB's( in parallel using framework like mapreduce)
- Among 6/7 approach, which one is better ?
- Is similar desgign used by any scalable ecommerce application ?