title: Should django model object instances be passed to celery?
body: <pre><code># models.py
  from django.db import models
  
  class Person(models.Model):
      first_name = models.CharField(max_length=30)
      last_name = models.CharField(max_length=30)
      text_blob = models.CharField(max_length=50000)
  
  # tasks.py
  import celery
  @celery.task
  def my_task(person):
      # example operation: does something to person 
      # needs only a few of the attributes of person
      # and not the entire bulky record
      person.first_name = person.first_name.title()
      person.last_name = person.last_name.title()
      person.save()
  </code></pre>
  
  <p>In my application somewhere I have something like:</p>
  
  <pre><code>from models import Person
  from tasks import my_task
  import celery
  g = celery.group([my_task.s(p) for p in Person.objects.all()])
  g.apply_async()
  </code></pre>
  
  <ul>
  <li>Celery pickles p to send it to the worker right? </li>
  <li>If the workers are running on multiple machines, would the entire person object (along with the bulky text_blob which is primarily not required) be transmitted over the network? Is there a way to avoid it?</li>
  <li><p>How can I efficiently and evenly distribute the Person records to workers running on multiple machines?</p></li>
  <li><p>Could this be a better idea? Wouldn't it overwhelm the db if Person has a few million records?</p>
  
  <pre><code># tasks.py
  
  import celery
  from models import Person
  @celery.task
  def my_task(person_pk):
      # example operation that does not need text_blob
      person = Person.objects.get(pk=person_pk)
      person.first_name = person.first_name.title()
      person.last_name = person.last_name.title()
      person.save()
  
  
  #In my application somewhere
  from models import Person
  from tasks import my_task
  import celery
  g = celery.group([my_task.s(p.pk) for p in Person.objects.all()])
  g.apply_async()
  </code></pre></li>
  </ul>