We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14605
    • 40 Posts
    Hi

    I am currently using Gallery and Gallery item heavily in my site, which are great tools and allow for great flexibility in image management through the site.

    However, Gallery and Galleryitem use phpThumb, which spawns a connector.php instance, which runs in a separate Linux
    process for each image generated (even if the image is cached).


    The problem with this is that in my current hosting package I have a maximum of 16 parrallel processes available, on a shared server.
    At peak times or during simultaneous hits of pages with lots of images, this causes a server 500 error.

    So when running the following url, i see processes on the server, as follows (this is a snapshot of processes during the loading of the following url, so not necessarily 16 processes at this point)

    ps -ef
    
    3409642  15389  6166 11 12:32 ?        00:00:00 /usr/lib/cgi-bin/php5 /.../home/php/v2/v3/modx/assets/components/gallery/connector.php
    3409642  15400  6164 17 12:32 ?        00:00:00 /usr/lib/cgi-bin/php5 /.../htdocs/home/php/v2/v3/modx/index.php
    3409642  15414 15389  0 12:32 ?        00:00:00 sh -c which convert 2>&1
    3409642  15419 19349  0 12:32 ?        00:00:00 /usr/lib/cgi-bin/php5 /...htdocs/home/php/v2/v3/modx/assets/components/gallery/connector.php
    3409642  15448 13259  0 12:32 pts/0    00:00:00 ps -ef
    3409642  15450 30235  0 12:32 ?        00:00:00 /usr/lib/cgi-bin/php5 /.../home/php/v2/v3/modx/assets/components/gallery/connector.php
    3409642  15451 15419  0 12:32 ?        00:00:00 sh -c convert --version 2>&1



    I am wondering if there is a way around this. Is there any way of executing phpThumb without spawning a new linux (via php shell_exec) process each time an image is retreived?

    I would be really grateful for any discussions / advice around this.

    Upgrading my hosting package is feasible, but I am thinking there must be another way.

    I don’t want to change / rewrite the way that Gallery or Gallery item works either, as these tools have
    taken a massive load off my development time, and I want to be able to upgrade Gallery seamlessly (without having to include any hacks!!)

    This is related to my last post, where images were intermittently not displaying...

    http://modxcms.com/forums/index.php/topic,63184.0.html

      • 21838
      • 284 Posts
      1&1 hosting is ********. Change to another provider if possible. The performance and service is horrible. I’ve never seen that issues before but on 1&1 hosting-packages it appears from time to time.
      Just upgrading could help but I suggest to move to another provider with better support and performance (not strato)
        MODX Free Template Base: MODX-Boilerplate | my blog (lots of MODX stuff) | my gitHub (translations) | MODX User Groups Germany (Facebook)
        • 19388
        • 297 Posts
        I had some problems with Gallery and my hosting provider too. It would be nice to see performance improved. For example, "Gallery" ( menalto ) creates thumbnails and images on upload and then this static images are delivered to users. Gallery for MODX do it on the fly but has a cache system. The administrator of my hosting provider told me performance was not so good and I was not allowed to use it anymore. I don’t know if believe him or not, because Gallery uses cache for images, and with Gallery ( menalto ) I have no problems at all.
          • 14605
          • 40 Posts
          Thanks guys for your responses...

          For example, "Gallery" ( menalto ) creates thumbnails and images on upload and then this static images are delivered to users.

          I like this idea... Much more traditional approach for dealing with images...

          With Gallery ( menalto ) can you specify multiple thumb sizes? For example i have small thumbs on the home / product pages... and larger thumbs on the category listing pages.

          I do really like the way Gallery works though... The reason being, if my client decides they want to the thumbs to change size, I make a small change to 1 or 2 chunks (i.e width and height in the call to gallery and galleryitem) and the changes will cascade through the site automatically... albeit with the images having to be generated again... I believe, by your description of menalto that should the client request a similar change, the images would have to be uploaded again?

          I am try to figure out the possibility of staying with Gallery, but rewriting slightly so that when the image is cached, i generate a standard img tag...

          <img src ="/path_to/cache/cached_image.jpg" />
          ]

          and when the image is not cached, generate the connector.php tag:

          <img src ="/path_to_gallery/connector.php....width=100&height=100&etc..." />
          ]

          This would mean I would have to check this before outputting every gallery/gallery item image tag... However, since the call will be made in the same thread (via a snippet call) as modx’s index.php, this will not generate a new thread (via shell_exec) and thus should not threaten the parallel processing limits of any shared hosting package.

          My only concern with coding the above is how do I use the same algorithm as phpThumb to check if the cached file exists? phpthumb cache files look like this...

          phpThumb_cache_freewaymedical.co.uk_src43fd9f48d8361c087615b1d67c59a603_par14ea58a188554046c2f1dc724d84c86d_dat0.jpeg