Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Lots of cachefiles, a problem?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Eindbaas
Smarty Rookie


Joined: 16 Apr 2007
Posts: 28

PostPosted: Thu May 17, 2007 11:44 pm    Post subject: Lots of cachefiles, a problem? Reply with quote

Well, that's basically the question. Are there any drawbacks for having tenthousands of cachefiles (assuming there's enough space on the hd).
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri May 18, 2007 2:25 pm    Post subject: Reply with quote

The only drawbacks would be the speed of your file system, and how quickly it can find a file within a directory.

If you are in unix, you can write a cron to clean up caches that have not been accessed in awhile.

Code:
# remove all cache files stale for five days or more
find /path/to/cache_dir/. -type f -atime +5 -exec rm -f {} \;


reiserfs and xfs are very fast at directory scans, and do not have the limitation that of ext2:

Quote:

The limit of ext2 sublevel-directories is about 32768. If the number of files in a directory exceeds 10000 to 15000 files, the user will normally be warned that operations can last for a long time. The actual limit of the number of files in a directory is very theoretical, because before reaching the limit of 1.3 × 10^20 files it will become hard to find new well-defined file names.
Back to top
View user's profile Send private message Visit poster's website
Eindbaas
Smarty Rookie


Joined: 16 Apr 2007
Posts: 28

PostPosted: Fri May 18, 2007 4:09 pm    Post subject: Reply with quote

mohrt wrote:
The only drawbacks would be the speed of your file system, and how quickly it can find a file within a directory.

But does that speed change when there are more files in the directory? All i ever do there is check whether a certain file (with a certain cache_id) was cached (using is_cached) and let smarty display it.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri May 18, 2007 7:00 pm    Post subject: Reply with quote

The speed is going to be determined by your filesystem's ability to scan a directory for files. Typically this is going to be negligible, but if your file cache grows to 10,000+ files and you have a high traffic website, the performance could become an issue. About the best bet is to benchmark yourself, as every environment is going to be different.

My very general rule of thumb (not tested): if you have more than 10k of cache files, turn on $smarty->use_sub_dirs. That will really help break down the number of files per directory.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP