aws-samples / retail-demo-store

AWS Retail Demo Store is a sample retail web application and workshop platform demonstrating how AWS infrastructure and services can be used to build compelling customer experiences for eCommerce, retail, and digital marketing use-cases
MIT No Attribution
729 stars 516 forks source link

Ability Disable AWS Personalize #191

Open aeggbeg opened 3 years ago

aeggbeg commented 3 years ago

Hello,

I am trying to create a demo video with retail store demo. I have a use case where I need to showcase

I am using the full deployment method to enable retail demo store in AWS. I would like to find a way to disable/enable AWS personalize. This also helps reduce cost. What are my options?

Apologies I am a newbie when it comes to Personalise/Sagemaker. I don’t want to delete the solution- just control cost and do before and after video. Furthermore this allows me to learn the solution in a cost effective manner.

This is not a bug - just looking for some guidance and help on the use case.

many thanks

aeggbeg commented 3 years ago

This is an expensive project! I been running the full solution for 2 days now and the cost just doesn't work for me aka personal learning/start-up development. Here is the cost breakdown

CF template created 1 datasets group, 3 datasets, 3 solutions and 3 campaign with 1 TPS (3600 recommendations per hour - plenty for startup/demo). To run the solution for 30 days

3 1 TPS 24 Hours 30 days = 2160 TPS hours $0.20/TPS hour = $432 USD (just on Personalize TPS hour)

I would love to tinker and learn this solution but I think it's time for me to delete the campaign (there is no disable). I am trying to understand if I can move to a batch mode recommendation instead of real time to reduce cost. I would appreciate if we can update the README file with some cost details for other users - this is something Amazon does on all their solutions/quick starts e.g. typical sample cost to get an idea of the cost.

Thanks.

james-jory commented 3 years ago

Thank you for the feedback @aeggbeg.

There currently is not a single toggle to enable/disable personalization in the storefront/web-ui and the recommendations service. However, there is a fairly easy way to accomplish what you're wanting to do.

The recommendations service provides an API that is used by the storefront to retrieve user product recommendations, similar product recommendations, and to rerank products. When Personalize campaigns are created for trained models (either in the workshop or automatically after deployment), the campaign ARNs are stored in the SSM parameter store. The recommendations service checks the parameters retaildemostore-product-recommendation-campaign-arn, retaildemostore-related-products-campaign-arn, or retaildemostore-personalized-ranking-campaign-arn depending on the API being called. If the parameter value is not NONE, it will use the value as the campaign ARN when making calls to Personalize to get recommendations. Response headers in the API response are used to inform the storefront that a Personalize campaign was used. If the parameter value is NONE, the service will perform suitable default logic. For example, for product recommendation requests the service will return featured products and for related products requests the service will return products from the same category as the specified product. The storefront UI will display the Personalize service icon above a personalized section of a page when a Personalize campaign was used. Otherwise, the icon will not be displayed. This is an easy way to tell if Personalize is in effect or not.

So to enable/disable personalization in the storefront, sign in to your AWS account where you have the Retail Demo Store deployed, go to the Systems Manager Parameter store page, and change the SSM parameter values noted above to NONE. You should see the personalization behavior on the storefront change immediately (once you change to a view that displays personalized content). To switch back to using Personalize, replace NONE with the appropriate Personalize campaign ARN. If you lose track of the ARNs, you can always find them on the Personalize console page for the Retail Demo Store's dataset group.

Regarding cost of this project, you are right that it can add up if left running. Most of the cost will come from the Personalize campaigns. The project is using the lowest allowed minProvisionedTPS for each campaign to keep costs as low as possible. There is a note at the very beginning of the Getting Started section that calls out the fact that costs will be incurred but I agree that it can be improved to provide more detail. You can delete the campaigns and set the SSM parameters noted above to NONE in the AWS console to remove the ongoing Personalize campaign costs and then recreate the campaigns and set the campaign ARNs back to reactivate personalization. This is fairly easy and quick to do in the AWS console--note that the trained models/solutions are still there and do not incur ongoing costs once created.

aeggbeg commented 3 years ago

Hi James,

Thank you again for your tips. It works!!! :) I can now keep it running cos rest of the cost are do able compare to every time start from scratch to understand the solution. I do have a related question - when you temporary disable the personalize campaigns. The site homepage goes to "spinning wheel - no stop or error message". I only see "Featured" section working without issue. I am guessing it's because of "amazon personalize is not there to send the data back to website". it doesn't bother me just curious is it supposed to be like that or maybe I have other issues in my deployment.

Many thanks again for solving my budget problem :)

james-jory commented 3 years ago

I do have a related question - when you temporary disable the personalize campaigns. The site homepage goes to "spinning wheel - no stop or error message". I only see "Featured" section working without issue. I am guessing it's because of "amazon personalize is not there to send the data back to website". it doesn't bother me just curious is it supposed to be like that or maybe I have other issues in my deployment.

The spinning wheel on the homepage when the Personalize campaign ARNs are not set in SSM sounds like a bug. The behavior should fall back to displaying featured products only when Personalize campaigns are not available/active. I'm guessing you were signed in as a storefront user.

A question I missed from your earlier comment:

I am trying to understand if I can move to a batch mode recommendation instead of real time to reduce cost.

Batch recommendations would reduce cost by eliminating the need for campaigns but you would be sacrificing several key features of Personalize and the project.

Other significant changes would be needed such as loading the batch recommendations into a datastore like DynamoDB, modifying the logic in the recommendations service to query the datastore rather than a campaign to get recommendations, and so on.