# Spawning sleeper threads... good idea? bad?

**URL:** <https://www.ruby-forum.com/t/spawning-sleeper-threads-good-idea-bad/189478>\
**Category:** Rails\
**Created:** [June 1, 2010, 4:13pm UTC](https://www.ruby-forum.com/t/spawning-sleeper-threads-good-idea-bad/189478 "2010-06-01T16:13:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danimal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bb73d2/32.png) [@Danimal](https://www.ruby-forum.com/u/Danimal)\
**Post date:** [June 1, 2010, 4:13pm UTC](https://www.ruby-forum.com/t/spawning-sleeper-threads-good-idea-bad/189478/1 "2010-06-01T16:13:39Z")

</div>

Hello!

I am building an application that requires users to complete a short  
tutorial after registration in order to fully activate their account.  
When a user registers, they get an email saying something like “thanks  
for registering. Please complete the tutorial by clicking _here_”  
which links to the tutorial. However, after filling out the  
registration form, the “thank you for registering” page includes a  
button to go to the tutorial.

Thus, it’s a little weird to have the email go out if they just  
clicked the button and went right into the tutorial.

What I’m thinking of doing is this:

When the registration form is submitted, spawn a thread that sleeps  
for 1 hour. Then, after the hour, check and see if the member has  
completed the tutorial. If not, send the “please complete the  
tutorial” email.

This way, if the user goes right into the tutorial after registering,  
the email doesn’t go out, thus confusing them.

So that’s the business logic. What I’m worried about, and would love  
some input on, is the pros/cons of spawning threads (possibly with the  
Spawn plugin) and having them sleep for 1 hour (or 1/2 hour or  
whatever). I don’t predict a huge influx of members (it’s an invite-  
only website), but I don’t know enough about how Rails will perform  
under lots of spawned threads. Also, would there be memory leak  
issues? If after the thread wakes and does it’s thing, how can I be  
sure it fully dies?

Am I crazy to think of it this way? Should I just background-job it or  
something?

BTW, I’m currently running NginX and Thin, but I’m amenable to a  
Passenger switch.

Thanks for any intelligence you can provide on this!

-Danimal
