Need to decrease file count or host will cut me off...which files can I delete?

tbladmin

Joined: 2008-05-27
Posts: 14
Posted: Thu, 2010-08-19 16:22

I'm using BlueHost and was notified that I need to delete a bunch of files to get below the limit of 50,000 files. At the time when I was first notified of this, I had 210082 files and pretty much all of the top 20 most heavily populated directories were some variation of /home/mysite/public_html/gallery/g2data/cache/entity/x/x where x is a number from 0-9.

I ran the Optimize database, Delete template cache, and Delete database cache tasks along with some other cleaning up and it only got me down to 106607 files. According to my userquota file, I still have 35 directories that follow the path above that hold more than 1000 files.

I have read a few things on here about what can and can't be deleted, but I couldn't come up with a firm answer..or maybe I was just worried that I would foul something up if I went and deleted anything manually. Anyway, here are my questions:

1. Can I safely delete anything after the /cache folder? By safely I mean without triggering tasks on the server that may put me in violation of other terms of service. I have read some say that you can, and some say that you cant.

2. What is building so many files and what are they for? In other words, approximately how many behind-the-scenes files are required for each photo in my gallery?

3. If I manage to get under 50k files, is there a formula that I can use, even a rough one, to predict when I may hit this limit again? Something like 10,000 photos = xxxxx files?

Thank you all for the help!


Gallery version = 2.2.4 core 1.2.0.6
PHP version = 5.2.13 cgi-fcgi
Webserver = Apache/2.2.16 (CentOS) mod_ssl/2.2.16 0.9.8l DAV/2 mod_auth_passthrough/2.1 FrontPage/5.0.2.2635
Database = mysqlt 5.1.47-community-log, lock.system=flock
Toolkits = ArchiveUpload, Dcraw, Exif, Getid3, LinkItemToolkit, Thumbnail, Gd, ImageMagick, NetPBM
Acceleration = none/86400, none/86400
Operating system = Linux box407.bluehost.com 2.6.28-10.40.intel.E1000E.BHsmp #1 SMP Thu May 20 14:03:42 MDT 2010 x86_64
Default theme = PGtheme
gettext = enabled
Locale = en_US
Browser = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
Rows in GalleryAccessMap table = 14
Rows in GalleryAccessSubscriberMap table = 15518
Rows in GalleryUser table = 2
Rows in GalleryItem table = 15516
Rows in GalleryAlbumItem table = 310
Rows in GalleryCacheMap table = 0

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2010-08-19 16:55

remove any gallery2/modules/unused_module and gallery2/themes/unused_theme
goto gallery admin -> maintenance -> clear template cache and database cache
The cache files will build up again, the best way to keep them down is to only use one theme.
Also may be time to upgrade your account w/ Blue Host.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Thu, 2010-08-19 16:59

Ah the continually getting crappier and crappier bluehost who didn't have a limit, then specified a 100,000 file limit has lowered it to 50,000. Sorry, you're not going to get many G2 installs below that.

Short answer, find a new host. 15,500 images = at least 46,500 files with G2 just for the images alone (thumb, resize, fullsize). If using caching then it's even more. This isn't even taking into consideration the 1,000s of files a typical G2 install has. Though it appears that a "minimal" install (bare functionality) has only about 853 files and 130 folders (which also most likely counts against your file count). So a minimal G2 install has 983 files as far as bluehost is concerned.

If you're using caching, then you're looking at 6 files for ever image, plus some additional files for cached DB calls, pages, etc. I believe the estimate was about 10 files for each image, IIRC.

Best advice you'll ever get for choosing a host (in my not so humble opinion, IMNSHO);
1) Don't shop based on price alone. You get what you pay for.

2) NEVER use a host that advertises ANYTHING as "unlimited". There is no such thing as unlimited disk space, bandwidth, domains, mailboxes, databases, etc. You can abuse them all. For example, a host that advertises "unlimited" domains will surely cut you off or find some clause in their TOS that says the 50,000 domains you've added are a violation of their TOS.

In short if you want to stay with bluehost. Turn off caching. Delete all cached pages (database, template, etc) Uninstall and delete as many plugins and themes as you can. Delete probably around 10,000 photos. Don't use any other apps, you might get away with something small like Wordpress though. Have fun :)

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2010-08-20 02:04
Quote:
1. Can I safely delete anything after the /cache folder? By safely I mean without triggering tasks on the server that may put me in violation of other terms of service. I have read some say that you can, and some say that you cant.

You can delete anything in /cache if you want. But if you delete /cache/derivatives then all your thumbnails and resizes need to be rebuilt, as that's where they live.

Quote:
2. What is building so many files and what are they for? In other words, approximately how many behind-the-scenes files are required for each photo in my gallery?

Let's see: the original file, plus a cached entity record, plus each derivative's jpg, plus a cached entity record for each derivative.

So if you have the original file, a thumbnail, and one resize (or a watermarked version) then six files for each image.

Plus a cached file for each database query. Unfortunately G2's architecture is very heavy, and slow, particularly on the db query side and (unsurprisingly) when it comes to creating new graphics (resizes etc) - so caching all these things makes G2 run at a reasonable speed. At the expense of a lot of files.

Bluehost cram thousands of websites onto each CPU box; they're great for three-page static websites, but not up to running anything more than a small G2 installation, and you'd be wrong to expect that of them, for the price.

See also:
http://gallery.menalto.com/node/80120

 
tbladmin

Joined: 2008-05-27
Posts: 14
Posted: Fri, 2010-08-20 05:25

Thank you all for the great advice.

I'll definitely consider leaving Bluehost for a more Gallery friendly provider, but in the meantime I need to make a few changes to keep at least a part of my Gallery running.

A forum post pointed me to this corner of the Gallery config: http://www.mywebsite.com/gallery/lib/support/index.php where there are options for PHP Info, Cache Maintenance, Filesystem Permissions, and GD. Would deleting the cache as mentioned above by alecmyers be done here? I'm sure it's advisable to do it through some sort of Gallery API instead of just going into my File Manager and deleting files manually.

Also, alecmyers mentioned that the thumbnails will need to be rebuilt if I delete the /derivatives directory. Would the process of rebuilding the thumbnails begin immediately after I delete the /derivatives directory or would it happen on an "on access" basis as visitors view my albums? I don't have a lot of traffic at all, mostly family who seem to forget the site exists unless I send out constant updates, so an "on access" basis wouldn't impose a heavy load on the server if that is how it's done.

I'm also going to trim some of the albums that get little to no traffic and see if that helps until I can decide on a final plan. Thanks again.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2010-08-20 13:11

Some more discution:
http://gallery.menalto.com/node/73277

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2010-08-20 22:24
Quote:
I'm sure it's advisable to do it through some sort of Gallery API instead of just going into my File Manager and deleting files manually.

No, it makes no difference how you delete the files; you can just use the file manager (I do it from a shell prompt, if it's ever necessary).

Quote:
Also, alecmyers mentioned that the thumbnails will need to be rebuilt if I delete the /derivatives directory. Would the process of rebuilding the thumbnails begin immediately after I delete the /derivatives directory or would it happen on an "on access" basis as visitors view my albums?

It's "on-demand", but not necessary "on-view" - sometimes Gallery needs information about a derivative that's only available after it's been built (like its height and width) which means that it can be hard to predict when a thumbnail is going to be created (or when 600 need to be created all at once) - so I advise never removing anything in the /cache/derivatives directory. If the re-creation stalls and the derivative is marked as "broken" it can be a real pain to fix.