简体   繁体   中英

What is the best way to send emails in background without interferring the process in ruby on rails?

I am using Rails 4 .

I have used thread for sending emails . Sometimes the site crashes for threads after sending emails.

What should be the best way to perform this ?

Any help appreciated.

Thanks

Sending email there are several option. If you don not have many emails to send then use the delayed_job gem. else use the redis and resque gem.

In delayed job https://github.com/collectiveidea/delayed_job in the time of sending email it will lock your database. and in the production mode if you have huge number of of emails it may cause performance issue. but for small application it's good and easy to implement.

Redis and resque is one of the best option for background job ( https://github.com/resque/resque ) as it is more reliable and easy to implement. and its running on redish. So you need to take the overhead for running a new redish server. you can check the awesome railscast video too( http://railscasts.com/episodes/271-resque ).

other options are also there like sidekiq sidekiq is also running top of redish. feel free to use any one of them depending on your requirement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM