Some thumbs fail to load on live server

Hi everyone, I’m having problems with images on my live server and I’ve spent hours searching for a solution without success.

The website is a prototype for a public library. I have a page with search results, and for each book I display the cover image. On first load, I have 5 or 6 items for which the thumb doesn’t load, with a 503 response. Upon refresh thumbs load as expected. The issue only happens on my live server, not my local dev one.

Here is the page: Catalogue | La bib'

Here is what I get in DevTools for the failing images:

Here is what I already tried:

  • checking that gd is enabled
  • increasing php max input time and max execution time
  • enabling debug (it shows no error)
  • deleting the media and the cache folders

Here is the code in my template:

<?php if ($cover = $result->cover()->toFile()): ?>
        <picture class="ratio-2-3">
            <source srcset="<?= $cover->srcset('result_avif') ?>" width="<?= $cover->thumb('result')->width() ?>" height="<?= $cover->thumb('result')->height() ?>" type="image/avif">
            <source srcset="<?= $cover->srcset('result_webp') ?>" width="<?= $cover->thumb('result')->width() ?>" height="<?= $cover->thumb('result')->height() ?>" type="image/webp">
            <img alt="Couverture <?= $result->title()->esc() . ' par ' . $result->authorName()->esc() . $cover->alt()->or('') ?>" src="<?= $cover->thumb('result')->url() ?>" srcset="<?= $cover->srcset('result') ?>" width="<?= $cover->thumb('result')->width() ?>" height="<?= $cover->thumb('result')->height() ?>"> 
        </picture>
        <?php endif ?>

Here is my thumbs config for these images:

'thumbs' => [
        'srcsets' => [
            'result' => [
                '1x'  => ['width' => 132],
                '2x'  => ['width' => 264],
                '3x'  => ['width' => 396]
            ],
            'result_webp' => [
                '1x'  => ['width' => 132, 'format' => 'webp'],
                '2x'  => ['width' => 264, 'format' => 'webp'],
                '3x'  => ['width' => 396, 'format' => 'webp']
            ],
            'result_avif' => [
                '1x'  => ['width' => 132, 'format' => 'avif'],
                '2x'  => ['width' => 264, 'format' => 'avif'],
                '3x'  => ['width' => 396, 'format' => 'avif']
            ]
        ]
    ],

If someone can help me with this it would be awesome! (please forgive my english)

Which PHP and gd versions are running on your server?

Oh yes thank you I forgot to add:
php 8.2 and GD library Version => 2.3.3

Since my post I kept testing:

  • when I remove the elements it works (but I loose the benefits of avif or webp)
  • when I restrict the avif generation to the first 6 images it works (but I loose a little optimization).

And it doesn’t really tell me what’s the source of the issue is :smiling_face_with_tear: