craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
218 stars 170 forks source link

[3.1.5]: Updating search indexes for Product elements always out of memory #2822

Closed wblommaert closed 2 years ago

wblommaert commented 2 years ago

What happened?

Description

For one of our clients we are running a Craft CMS & Craft Commerce setup with a product count of about 1800 products, offered in 4 different languages. The products themselves have a fairly large amount of custom fields containing detailed product information and most of these are searchable because they contain textual information. To keep product information in sync we have implemented a custom module. Feed Me wasn't an option due to the nature of the external system. The module reads and processes XML files containing product and category information. The syncing mechanism itself poses no issues. The updating of the search index after syncing has stopped working recently. The error we're being presented with is "The process has been signaled with signal 9", which seems to be coming from Symfony and indicates we ran out of memory.

Screenshot 2022-05-23 at 08 22 16

When the Commerce side only contained about 1200 products, we would have the occasional failed "Updating search indexes" job, but usually a retry or the next iteration of it would pick it up and finish. Nowadays however it no longer manages to get through the entire job. We've already tried increasing the memory limit for PHP to 512MB but this only manages to add a bit more to the progress percentage before eventually failing as well.

Screenshot 2022-05-23 at 08 22 05

Note: We are aware both Craft CMS and Commerce are outdated, but I couldn't find anything related to performance improvements on the "Updating search indexes" job, so I assumed them being outdated has no influence on this issue.

Steps to reproduce

  1. Craft Commerce store with roughly 1800 products in 4 languages/sites with a large amount of custom fields that are searchable
  2. Trigger "Updating search indexes" job with settings to index for all sites and Product element type
  3. After a while the job will fail with error "The process has been signaled with signal 9"

Expected behavior

Allow updating the search index for products without the job failing.

Actual behavior

The "Updating search indexes" job fails when we trigger it for the Product element type and all sites.

Craft CMS version

3.4.30

Craft Commerce version

3.1.5

PHP version

7.3

Operating system and version

Ubuntu 16.04.6 LTS

Database type and version

MySQL 5.7

Image driver and version

Imagick 3.4.3

Installed plugins and versions

Craft Commerce | 3.1.5 Feed Me | 4.2.3 Freeform | 3.6.11 Imager | v2.4.0 Minify | 1.2.10 Mollie for Craft Commerce | 2.1.1 Redactor | 2.6.1 SEOmatic | 3.3.5 Super Table | 2.5.0

lukeholder commented 2 years ago

It sounds like you are triggering the search index update in your module - and it looks like you are updating the index for every product in the one job. Could you possibly add a search index update to the queue per product or batch them - instead of all products in a single job?

wblommaert commented 2 years ago

Hi @lukeholder, thank you for the suggestion. This seems to be one of the approaches that works best for us. We've also increased the amount of runners processing the queued jobs to deal with the increased amount of concurrent jobs and to speed up the processing in general. For now this seems to be a very scalable solution!