This Guidance demonstrates how retailers can use Amazon OpenSearch Service, in combination with natural language processing, to create digital recommendations when needing to replace out-of-stock store products. Product names and descriptions are embedded and stored in a k-nearest neighbors (k-NN) index. When a consumer is querying for product recommendations, neighboring products are located within the k-NN index and returned to the consumer. The relevance of returned products can increase by using the optional category and price-based filters. 

Please note: [Disclaimer]

Architecture Diagram

[text]

Download the architecture diagram PDF 

Well-Architected Pillars

The AWS Well-Architected Framework helps you understand the pros and cons of the decisions you make when building systems in the cloud. The six pillars of the Framework allow you to learn architectural best practices for designing and operating reliable, secure, efficient, cost-effective, and sustainable systems. Using the AWS Well-Architected Tool, available at no charge in the AWS Management Console, you can review your workloads against these best practices by answering a set of questions for each pillar.

The architecture diagram above is an example of a Solution created with Well-Architected best practices in mind. To be fully Well-Architected, you should follow as many Well-Architected best practices as possible.

  • Amazon CloudWatch, OpenSearch Dashboards, and Amazon SNS are all services used to enhance operational excellence throughout this Guidance. Consisting of serverless and managed services, the services output their own metrics to CloudWatch, where the state of the service can be monitored. OpenSearch Dashboards is also used to explore, inspect, and visualize data. Amazon SNS is used in collaboration with the monitoring services to provide notifications. These services help to run and scale your OpenSearch clusters, monitor the state of each service used in the architecture, and notify you of metrics and state changes that you define as important to your business.

    Read the Operational Excellence whitepaper 
  • Cognito, Lambda, and AWS Identity and Access Management (IAM) are services deployed in this Guidance to enhance your security. IAM can be used to create fine-grained roles and policies to control who can manage and create your APIs, as well as control who can invoke them. 

    To control access to your APIs, Cognito user pools or a Lambda authorizer can also be used for secure authentication and authorization. Cognito provides customizable secure authentication and authorization for users in your user pools. Lambda authorizers control access to your APIs using bearer token authentication, as well as information described by headers, paths, query strings, stage variables, or context variable request parameters.

    Read the Security whitepaper 
  • Lambda, OpenSearch Dashboards, and API Gateway were used throughout this Guidance to enhance reliability. Lambda is used for serverless compute and is designed to provide managed scaling. As traffic increases, Lambda increases the number of concurrent processes of your functions. OpenSearch Dashboards allows you to monitor and visualize your OpenSearch data for better insight into the performance of your cluster. API Gateway uses throttling to prevent your APIs from being overwhelmed. You can configure custom throttling for your APIs to set a limit on steady-state rate and a burst of requests against your APIs. Through monitoring and built-in scaling capabilities, these services help to provide a reliable architecture to ensure consistent performance for your product substitution application.

    Read the Reliability whitepaper 
  • This Guidance deploys Lambda to enhance performance efficiency. It is used as serverless compute to load seed data into DynamoDB, embed, and index data for OpenSearch, as well as query product substitution requests to OpenSearch. Lambda can be set up to operate based on trigger functions to automate the flow of data through the architecture. Leveraging Lambda for serverless compute improves performance for loading data and querying data within the architecture. 

    Read the Performance Efficiency whitepaper 
  • OpenSearch, Lambda, and Amazon S3 were deployed in this Guidance to optimize your costs. Amazon S3 is a low-cost storage option for product data. Lambda is a serverless compute service that runs your code without having to manage servers, and incurring costs while the code is running. And following OpenSearch best practices, such as using the latest generation instance types and node storage volumes, can help to reduce OpenSearch cluster costs. Reserved instances can also be used for your OpenSearch instances.

    Using Amazon S3 lifecycle policies, infrequently accessed data can be moved to lower-cost storage tiers to further optimize costs. Also, Lambda contributes to a lower cost architecture by allowing you to avoid paying for idle compute resources. Additionally, following OpenSearch best practices ensures you are optimizing compute instances and storage volumes for your cluster, so you are only paying for the resources necessary for your workload. Finally, using reserved instances provides a better price for your OpenSearch cluster. 

    Read the Cost Optimization whitepaper 
  • Lambda, OpenSearch, and OpenSearch Dashboards were deployed throughout this Guidance to enhance sustainability. Lambda uses the minimum amount of hardware resources to run your code, then terminates the environment on completion. OpenSearch clusters can be optimized and monitored using OpenSearch Dashboards. Finally, with Lambda and OpenSearch, using the minimum number of resources also reduces the amount of energy needed to operate the workload, contributing to greater sustainability efforts.

    Read the Sustainability whitepaper 

Implementation Resources

The sample code is a starting point. It is industry validated, prescriptive but not definitive, and a peek under the hood to help you begin.

Video
AWS Guidance for Retail Use Cases

Disclaimer

The sample code; software libraries; command line tools; proofs of concept; templates; or other related technology (including any of the foregoing that are provided by our personnel) is provided to you as AWS Content under the AWS Customer Agreement, or the relevant written agreement between you and AWS (whichever applies). You should not use this AWS Content in your production accounts, or on production or other critical data. You are responsible for testing, securing, and optimizing the AWS Content, such as sample code, as appropriate for production grade use based on your specific quality control practices and standards. Deploying AWS Content may incur AWS charges for creating or using AWS chargeable resources, such as running Amazon EC2 instances or using Amazon S3 storage.

References to third-party services or organizations in this Guidance do not imply an endorsement, sponsorship, or affiliation between Amazon or AWS and the third party. Guidance from AWS is a technical starting point, and you can customize your integration with third-party services when you deploy the architecture.

Was this page helpful?