1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Few questions when and how to use sleep();

Discussion in 'PHP' started by Agent_Smith, May 30, 2008.

  1. #1
    Hello,

    Just wondering,

    With my mass email program, should i use sleep to wait a second after each email to reduce the sudden email load?

    Also,

    With my cron job, there are around 15 queries, which are in a while loop over 1500 times. As you can imagine, do you suggest i use a sleep function here?

    Thanks!
     
    Agent_Smith, May 30, 2008 IP
    swordbeta likes this.
  2. Altari

    Altari Peon

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You could. I don't know the practical application of using it in that manner (for the mail). I've always had it set to mail with the cron job, based upon the server limit (usually 50 at once). Maybe someone else knows more about mailing.

    Tell us a bit more about your queries. There should be some way to not do that.
     
    Altari, May 30, 2008 IP
    Agent_Smith likes this.
  3. Agent_Smith

    Agent_Smith Well-Known Member

    Messages:
    890
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    145
    #3
    It's for a multiforum platform. Multiple databases over a couple of web servers. It's the easiest way to do it.

    Thanks.
     
    Agent_Smith, May 30, 2008 IP
  4. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That should work so it doesn't all get queued up at once.. that being said I'm not sure if 1 second after each e-mail is enough.. then again unless there's some sort of anti-spam measure it'll just queue up and send it ASAP so sleeping isn't needed.
     
    CodyRo, May 30, 2008 IP
    Agent_Smith likes this.
  5. swordbeta

    swordbeta Banned

    Messages:
    225
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes, it's a good idea to use the sleep function to send those emails.
    My little brother wanted once me to spam someones email box and the server overloaded because I used it too much :p

    About the cron job, yes I would use it too, but not after every loop, that will slow down the progress too much, sleep a few seconds after around 30~50 times??
     
    swordbeta, May 31, 2008 IP
    Agent_Smith likes this.