I have an image gallery that allows users to upload a huge number of images at a time (this was a project requirement) and when an upload happens, the server's reported CPU usage spikes to 1000%. What modules, settings, or other modifications can be used to ease the load on the server or throttle the image processing (without delaying the loading of the next page so users don't think it's hanging)?
1 Answer
More than likely, the CPU spike is actually happening after the upload and the new gallery is being viewed.
When this happens, each of the new images will be loaded by the browser. Drupal will detect that these images don't exist on the filesystem, and punt to Image module to render out the derivatives that you defined (ie, the images in each style). If the user bulk uploaded a bunch of images, then the server may be rendering out a lot of new images in parallel.
To combat the CPU, you can try enforcing smaller max image dimensions. Smaller images take less CPU to crop/scale/etc.
You can look through the MPM configuration options and see if there is anything you cal tweak. ServerLimit
may be your only option here; I don't recall per-client option in Apache for maximum parallel connections.
Otherwise, I think you may be better served on ServerFault for this issue.