|
Posted by Norman Peelman on 01/25/07 00:30
FFMG wrote:
> In my site I have a config table, (MySQL), with about 30 entries; the
> data is loaded on every single page load. This is not the only call to
> the db, (we do a total of about 8 calls to the db).
> As with many configurations settings, once the options are set the
> values will not change much.
>
> So I thought it would be a good idea to move the data to a flat file.
> I have written a small wrapper class to first look for the file, if it
> exists then load the data from that file, if not the data is loaded
> from the database and then saved to a file.
> That way I can copy the database without worries about the cached data
> itself.
>
> It all works as expected, but the question is, did I waste my time?
> How can I do some load test on my server to see what would be better?
> Database call or flat file read.
>
> My personal guess is that the flat file will only help under very heavy
> load, (a couple of hundreds/thousand pages a seconds).
>
> What do you think?
> Will the flat file help at all?
>
> Simon
>
FFMG,
MySQL will cache queries and not go to the db if it doesn't need
to... in this case, if keeping the config data in the db is convienent
for you then leave it there. Make sure you have the following MySQL
system variables set:
query_cache_size #bytes (ei: query_cache_size 5242880, that's 5MB)
query_cache_type ? (ei: query_cache_size 1, 0 = OFF / 1 = ON / 2 = DEMAND)
So really what's happening is either MySQL will cache the result set
or your web server will cache the flatfile. The only way to test would
be to write a small script that timed both the database call and the
flatfile call.
You can get this info from MySQL Administrator or command line, or
set them in my.ini, etc.
Norm
[Back to original message]
|