Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6631429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:32:42+00:00 2026-05-25T22:32:42+00:00

I need to develop a realtime recent activity feed in django (with AJAX long-polling),

  • 0

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.

Pseudocode:

def recent_activity_post_save():
    notify_view()

[in the view]
while not new_activity():
    sleep(1)
return HttpResponse(new_activity())

The first thing that comes in mind is querying the DB every second. Not feasible. Other options:

  1. using the cache as a notification service
  2. using a specialized tool, like Celery (I’d rather not do it, because it seems like overkill)

What’s the best way to go here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:32:43+00:00Added an answer on May 25, 2026 at 10:32 pm

    I would suggest keeping it simple…

    Create a database table to store your events, insert into that table when appropriate, then just implement a simple ajax polling technique to hit the server every x seconds on the client side.

    I have concerns with other solutions considering using a push-notification approach or using a noSql data store. It’s a whole lot more complicated than a traditional pull-notification system using the tools that are built in to the Django framework, and except for very rare exceptions, is overkill. Unless you specifically require a strict real-time solution, keep it simple and use the tools that already exist in the framework, and for people with objections based on database or network performance, all I have to say is that premature optimization is the root of all evil.

    Build a model that contains recent activity data specific to your application then, whenever your application does something that should log new activity you can just insert into this table.

    Your view would simply be like any other view, pulling the top x rows from this RecentActivity table (optionally based on query parameters and whatever).

    Then, on the client side, you’d just have a simple ajax poller hitting your view every x seconds. There is no shortage of complicated plugins and technologies you can use, but writing your own isn’t that complicated either:

    function simplePoll() {
      $.get("your-url", {query-parameters}, function(data){
        //do stuff with the data, replacing a div or updating json or whatever
        setTimeout(simplePoll, delay);
      });
    }
    

    My opinion is that performance issues aren’t really issues until your site is successful enough for them to be an issue. A traditional relational database can scale up fairly well until you start reaching the level of success like Twitter, Google, etc. Most of us aren’t at that level 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to develop a server side application that opens sockets and manages communication
I need to develop an application which stores data in a SQL Server 2005
I need to develop an IMAP poller which pings an email server every few
I need to develop a game server that will run periodically (e.g., triggered by
I need to develop a WCF server (basically a web service which will eventually
I need to develop an IFilter for Microsoft Search Server 2008 that performs prolonged
I need to develop a small-medium sized desktop GUI application, preferably with Python as
I need to develop a generic jQuery-based search plugin for the ASP.NET MVC application
I need to develop a system for storing large numbers (10's to 100's of
I need to develop a CRM system which will allow users to have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.