Hi. I'm just pondering which to use - either write to separate files for each user, or write to a single table in a MySQL-database, and retrieve from that. Scenario: I have a counter-script on my webpage which works as follows: User's first visit: make a file, write "1" to that file (file is stored with the visitor's IP as name). User's subsequent visits - open file, write "+1" to the number already in the file, display result Also, write a "+1" to a file holding total number of visits site-wide for each time something is written to individual files. So, for every single IP, one gets a file containing the number of visits for that IP. This hasn't been a performance issue, yet, but I was thinking about changing the "write to file" approach to "write/retrieve from database" approach. Any thoughts? This is a low-traffic website, but even so, the total amount of files in the "counters" folder is now at 12500 files. Given that number, I'm assuming a database table of (currently) 12500 files, maybe growing with about 400-800 rows pr. month. (As I said, the number of NEW unique visitors aren't that high). Any thoughts on what would be best, performance-wise? Currently the look-up of the files is instant. I'm assuming it would also be more or less instant when looking up from a database at this level. Where would the problems begin to occur? I'm thinking "what if the traffic hits the roof" and it has to do several (hundreds, maybe thousands) of file lookups at "the same time" more or less. I'm assuming that would put a lot higher stress on the server than a DB-query?
The more it grows, the "more faster" the database will be. Directories with very large numbers of files (hundreds of thousands or more) start to get slow. Your host may have an inode limit for your account (if using shared hosting). And if you ever need to search across all those files, you'll start to cry.