in reply to Improving efficiency - repeated script hits at small interval
I wrote a startup script for mod_perl to
(1) set up a persistent database connection (in my case, MySQL),
(2) declare some global variables to use within the script.
(3) pre-load the script to be used by the outside world
Changes that will be referenced "every now and then" can be updated quickly in MySQL without problems. Remember to keep your tables small and properly indexed. The fewer UPDATE statements, the better. My final solution used one UPDATE statement, which meant the table was locked for a minimum amount of time without a chance of data corruption from an ill-timed SELECT statement by another child process.
Changes that must be immediately available to all can be stored in the global variable(s). Any future children will instantly have the correct info.
Doing this, I was able to maintain correct information without problems with up to 30 script calls per minute. No storage of session data was necessary. The script for the outside world becomes very small -- get the info, make UPDATEs if necessary, and spit out an answer...
|
|---|