rabbitmq - understanding how queues(celery etc.) work? -


i have been reading lot queues , have confused myself. jot down know, please let me know, if understand things correctly.

a queue helps things out of request-response cycle. meaning, if client uploads image, , want save thumbnail version of image, not want keep client waiting time till image gets trimmed, , return him, out of request-response cycle, via queue. queue traditional data-structure queue, first in first out sort of.

the popular solution providers these queues celery, pyres, & amazon sqs.

how queue work?

generally there daemon running, instance, if there celery there celery daemon runs, , keeps doing computation on whichever task @ top of queue. (hope right on this)

another example, complicated, please correct me on this.

now want automate following task:

  1. send mail friend of mine, on 25th dec.

  2. wish friend on birthday on 26th dec.

  3. wish friend on birthday on 26th dec.

in case, following:

  1. create entry, , in database.

  2. once entry created, queue entry.

  3. fire worker, execute task.

now here doubt, step 3 correct?

is there long polling worker, act? how work? confused. or need have cron job, running, keep firing script check if there in queue, given time(with precision of minutes) if yes, fire worker.

when @ documentation of celery, need backend - redis, mongodb, sqs etc. if right, there continuous process run daemon, , keep track of things in queue(redis, mongodb) , should execute. gray area. please help.

thanks answer.

there 2 basic ways using celery. let's suppose you're using celery+rabbitmq

  1. executing long running tasks ( > not want keep client waiting time till work done.) can run celery task code executing in web request. means task serialized message , sent queue @ rabbit server. other process ( celery process ), have consumer initialized when message comes queue. celery worker messages, deserialize it, , execute task in other thread. that's all.

  2. you can start celery jobs cron ( changes sender creates task celery, other things same)

p.s. if using not rabbitmq, database, memcached broker. celery make reads each n seconds, or milliseconds. etc.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -