views:

107

answers:

3

Hi there. I am creating a new PHP framework depending on Zend Framework. It will be a general purpose MVC framework for web development. I am worried about 2 aspects:

  1. Logging:
    Should I use logging? Is there any substantial performance problems when using logging?

  2. Caching database queries:
    I am caching some queries from database. I am concerned about caching user related information. Suppose there are some information related to users. Like their personal info, etc. If I cache such data, for every user a cache file will be generated in my data folder. Now suppose there are 10,000 - 20,000 users online in 2 hours span of time. These means that there will be 20000 files on my folder.
    My question is that, will it affect the performance of my server. Is there any upper limit on how many files a folder can have on server.

+1  A: 

1) You definitely want logging, I'd recommend xdebug available at http://www.xdebug.org/. You can read further about the performance overheads at their site. (plus it integrates nicely with Eclipse's PHP version.)

2) I'm not really sure I'd want to cache much user information, but memcache is probably one of the better choices for caching in php (http://se2.php.net/memcache). And yeah, there's no limit on file number, and you'll probably not be going over the 32-bit filesize limit either =)

aright
If am using logging. Then why should I not use Zend_Log? Is there any problems with it?
Krishna Kant Sharma
A: 

Caching is a real problem it's almost impossible to get it right from a user/programmer perspective. I wouldn't cache things as simple as user data. This is already cached in the database. Focus more on complex queries and complete webpages (or parts of it).

Unless you have a page like stackoverflow where i see really few ways to cache anything you have to search hard and check your logfiles about what users do on your site and you will see some hotspots soon.

Memcache is not recommended by me unless you have a lot of memory (> 8GB) on your machine. Memcache works best if you throw in Memcache servers with 16 GB doing nothing else them caching things.

For smaller sites, hardware and requirements you should consider APC as this is a very low overhead cache for data and it speeds up the execution of php at the same time (you don't want to run a production server without a bytecode cache).

Lothar
+2  A: 

Do not use a file based cache. File system operations are exceptionally slow: http://imgur.com/X1Hi1.gif . Use memcached, you don't need a lot of memory contrary to what the above post says, the amount of memory you need for it is totally proportional to how much stuff you want to store, plus memcached can cull data based on access frequency.

Alex Gaynor