title: Lightweight notification technique
body: <p>I need to develop a realtime recent activity feed in django (with AJAX long-polling), and I'm wondering what's the best strategy for the server-side.</p>
  
  <p>Pseudocode:</p>
  
  <pre><code>def recent_activity_post_save():
      notify_view()
  
  [in the view]
  while not new_activity():
      sleep(1)
  return HttpResponse(new_activity())
  </code></pre>
  
  <p>The first thing that comes in mind is querying the DB every second. Not feasible. Other options:</p>
  
  <ol>
  <li>using the cache as a notification service</li>
  <li>using a specialized tool, like Celery (I'd rather not do it, because it seems like overkill)</li>
  </ol>
  
  <p>What's the best way to go here?</p>