Re: Individual bulk e-mails - performance question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Robert Cummings schreef:
On Sun, 2008-08-31 at 17:10 +0200, Jochem Maas wrote:
Robert Cummings schreef:
On Sun, 2008-08-31 at 12:12 +0200, Per Jessen wrote:
Robert Cummings wrote:

That's easily taken care of.  Instead of a cron-job, you could have a
script running as a daemon, checking for emails to be sent every
5mins.
That's the same as running a cron every 5 minutes except now you also
need to detect if your daemon dies :) On the plus side though, you
eliminate the overhead of starting up the script every 5 minutes :)
It is not the same as it will prevent multiple scripts running
concurrently in case a batch of emails takes longer that 5 minutes. Checking if the daemon dies - I guess it's a matter of taste or
paranoia, but I don't think it's necessary when the script is
sufficiently simple:

#!/bin/sh
while true do
    <yourscript>
    sleep 300
done
I accomplish the same with cron scripts by using locks with expiry.
got an example? my cat skinning skills need to be improved, the cat
won't like it but screw the cat, right?

<?php

    $lockName = 'myLockForSomething';
    $mLock = &$this->getService( 'lockManager' );
    if( !($lock = &$mLock->get( $lockName )) )
    {
        $age = $mLock->getAge( $lockName );
        if( $age > (60 * 60) ) // 1 hour
        {
            $mLock->forceRemoval( $lockName );
        }
    }

    if( !($lock = &$mLock->getRef( $lockName )) )
    {
        exit;
    }

    // Do stuff... current process has the lock.

    $lock->destroy();

?>

Never really thought to until now... but I could easily roll the age
check into the lock code itself and pass a parameter to the get()
method. It would shrink the above code considerably.

proves tedd's adage that writing up a decent post always brings about
some level of insight :-)

I implemented my own lock class which uses directory creation and the
return value to determine if the lock was successful. Unlike file
creation (or so I read several years ago) directory creation is atomic
and works across NFS. As an added benefit, I'm able to store lock
related data into the lock directory as files.

interesting, thanks for the feedback.

I assume that this is coming from your interjinn lib, and that it's
aimed at php4 (given the ampersands your throwing about)

also your LockManager object seems to have a get() and getRef()
method which do the same ... or is that typo?

Cheers,
Rob.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux