Gallery3 speed

Infopic
Infopic's picture

Joined: 2011-03-30
Posts: 25
Posted: Thu, 2011-04-07 09:41

Hi,
Just wanted to see how to make my Gallery3 as fast as Bharat on his new .../photos website. Mine is basically Wind theme, but my pages take around 4 sec to load, as opposed to his around 2 sec. The home page was especially slow, so I've put 12 Albums instead of the 48 I started with which made it better.
Here's the link, which I'll remove a bit later for privacy. "Removed"
I've followed a couple of the thread about some speed issues, and I've removed the php.ini file and put the config.php cache at 3600 which have made a small improvement.
I'm on a shared server with Cpanel
Apache- 2.0.63
PHP 5.2.9
Perl 5.8.8
MySQL version 5.0.92-community
Operating system linux
Server Load 2.22 (1 cpu) This fluctuates from .3 to as high as 5.5 (My 4 sec time is when the load is below 1)

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Thu, 2011-04-07 12:55

Your site loads relatively fast to me for being in the UK and I'm on the west coast in the US. It's not super slow like I've seen a few others with funky configurations (network mounted disks, cheap network attached storage devices, etc) So I can only think it's your host's network/server (both web and database) configuration or they are just out-right overselling and overloading their servers with accounts.
____________________________________________
Like Gallery? Like the support? Donate now!

 
Infopic
Infopic's picture

Joined: 2011-03-30
Posts: 25
Posted: Thu, 2011-04-07 13:52

i think you're right. I contacted them, and they've moved the sight to a new partition, which I think has improved things. I'll see how it goes. Thanks for the feedback

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Thu, 2011-04-07 15:32

I'm a long way from both of you. I thought that it wasn't bad. The pages themselves load fast as do the thumb images, but I thought that the resize images were a touch slow. This is why I like the greydragon theme with its image preloading - it increases the impression of speed in situations like this.

U-G

Edit: I timed your site using Yahoo Yslow and I think it's ok for a shared server. I had load times like this when I was on a shared server.

 
Infopic
Infopic's picture

Joined: 2011-03-30
Posts: 25
Posted: Thu, 2011-04-07 19:06

I will check out Grey Dragon. The problem I now have is that by moving the site to the partition the Albums have "the album... is not writable" when you click on them in admin mode, means I can't upload photos to them. New Albums are ok. Dave's suggestion on a previous post is to ask the host to change the permissions recursivey on Gallery3/var.
"http://gallery.menalto.com/node/101233"
I've asked them, but they seem a tad confused, I'll ask again tomorrow. I wonder if there's anything I can do my end. There's a Cpanel for the website.
Thanks

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Thu, 2011-04-07 19:17

A bit of advice, take it or leave it. But find a new host or at least keep that in mind when (not if) you have more problems. If changing permissions recursively confuses your host, there's a fundamental problem there...

In short, they need to make it so the user Apache (or PHP) run as has read/write access to all files and directories under your gallery3/var directory (including your gallery3/var directory)

____________________________________________
Like Gallery? Like the support? Donate now!

 
Serge D
Serge D's picture

Joined: 2009-06-11
Posts: 2466
Posted: Thu, 2011-04-07 20:42
Infopic wrote:
There's a Cpanel for the website.

* check in CPanel if you have file browser, if you do check if there is an option of setting permission for the folder. Most CPanels I've seen had it
* do you have FTP access? if so, you should able set permissions from FTP client

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Fri, 2011-04-08 01:13

I had a similar experience recently. I moved a site by packing it into a .tar.gz and unpacking it at the new location. I got "the album... is not writable" error messages. This happened several times and I can only conclude that it was caused by the unpacking process changing the permissions on the folders.

I'm not sure that CPanel will enable you to reset permissions recursively. It's probably only the folder permissions you need to change, and if there's not too many you could use CPanel to do it one at a time. However it's more likely that there are too many folders. As Serge said, the current crop of FTP clients have the ability to change permissions recursively. I've used FireFTP and Filezilla. You only need to change folder permissions on the albums, thumbs and resize folder hierarchies, not on the files. My understanding is that the folders in these hierarchies need 777 permissions.

There is another potential problem that I encountered, but it's unlikely in your case. If PHP runs as "nobody" and the files it creates are owned by "nobody" you wouldn't be able to overwrite them. The average shared user can't change these. But as the problem doesn't happen with new albums I'm fairly certain that the problem is that folder permissions were reset in the move.

U-G

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Fri, 2011-04-08 02:39

As another comment on your first post, I found that a page load of about 4 seconds is typical on a reasonable quality shared server. You might do a bit better but probably not by all that much. Greydragon will help with its pre-loading, but equally it is a bit "heavier" than the Wind theme which will partially offset the gains from pre-loading. I moved to a faster host and now generally get around 2 seconds. Nivekiam has a super-fast server, but IIRC it is unmanaged and I'm not prepared to have to manage a server in order to get a further speed improvement. 2 seconds is ok IMHO.

So there are modest gains to be had from various config and theme options, but the larger gains come from faster (more expensive) hosts. People don't want to hear this, but it was my experience, and believe me, I tried a lot of things before I moved hosts.

U-G

 
Infopic
Infopic's picture

Joined: 2011-03-30
Posts: 25
Posted: Fri, 2011-04-08 08:26

Great answers! I went to Cpanel and there is an option to change the permissions. I changed each folder and sub folder's permission to 0777 (from 0755) and that did the trick, everything is back to writable. Var I left to 0755 as it didn't seem to affect it. Thanks for the insight. In regards to the host, you're right, they are basic. I'll migrate to a more professional outfit ASAP.
Have a nice day,
JL

 
inposure
inposure's picture

Joined: 2010-04-23
Posts: 304
Posted: Fri, 2011-04-08 09:27

If it takes 4 secs to render a Gallery page, how long does it take to render a reasonably large Wordpress page then? 10 secs?

On a small VPS execution completes after 0.35-0.45 secs, and the entire page is delivered within a second, i.e. more or less instantly. Add latency for faraway visitors and crappy lines, of course.

But whatever the server environment, there are a few things one can do to speed up Gallery.

1. In application/config/config.php, make the following changes

$config["internal_cache"] = 3600;
$config["log_threshold"] = 0;
$config["display_errors"] = FALSE;
$config["render_stats"] = FALSE;

2. Go for the smallest set of modules possible. Do you really need search? Disable all modules you don't need and choose a lightweight theme.

3. Remove modules that are not used and will never be used. g2_import and digibug can be removed from the modules directory altogether, and unused third party stuff should be deleted altogether.

4. Enable overall compression in apache or PHP or in application/config/config.php for Gallery (either alternative, but only one, in that order).

5. Optimize your database on a regular basis with phpmyadmin, cpanel or whatever. Tables "caches" and "sessions" can and should be truncated (emptied, not deleted) every now and then to prevent Gallery from expanding into infinity.

6. Make sure things work as intended. The OP's cache doesn't work properly, it returns the following: Expires: Thu, 19 Nov 1981 08:52:00 GMT
This is remedied by adding the following to .htaccess , in the<IfModule mod_php5.c></IfModule> section:

php_flag session.cache_limiter public

There is other stuff you can do as well, like access control for bots (like Baidu, .ru scrapers, .in sploggers and so on), but that requires a more thorough knowledge, and is also a general problem.

--
http://inposure.se/

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Fri, 2011-04-08 11:49

I'd be interested whether the OP can get significant speed improvements using this tweaks. I said that I got modest improvements. If you use the Wind theme and almost no modules, you will get more, but at this point you question why you're using Gallery3 if you have to use such a basic theme and no added functionality in order to get closer to acceptable speed.

It was at this point that I decided to move hosts and pay a bit more.

U-G

 
Infopic
Infopic's picture

Joined: 2011-03-30
Posts: 25
Posted: Fri, 2011-04-08 14:27

Gulp! I implemented all your suggestions, and I seemed to have gained 1 sec on most executions. Compression I set to 6, choice was between 1-9. I'm not sure how to optimize the database with Cpanel so I left it. Amazing the VPS difference, your gallery is fast!!.
Thanks for the tips. I'm going to start another thread "http://gallery.menalto.com/node/101636", as the transition of my Gallery has thrown up another problem, I can't upload anything more than 1.5 Mb.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Fri, 2011-04-08 15:44
Quote:
Compression I set to 6, choice was between 1-9

Set it to 9, it'll make things a bit faster for transfer. That setting shouldn't be effecting image quality, but compressing the pages smaller to make them smaller to transfer. It does make the server work a bit harder, but really it shouldn't notice a difference at all.

Quote:
Amazing the VPS difference, your gallery is fast!!.

Not all VPS are created equal.
http://journal.uggedal.com/vps-performance-comparison/

With a VPS you are guaranteed (or should be) a certain amount of resources and are not sharing a server with 100s or 1000s of other accounts.... I've used shared hosting for 10+ years and went through a lot of changes before I settled on Pair (www.pair.com) about 8 years ago. They are an excellent host, but I finally got tired of sharing a server and also wanted to be able to do somethings that you can't do on a shared server. So I headed over to Linode (because I can't afford Pair's managed VPS service)
____________________________________________
Like Gallery? Like the support? Donate now!

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Sat, 2011-04-09 01:40

There were a few config.php tricks plus the php compression idea that I hadn't seen before. So thanks for those inposure. I'm probably at about 1.5 secs now according to YSlow, although the apparent speed is much faster because these figures include greydragon preloading the next image after the page is displayed. Also there is a bit of a lag loading the next random image in the imageblock module, which doesn't really affect the impression of page speed, but is counted in the YSlow numbers.

Still it would be interesting to know how much of Infopic's speed improvement was due to these tweaks and how much was due to running a fairly minimal install (theme, modules). This minimal approach is ok if you are happy with a minimal gallery, but if you want more and speed as well, then consider your host.

I have a question re compression. I've enabled it in my VPS php.ini config file, but I don't seem to have the option for setting the compression level. Here is the extract. Is this normal? Would I be better setting compression in config.php?

; Transparent output compression using the zlib library
; Valid values for this option are 'off', 'on', or a specific buffer size
; to be used for compression (default is 4KB)
; Note: Resulting chunk size may vary due to nature of compression. PHP 
;       outputs chunks that are few hundreds bytes each as a result of 
;       compression. If you prefer a larger chunk size for better 
;       performance, enable output_buffering in addition.
; Note: You need to use zlib.output_handler instead of the standard
;       output_handler, or otherwise the output will be corrupted.
zlib.output_compression = On

U-G

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Sat, 2011-04-09 04:57

OK, I've set the compression with the help of support. I have a supplementary question. From a Gallery3 perspective, is there any advantage in making this setting server-wide in the VPS php.ini file rather than the G3 config.php file? I.e. are there any performance benefits?

I ask because I want to set this to level 9, but as the VPS will be used for hosting other sites I am disinclined to make the change server-wide.

U-G

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sat, 2011-04-09 05:25

Read about it :)

http://www.php.net/manual/en/intro.zlib.php

It'll make the server work a little harder, but it'll make all pages served by it smaller. However, do note that some things will break if you have it on by default. For example, the little bit of file optimization that G2 does (it combines a few JS files) and then tries to gzip them. I've you're compressing all output at the server level and have an app like G2 which wasn't checking for compression, you'd get a double compressed file and browsers don't know how to deal with that and it's just garbage. You'd really see this with the breakage of the plugins page in G2.

Personally, I'd probably do it on a site by site basis, that way if it does interfere with something you can disable it quickly and not effect the rest of the sites on the server.
____________________________________________
Like Gallery? Like the support? Donate now!

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Sat, 2011-04-09 07:17

Thanks. I had found that documentation, but it didn't address how best to implement it in G3.

Doing it on a site by site basis is also my inclination. Server wide settings can't be configured so as to break things.

U-G

 
dave8401

Joined: 2009-06-01
Posts: 129
Posted: Sun, 2011-04-10 22:09

@inposure: Thanks for all those tips regarding performance ... they do matter!

 
snackmaster
snackmaster's picture

Joined: 2005-11-20
Posts: 135
Posted: Mon, 2011-04-11 02:08

Ditto. Thank you inposure. The config.php and other tips above definitely improved site speed for me. Went from a C to a B on YSLOW and page loads were definitely faster, not a little but a lot.

 
snackmaster
snackmaster's picture

Joined: 2005-11-20
Posts: 135
Posted: Tue, 2011-04-12 01:18

Need for speed... with the settings above it appears I have no expire headers being set. I've tried enabling Cache settings via .htaccess and local PHP.ini. No luck. Any tips here?

Host = Site5, Gallery in /gallery, Wordpress is in root /. Wordpress is using W3 Total Cache and working well and perhaps is the issue?

I've tried variations here:
http://www.askapache.com/htaccess/apache-speed-cache-control.html

Feedback for /Gallery no matter what I set in .htaccess or PHP.ini:
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip

Feedback from Wordpress root
Cache-Control: public, must-revalidate, proxy-revalidate
Expires: Tue, 10 Apr 2012 11:27:57 GMT
X-Powered-By: W3 Total Cache/0.9.1.3
Pragma: public
Keep-Alive: timeout=5, max=98
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Content-Encoding: gzip

 
dave8401

Joined: 2009-06-01
Posts: 129
Posted: Mon, 2011-04-11 18:09

Same here. Although I applied the php_flag session.cache_limiter public fix, the cache shows 1981.

 
snackmaster
snackmaster's picture

Joined: 2005-11-20
Posts: 135
Posted: Tue, 2011-04-12 01:21

Same for me Dave, 'php_flag session.cache_limiter public' nor the default code from Gallery's .htaccess which I've uncommented
<IfModule mod_expires.c>
ExpiresActive On
# Cache all files for a month after access (A).
ExpiresDefault "access plus 24 months"
#Do not cache dynamically generated pages.
ExpiresByType text/html A1
</IfModule>

Weird as it's working for WordPress via .htaccess but not for Gallery. I've pinged my host for help.

 
Infopic
Infopic's picture

Joined: 2011-03-30
Posts: 25
Posted: Tue, 2011-04-12 16:28

On the speed front, my gallery seems to be faster when browsed through Internet Explorer (at the library, PC) than Firefox (at home, Mac). Is there a reason for this? Also the index page when first loaded takes much longer compared to the others.
JL

 
snackmaster
snackmaster's picture

Joined: 2005-11-20
Posts: 135
Posted: Wed, 2011-04-13 00:05

Got it working. With all 6 of @inposure's tweaks the .htaccess Expires code below and using CSS min my YSlow score went from C to A and page loads went from ~2-4secs to ~0.8-1.5sec for Album and image pages.

Host - US based shared hosting @ $8 a month
Gallery - 3.01 Wind Theme modified
Running - Random image, Thumb Navigator, Popular Tags (Modules that execute & display for visitors)
Disabled SlideShow, FancyBox and Search modules
Disabled Larger Images in photo.html.php - loading full size image directly (speed and disk space - if you don't need large images)

Header Expires

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$">
  ExpiresActive On
  Header set Cache-Control "public"
  ExpiresDefault "access plus 2 years"
  Header unset ETag
  FileETag None
  Header unset Last-Modified
  Header set Last-Modified "Tue, 1 Apr 2012 00:00:00 GMT"
</FilesMatch>
 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Wed, 2011-04-13 03:43

I agree that these are all good tips, and I wish that I had seen some of them when I asked much the same question several months ago. I'll try more of these when I'm back in front of my production PC, although I'm not prepared to revert to the Wind theme.

But I have a question. Did you clear your browser cache first before recording these times? My experience has been that once there is a high degree of caching, and if you keep browsing the same pages, then you will get an unrealistic impression of how fast the site is for a new user.

U-G

 
snackmaster
snackmaster's picture

Joined: 2005-11-20
Posts: 135
Posted: Wed, 2011-04-13 12:42

No need to use any specific theme, I noted Wind for reference only. Balancing theme features and modules vs speed would be the key whatever Theme you're using. And yes always browser cached was cleared. The times are dependent on my connectivity and my hosts response times.

 
undagiga

Joined: 2010-11-26
Posts: 693
Posted: Thu, 2011-04-14 01:01

It was just that inposure's list included using a lightweight theme, and that would normally be interpreted as Wind. In my testing it was faster to load the text than Greydragon, but then you have to wait for the image to load, whereas Greydragon preloads the next resize image. For an image that isn't preloaded, Wind is faster, but in my testing not earth-shatteringly so.

Can you please explain how you applied CSS Min to your gallery?

Is there any neater alternative to using "Tue, 1 Apr 2012"?

U-G

 
snackmaster
snackmaster's picture

Joined: 2005-11-20
Posts: 135
Posted: Thu, 2011-04-14 03:04

CSS Min - I copy my CSS file contents and paste into CSS Mins first box, press Crunch and copy the generated code from the second box. Paste that into your CSS file, save and post to your site. I then undo the CSS min change and save my file in readable format.
You can use whatever date you want as long as it's in the past for the above example. I'm new to all this so take this advice carefully and check out a resource like this one where with many examples: http://www.askapache.com/htaccess/apache-speed-cache-control.html