开发者

Suggestions for performance improvement surrounding sending email notifications?

It takes around a couple of seconds for 开发者_StackOverflowmy app to execute the code to send an email right now on a test server with nothing much else running. Not sure if this is typical/expected. I'm also using the php framework Kohana's email helper and not php's mail directly out of convenience if that matters. Is it always just better to schedule a cron job to send emails every 5 min or so? Or should I be able to send emails immediately and I'm just not doing something right?

What the script does is insert a row into the db and notifies the relevant group that the row was created. The groups are usually < 20 people so I just do a loop calling Kohana's email helper each time for each member of the group.


Not sure about the implentation of the Kohana helper, but here is what the php doc tells :

Note: It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient. For the sending of large amounts of email, see the » PEAR::Mail, and » PEAR::Mail_Queue packages.


http://swiftmailer.org/ is an excellent and reliable mailer. Maybe an alternative approach is the right answer.


Something is not right, for groups of less than twenty users, it should be speedy. > 100 would garner slower processing time.

Look into your server setup. Or, use the IMAP functions...


For the quickest solution look into gearman You basically send the request to send the email into the gearman queue, and the rest of your script can run while Gearman completes the email part of your script in the background

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜