Yii Framework Forum: [EXTENSION] celery-yii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] celery-yii Rate Topic: -----

#1 User is offline   ema 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 11-June 11

Posted 17 June 2012 - 09:02 PM

http://www.yiiframew...ion/celery-yii/

Enjoy!
0

#2 User is offline   yugene 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 513
  • Joined: 08-August 09

Posted 19 June 2012 - 02:27 AM

Looks interesting.

As I read at celery project page:

Quote

Celery is an asynchronous task queue/job queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well.
The execution units, called tasks, are executed concurrently on a single or more worker servers using multiprocessing, Eventlet, or gevent. Tasks can execute asynchronously (in the background) or synchronously (wait until ready).


I would appreciate if you'd share which way do you use this extension (usage case(s)) also.

Thank you.


0

#3 User is offline   ema 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 11-June 11

Posted 19 June 2012 - 01:52 PM

View Postyugene, on 19 June 2012 - 02:27 AM, said:

I would appreciate if you'd share which way do you use this extension (usage case(s)) also.


Thanks for the feedback.

I basically use celery for every task that I can outsource to a backend, which means that the result of this task is not required to render the view.

To give you an example related to the Yii blog tutorial: http://www.yiiframew.../en/post.create

protected function afterSave()
{
    parent::afterSave();
    Tag::model()->updateFrequency($this->_oldTags, $this->tags);
}

I would rather implement Tag::updateFrequency() via Celery, as the exact frequency of the tags is not actually needed by post/create (or post/update) view.

When your project grows in size, in this way you reduce the possibility of errors (maybe creating a post fails because of a problem in the tags table) and the time a user has to wait until her request is processed.

Another classical example is notifications. Assume that, when a user creates a post, you want to add a notification to all her friends/followers. If you implement everything in the front end, a user with many friends should wait longer than one with a few of them, because it takes time to update all the records. Outsourcing to the backend, the user immediately creates the post, and the friends shall be notified asynchronously.

I've started using RabbitMQ (with the Yii AMQP extension) but I ended up switching to Celery simply because you don't just need a channel to send tasks to the backend (this is what rabbit is), but you also need a way to control your tasks, decide how they can communicate, manage their errors... in one word, you need to reimplement Celery.

The only drawback is that it's in python, so your backend must use a different programming language, but for me this was a requirement ;-)
0

#4 User is offline   yugene 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 513
  • Joined: 08-August 09

Posted 19 June 2012 - 10:36 PM

Thank you very much for the additional description.
0

#5 User is offline   ema 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 11-June 11

Posted 02 August 2012 - 11:49 AM

I've updated the extension to version 0.2. The only change is in the licence, now BSD 2-clause license.

Meanwhile, I've tested it on Celery 3.0.4. Enjoy!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users