On Tue, May 21, 2013 at 2:38 AM, Keith Rarick <
k...@xph.us> wrote:
> On Mon, May 20, 2013 at 5:05 AM, Abishek.R Srikaanth
> <
abishekr...@gmail.com> wrote:
>> Can I use beanstalkd to queue up tasks that can be executed at a specific
>> time during the day?
>
> Yes, but I wouldn't recommend it.
>
> You can approximate it by subtracting the current time
> from the time you want and adding a delay for that duration.
> But there's no guarantee the job will start on time; you must
> make sure there are workers working at the right time and
> that no other jobs are ahead in line keeping them busy.
>
> The general meaning of beanstalkd's delay is to wait *at
> least* the specified amount of time.
Forgive me for jumping in this thread, but I had a similar use case in
mind that could be solved by Beanstalkd and I would like to ask your
opinion.
I have to perform a task for each user (of which I have thousands) in
a weekly basis, but at a different time for each user, based on each
user's subscription time for example. Also each task can fail and
should be retried with a policy that can be dynamic. So I made a proof
of concept in which when a user subscribed I insert a job in
beanstalkd with a week delay. Then n workers will listen for jobs, get
one, make a try and if it fails return it to the queue with a
calculated delay (5 minutes or 1 day, for example).
Do you think this fits correctly? In my case I'm not really concerned
with being accurate to the second in processing the job, I just need
that it's run approximately one week after the previous one.
There's also a concern in that I would like to be able to check every
once in a while that all users have a corresponding job in the queue,
that I'm not sure how to do. Is there a way to do this in beanstalkd,
or should I use an external database and run checks against this
external data. I wouldn't want this since the only way to do that
would be to check that a user wasn't updated for more than a week,
which could mean that I lose an event for some potentially relevant
period of time.
Thanks,
Jesus.