• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
file cache performance

Hi CI guys,

I have set up a file-based cache behavior on my site, to store some portions of views, such as menus, breadcrumbs, page meta-data, etc.

The CI doc says to use file cache with care and to watch disk I/O.
How can I benchmark this area ? What are the limits of file caching ?


You would need access to your server's hardware to monitor the CPU and hard disks if you want to benchmark things.

Requesting (or generating) multiple smaller cache files can be more resource intensive than calling a single cache file, or using a better cache implementation that utilizes RAM instead of disk space. Why do you want to cache your menu and breadcrumbs and such? I'm betting there's a better way to optimize your application without utilizing the file system.

Hi Aken, thanks for your reply.

I'm caching menus and breadcrumbs — and other stuff also — because, in my application (custom CMS), they generate several SQL queries on every page. As these "views" won't change very often, I thought it was a good idea to store them in static files.

But if accessing static files slows down CPU and hard disks, I was wondering what was the best solution between SQL queries vs. accessing hard disk...

Anyway, my system works also with APC user cache, so the file-based caching would only be a fallback for servers where APC is not available.

Database caching is an option, too (I think -- I haven't really used it).

Keep in mind that simple SQL queries are pretty fast and not really that resource intensive -- if your menus and breadcrumbs are fast to begin with, maybe it's not that big of a deal. Have you compared the two?

I think database caching in CI also use local file access. So it could be the same problem, isn't it ?

And no I didn't compared yet, because I don't really know how to do it...

I think DB cache uses flat files, also, yes. But it may use fewer to store the information -- I don't know exactly how it puts together and stores query data, since I've never played around. It's just something to look into.

And what do you mean you don't know how to compare? My point is maybe the performance benefit of using cache over the DB queries is negligible -- you compare them by using zero cache and normal DB queries, then compare it with generating / using the cache files (maybe the different types).

The way CI works is that it checks early on if a valid cache file exists for the requested URL and if so, loads that one file and exits without loading the controller/model/libraries/helpers/views/etc files. No queries to the database, no php processing of whatever your controllers and models are doing or anything else. Just loading a single post-php processed html file. That will always be faster and more efficient.

CroNIX, that's the way the Output library's cache function works. He's talking about the Cache driver.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.