Version: | 0.0.3 |
---|
cell is an actor framework for Kombu and celery .
The actor model was first proposed by Carl Hewitt in 1973 [1] and was improved, among others, by Gul Agha [2].
An Actor is an entity (a class in cell), that has a mailbox and a behaviour. Actors communicate between each other only by exchanging messages. Upon receiving a message, the behaviour of the actor is executed, upon which the actor can send a number of messages to other actors, create a number of actors or change its internal state.
Cell supports:
- distributed actors (actors are started on celery workers)
- Remoting: Communicating with actors running on other hosts
- Routers: it supports round-robin, direct and broadcast delivery of actor messages. You can create custom routers on top of it, implementing Actors as routers (joiner, collector, gatherer).
In a nutshell:
- Horizontal scalability with actors across multiple nodes
- You get asynchronous message passing for free
- If you are already using celery, all comes for free, no additional setup is required
- Control over the tasks distribution
- More flexible configurations of nodes
- Well known abstraction
- Easy learning curve (check teh 30 sec video to get you started)
- You can use Actors, instead of task-based classes:
(You can program with classes and not tasks)
- Stateful execution. You can link actors together and their execution, creating complex workflows.
You can control the execution per actor/not per worker.
- Better control over work distribution (You can target the same worker for a given task):
adder.send.add(2, 2)
adder.send.add(2, 2)
Having a framework for distributed actor management in your toolbox is a must, bacause:
- simplify the distributed processing of tasks.
- vertical scalability:
- Fair work distribution, load balancing, sticky routing
You can install cell either via the Python Package Index (PyPI) or from source.
To install using pip,:
$ pip install cell
To install using easy_install,:
$ easy_install cell
If you have downloaded a source tarball you can install it by doing the following,:
$ python setup.py build # python setup.py install # as root
If you are too impatient to start, here are the 3 quick steps you need to run 'Hello, world!' in cell: (You can also check the Demo video)
- Define an Actor
from cell.actors import Actor
class GreetingActor(Actor):
class state:
def greet(self, who='world'):
print 'Hello %s' % who
- Start celery with an amqp broker support
>>> celery worker -b 'pyamqp://guest@localhost'
- Invoke a method on an actor instance:
from cell.agents import dAgent
from kombu import Connection
from examples.greeting import GreetingActor
connection = Connection('amqp://guest:guest@localhost:5672//')
agent = dAgent(connection)
greeter = agent.spawn(GreetingActor)
greeter.call('greet')
The full source code of the example from :py:mod:`examples` module. To understand what is going on check the :ref:`Getting started <getting-started>` section.
Join the celery-users mailing list.
If you have any suggestions, bug reports or annoyances please report them to our issue tracker at http://github.com/celery/cell/issues/
Development of cell happens at Github: http://github.com/celery/cell
You are highly encouraged to participate in the development. If you don't like Github (for some reason) you're welcome to send regular patches.
This software is licensed under the New BSD License. See the LICENSE file in the top distribution directory for the full license text.
Copyright (C) 2011-2013 GoPivotal, Inc.
The maintainers of cell and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/pypi-cell?utm_source=pypi-cell&utm_medium=referral&utm_campaign=readme&utm_term=repo)