Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new document for handling carts with large amount of items #2429

Merged
merged 14 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _data/sidebars/pbc_all_sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ entries:
url: /docs/pbc/all/cart-and-checkout/base-shop/tutorials-and-howtos/enable-guest-checkout-in-the-b2b-demo-shop.html
- title: Implement a customer approval process based on a generic state machine
url: /docs/pbc/all/cart-and-checkout/base-shop/tutorials-and-howtos/implement-a-customer-approval-process-based-on-a-generic-state-machine.html
- title: Handling carts with a big number of items
url: /docs/pbc/all/cart-and-checkout/base-shop/tutorials-and-howtos/handling-carts-with-a-big-number-of-items.html
- title: "Tutorial: Checkout and step engine"
url: /docs/pbc/all/cart-and-checkout/base-shop/tutorials-and-howtos/tutorial-checkout-and-step-engine.html
- title: "Tutorial: Calculator plugin"
Expand Down
58 changes: 27 additions & 31 deletions docs/ca/dev/deploy-in-a-production-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This document describes how to deploy an application to [ECS cluster](https://do


## Prerequisites

We use the *spryker-prod* environment as an example. Adjust the name according to your project name.

In this document, an *application version* is a Git commit hash string which is set as a Docker Image tag for all [Elastic Container Registry (ECR) repositories](https://docs.aws.amazon.com/AmazonECR/latest/userguide/Repositories.html) for the environment.
Expand Down Expand Up @@ -42,42 +43,40 @@ To deploy a specific application version, copy the version of the respective Git


## 2. Define the version to deploy
To define the application version to deploy:

1. In the AWS Management Console, go to **Services** > **Systems Manager** > **Application Management** > **[Parameter Store](https://eu-central-1.console.aws.amazon.com/systems-manager/parameters/)**.
1. In the AWS Management Console, go to **Services** > **Systems Manager** > **Application Management** > **Parameter Store**.

2. Select */spryker-prod/desired_version*.
2. Click **/spryker-prod/desired_version**.

3. Select **Edit**.
3. Click **Edit**.

4. Enter the application version into the **Value** field.

5. Select **Save changes**.
5. Click **Save changes**.


## 3. Run a deployment pipeline
To run a pipeline:

1. In the AWS Management Console, go to **Services** > **[CodePipeline](https://eu-central-1.console.aws.amazon.com/codesuite/codepipeline/pipelines)**.
1. In the AWS Management Console, go to **Services** > **CodePipeline**.

2. Select *NORMAL_Deploy_Spryker_spryker-prod*.
2. Click **NORMAL_Deploy_Spryker_spryker-prod**.


{% info_block infoBox "Normal deploy" %}

*Normal deploy* is a pipeline that includes all the stages of a complete CI/CD flow. The *Install* stage of this pipeline does not perform any dangerous data manipulations like database cleanup or scheduler reset. We recommend this type of deploy for the production environment.
*Normal deploy* is a pipeline that includes all the stages of a complete CI/CD flow. The *Install* stage of this pipeline does not perform any dangerous data manipulations like database cleanup or scheduler reset. We recommend this type of deploy for production environments.

{% endinfo_block %}

3. Optional: check the deployed application version and the application version to be deployed:

1. In the *Prepare_versions_information_for_Approval_stage* stage, select **Details**.
1. In the *Prepare_versions_information_for_Approval_stage* stage, click **Details**.



![compare application versions](https://spryker.s3.eu-central-1.amazonaws.com/cloud-docs/Spryker+Cloud/Deploying+in+a+production+environment/compare-application-versions.png)

2. Select **Tail logs** and check the job output.
2. Click **Tail logs** and check the job output.

![tail logs](https://spryker.s3.eu-central-1.amazonaws.com/cloud-docs/Spryker+Cloud/Deploying+in+a+production+environment/tail-logs.png)

Expand All @@ -87,49 +86,46 @@ To run a pipeline:

![deployment-versions-logs](https://spryker.s3.eu-central-1.amazonaws.com/cloud-docs/Spryker+Cloud/Deploying+in+a+production+environment/deployment-versions-logs-prod.png)

4. Approve the application version to be deployed:

1. In the *Please_approve* stage, select **Review**.
4. To approve the application version to be deployed, in the **Please_approve** stage, click **Review**.

2. Review the details and select **Approve**.
5. Review the details and click **Approve**.

5. Select **Release change**.
6. Click **Release change**.

![release change](https://spryker.s3.eu-central-1.amazonaws.com/cloud-docs/Spryker+Cloud/Deploying+in+a+production+environment/release-change.png)

If the deployment is successful, the */spryker-prod/lastdeployedversion* parameter in the [Parameter Store](https://eu-central-1.console.aws.amazon.com/systems-manager/parameters) is updated with the application version you’ve deployed.
If the deployment is successful, the **/spryker-prod/lastdeployedversion** parameter in the Parameter Store is updated with the application version you’ve deployed.


## Check the deployed application version
To check the deployed application version in the [ECS cluster](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/clusters.html), do following:

1. In the AWS Management Console, go to **Services** > **[Elastic Container Service](https://eu-central-1.console.aws.amazon.com/ecs/home?region=eu-central-1)**.
2. Select *spryker-prod*.
3. Select one of the following services:
* *spryker-prod-storeapp*
* *spryker-prod-backoffice*
* *spryker-prod-frontend*
* *spryker-prod-zed*
* *spryker-prod-yves*
To check the deployed application version in the ECS cluster, follow the steps:

1. In the AWS Management Console, go to **Services** > **Elastic Container Service**.
2. Click **spryker-prod**.
3. Click one of the following services:
* **spryker-prod-storeapp**
* **spryker-prod-backoffice**
* **spryker-prod-frontend**
* **spryker-prod-zed**
* **spryker-prod-yves**

![cluster](https://spryker.s3.eu-central-1.amazonaws.com/cloud-docs/Spryker+Cloud/Deploying+in+a+production+environment/cluster-spryker-prod.png)

4. Go to the **Tasks** tab.

5. Select the task.
5. Click the task.

![select task](https://spryker.s3.eu-central-1.amazonaws.com/cloud-docs/Spryker+Cloud/Deploying+in+a+production+environment/select-task-prod.png)

7. In the *Image* column of the *Containers* section, ensure that the image name of the container contains the correct application version.
7. In the **Image** column of the **Containers** section, ensure that the image name of the container contains the correct application version.

![check image task](https://spryker.s3.eu-central-1.amazonaws.com/cloud-docs/Spryker+Cloud/Deploying+in+a+production+environment/check-image-task-prod.png)

## Roll back an application
To roll back an application:

1. Find out the application version you want to roll back to. See [1. Check the version to deploy](#check-the-version-to-deploy) for more details.

2. In [Parameter Store](https://eu-central-1.console.aws.amazon.com/systems-manager/parameters/), set the application version as the value of the */spryker-staging/desired_version* parameter. See [2. Define the version to deploy](#define-the-version-to-deploy) for more details.

2. In Parameter Store, set the application version as the value of the **/spryker-staging/desired_version** parameter. See [2. Define the version to deploy](#define-the-version-to-deploy) for more details.

3. Run a deployment pipeline as described in [3. Run a deployment pipeline](#run-a-deployment-pipeline).
12 changes: 6 additions & 6 deletions docs/ca/dev/security/generate-access-keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ You can only generate an access key for your own account. If you want to create

{% endinfo_block %}

To generate an access key:
To generate an access key, follow the steps:

1. In the AWS Management Console navigation bar, select your username > **My Security Credentials**.
1. In the AWS Management Console navigation bar, click on your username > **My Security Credentials**.
![My security credentials button](https://spryker.s3.eu-central-1.amazonaws.com/cloud-docs/Spryker+Cloud/Security/Generating+access+keys/my-security-credentials-button.png)
2. On the *My security credentials* page, select **Create access key**.
2. On the **My security credentials** page, click **Create access key**.
![Create access key button](https://spryker.s3.eu-central-1.amazonaws.com/cloud-docs/Spryker+Cloud/Security/Generating+access+keys/create-access-key-button.png)
This opens the Create access key window with the success message displayed. Your access key has been generated.
3. To download the access key, select **Download .csv** file.
This opens the **Create access key** window with a success message displayed. Your access key has been generated.
3. To download the access key, click **Download .csv** file.
![Download csv file button](https://spryker.s3.eu-central-1.amazonaws.com/cloud-docs/Spryker+Cloud/Security/Generating+access+keys/download-csv-button-file-button.png)
4. Optional: To check the access key in this window, select **Show secret access key**.
4. Optional: To check the access key in this window, click **Show secret access key**.

You've generated and downloaded your access key.
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
title: Handling carts with a big number of items
description: Challenges related to big carts and how to solve them
last_updated: Jan 09, 2024
template: howto-guide-template
---

Spryker's cart management easily covers small to medium-sized shopping carts, which satisfies the majority of use cases. However, you may have to deal with really big carts counting many hundreds and sometimes even thousands of line items. Handling such big carts usually means you have to go beyond the usual setup and customize on the project level. This document describes the challenges introduced by big carts and how you can effectively customize Spryker to deal with them.

Because UI plays a crucial role while working with big carts, this document focuses on Storefront. If you're using Spryker in a headless way, you can focus on Glue and Backend strategies. However, we encourage you to consider if you can apply Storefront strategies to your third-party frontend solution.

## Challenges and mitigation strategies

The following sections describe the possible challenges you need to consider. Use it as a guidance and evaluate, what challenges have the biggest impact on your project, and what mitigation strategies are the most effective given your business requirements and available resources.

Mitigation strategies are divided into the following categories:

- *Backend*: calculations, caching strategies; applies to every project, regardless of whether Storefront or headless approach is used.
- *Storefront*: applies only to projects with Spryker Storefront.
- *Glue*: applies only to projects with a headless approach.

Choose and apply the mitigation strategies that meet your requirements. Implementing them altogether might not be cost-efficient or even compatible. Consider implementing strategies in a “conditional“ mode, which enables the feature after achieving a certain cart size threshold. Despite having to maintain two solutions, it can give you good flexibility and a fallback tolerance.

## Heavy rendering with atomic design

Atomic design leads to long rendering time for big carts, consuming a significant portion of display processing time.

Storefront: rework the cart page to reduce reliance on atomic design, simplifying the UI components and the overall rendering process.


## Database-intensive cart calculation

Price calculation and cart checks, like actualizing prices and availability, that involve database or third-party calls are done on the cart item level and performed on each cart change.

Backend:
- Shift from item-by-item data extraction to batch processing before looping through items in the calculation stack.
- Implement caching strategies to avoid recalculating the entire cart each time, focusing especially on resource-heavy calculation.

Storefront:
- Extract heavy operations, like price and availability updates, into dedicated async calls.
- Shift from full-cart to partial lookups for operations like removing or updating a single cart item.

Glue: Implement dedicated “lightweight“ API endpoints for partial updates or heavy operations.


## Slow session handling

While not every session request requires cart data, a big cart being part of a session leads to a slow session lookup and update.

Storefront: Move cart data to separate Redis entries, leaving only the key reference in the session.

## Concurrency in shared carts

Sharing big carts among multiple users can lead to concurrency issues.

Backend: implement the following:
- Business-level limitations for working in a shared mode with big carts.
- Locking mechanisms to manage concurrent updates more efficiently. Focus on optimistic locking.
- A versioning system for carts where changes are tracked, and real-time feedback is provided to users when conflicts occur.

## UI challenges

Displaying a full cart in an overlay on each page and managing cart pages with hundreds of items brings significant UI challenges.

Backend: Implement search and sorting mechanisms for the cart.

Storefront:
- Rethink the cart UI design to better accommodate big numbers of items and enhance UX.
- Implement the following:
- Generalized or simplified info in the cart overlay.
- Pagination when viewing cart items.
- Asynchronous rendering.
- Infinite scrolling.

Glue: Implement API endpoints that support sorting, searching, pagination, or asynchronous cart rendering.


## Placement of big orders

Converting big carts into orders results in orders with many items, complicating order management.

Backend:
- Plan the OMS design with a focus on bulk processing and asynchronous (background) operations. Be cautious with functionalities like [Splittable Order Items](/docs/pbc/all/order-management-system/{{page.version}}/base-shop/order-management-feature-overview/splittable-order-items-overview.html) to avoid creating too big orders.
- If placing an order is inevitably complex and slow, consider making it asynchronously to prevent customers from waiting. Make sure to cover the cases of overbooking and failed order placements.

Storefront: Consider UI changes, similar to the [cart UI changes](##ui-changes).

Glue: Implement an API endpoint that supports asynchronous order creation.

## Complex checkout process

When the whole cart information is loaded, handling split payments, shipping costs, and summarizing big carts during checkout can be challenging.

Backend:
- Reduce unnecessary backend checks between steps and excessive quote walkthroughs.
- Unless it’s really needed, don’t load or involve full cart information on checkout steps.

Storefront: Redesign the checkout process to better manage big carts and enhance the UX.

Glue:
- Implement dedicated “lightweight“ checkout API endpoints for specific updates or recalculations.
- Implement pagination for the `checkout-data` endpoint.
Loading
Loading