CodeIgniter Forums
file cache performance - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: file cache performance (/thread-56728.html)



file cache performance - El Forum - 01-15-2013

[eluser]djsuperfive[/eluser]
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 ?

Thanks



file cache performance - El Forum - 01-15-2013

[eluser]Aken[/eluser]
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.


file cache performance - El Forum - 01-15-2013

[eluser]djsuperfive[/eluser]
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.


file cache performance - El Forum - 01-15-2013

[eluser]Aken[/eluser]
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?


file cache performance - El Forum - 01-15-2013

[eluser]djsuperfive[/eluser]
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...


file cache performance - El Forum - 01-15-2013

[eluser]Aken[/eluser]
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).


file cache performance - El Forum - 01-16-2013

[eluser]CroNiX[/eluser]
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.


file cache performance - El Forum - 01-16-2013

[eluser]Aken[/eluser]
CroNIX, that's the way the Output library's cache function works. He's talking about the Cache driver.