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

PHP process on 100% CPU and transformations not generated by cron jobs #267

Open
1 task
luke-nehemedia opened this issue Jun 22, 2024 · 2 comments
Open
1 task

Comments

@luke-nehemedia
Copy link

I'm submitting a...

  • [ x ] bug report
  • feature request
  • [ x ] general question

Steps to reproduce

  1. Create a page
  2. Add > 20 images with pre-defined transforms
  3. Save page
  4. (optional: Open page in browser)

Description

I have the problem that the server of a client becomes unresponsive by generating many transforms at the same time. I am looking into possible solutions. I thought about optimizing queue-handling. However, the generation of the transformations will not be executed by queue jobs. I run craft queue/listen -v but cannot see any queues of generating images. However, while observing the processes on the server, I can clearly see that imager is active generating transformations, for example by the cwebp process.

Displayed errors, stack trace, relevant logs

  • no php-errors
  • no queue-logs

Additional info

  • Imager version & edition: 4.4.0 Pro
  • Imager transformer: craft
  • Craft version: Craft Pro 4.10.0
  • PHP version: 8.1.29
  • Image driver & version: Imagick 3.7.0 (ImageMagick 6.9.11-60)
@aelvan
Copy link
Contributor

aelvan commented Jun 24, 2024

Hi,

In general, all PHP processes will gobble up as much CPU as is available, there's no way to throttle this. A queue runner wouldn't make much of a difference, the actual transform will happen in PHP anyway.

There're a couple of things in your description that's a bit unclear:

PHP process on 100% CPU...

When you say "PHP process", is it the webserver php process (ie php-fpm for instance), or the PHP CLI version?

...the server of a client becomes unresponsive...

Does it become unresponsive forever? Or just while the transforms are being generated? Does it eventually become responsive again.

And since you mention that this happens on a client's server, does that mean that it works as expected locally/in other envs?

Add > 20 images with pre-defined transforms

You mean that you've set ut auto generation for the fields to which you add the images?

If so, the the generation of the transforms will happen via queue jobs, there's no other way Imager will be triggered at this point. If the queue jobs doesn't appear when running queue/listen, something is.. very wrong.

How many transforms per image are you creating? What file formats?

@luke-nehemedia
Copy link
Author

Hi

PHP process on 100% CPU...

When you say "PHP process", is it the webserver php process (ie php-fpm for instance), or the PHP CLI version?
I think it was the php process of the web server. Right now I am handling all queue jobs via a cron job that runs every minute. This seems to somewhat resolve the issue. However, I also have very limited access to the server, which makes it difficult to investigate this problem.

...the server of a client becomes unresponsive...

Does it become unresponsive forever? Or just while the transforms are being generated? Does it eventually become responsive again.

It takes a between 30 seconds and a couple minutes.

And since you mention that this happens on a client's server, does that mean that it works as expected locally/in other envs?
I don't have this particular site locally right now. But I will try to reproduce it.
I use your plugin on other sites, too. On those sites (which run on my own servers) I do not experience problems.

Add > 20 images with pre-defined transforms
You mean that you've set ut auto generation for the fields to which you add the images?

Yes

If so, the the generation of the transforms will happen via queue jobs, there's no other way Imager will be triggered at this point. If the queue jobs doesn't appear when running queue/listen, something is.. very wrong.

I thought I was doing so, yes. But I just discovered, that I do not have enabled auto-generation at the moment.
When generating transforms via the "tools"-page of the plugin, they appear in the queue.

How many transforms per image are you creating? What file formats?
It really depends. For a title image it's about 5-6 sizes in JPEG en WebP as well as a lazy-load image as jpeg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants