Using after_filter for speed improvement?

Whenever a user sends another user a message, my app delivers an email
notification to the recipient. Unfortunately, the email delivery process
creates a short delay. Any thoughts on how to remove this delay? Would
calling the delivery method with a after_filter be the right way to go?
Thanks.

Jesse

Whenever a user sends another user a message, my app delivers an email
notification to the recipient. Unfortunately, the email delivery process
creates a short delay. Any thoughts on how to remove this delay? Would
calling the delivery method with a after_filter be the right way to go?
Thanks.

The after_filter might mask the delay… I’ve never used it, but another
option would be to store the message info in a table and process it with
a
background process out of cron every minute or so (or shoot it off to
backgroundrb for processing)…

-p

On 2/13/07, YJ [email protected] wrote:

Whenever a user sends another user a message, my app delivers an email
notification to the recipient. Unfortunately, the email delivery process
creates a short delay. Any thoughts on how to remove this delay? Would
calling the delivery method with a after_filter be the right way to go?
Thanks.

You can try this approach

http://datanoise.com/articles/2006/7/14/asynchronous-email-delivery


Kent

http://www.datanoise.com

The method of running a cron that often isn’t really a good idea,
especially if you’re not running on top of the line hardware. It will
load up the whole environment, execute that one tiny task and exit. What
I’ve done in cases like this is write a long-running(read: infinite)
class method that checks for the condition, executes its task and then
waits 30 seconds or so. Yes, you still have an extra copy of the app in
memory, but you’re not using up cpu and disk resources like you would
loading everything up every minute.

Jason

Check out the observer class. It is tailor made for what you want to do.

http://api.rubyonrails.org/classes/ActiveRecord/Observer.html

YJ wrote:

Whenever a user sends another user a message, my app delivers an email
notification to the recipient. Unfortunately, the email delivery process
creates a short delay. Any thoughts on how to remove this delay? Would
calling the delivery method with a after_filter be the right way to go?
Thanks.

Jesse

Hey YJ

I wrote a short article on exactly this issue here:

http://rails.co.za/articles/2006/10/30/sending-emails-in-the-background-with-actionmailer-and-backgroundrb

It does as Philip stated right at the end of his reply…

Cheers,
Gustav P.

Chet,

The observer class looks interesting, and I may use it in a project I’m
working on, but I don’t think the situation I had could use Observer.
Basically, the app is an Ebay-style auction site. I have lots which have
an expiration time and a status. My daemon goes and queries the database
for lots that are “Open” but whose end time has passed. If it finds one,
it closes the lot, logs a purchase and sends emails to the buyer and
seller.
It is really clunky having an external process like that running, and a
bit unreliable - the app could be running fine, but without the daemon,
lots will never get properly closed and no one will get emails about
them.
If you know of any other way to implement something like this, I’d be
happy to hear about it.

Jason

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs