I have a raspberry pi that is sending an https request to my Django application every 2 seconds. The request is essentially asking the application 'Has a user requested data from me?' My Django application then responds to the request with either a 'yes' or a 'no'. If it is a 'yes', the raspberry pi will send the packet of data requested.

My issue/concern: I have several raspberry pi's now, and plan on adding many more. I am looking for a more efficient way of doing this, meaning not having 50 raspberry pi's polling my server every 2 seconds each.

My plan is to have the raspberry pi's do the following instead:

  • On startup, the raspberry pi will send it's public IP to Django application via https request.
  • Every few seconds the raspberry pi will check to see if it's own IP address has changed (in event the host network changes the IP?) If it has, update Django application.
  • Now, instead of the raspberry pi continuously polling the server, it will just wait for a request to send data because now the django application has it's IP.

Is this a sound plan?

  • 2
    A server responding to an average of 25 requests per second is small potatoes. Another raspberry pi could probably be the server and serve 10x that without even breaking a sweat. Oct 26, 2020 at 20:17
  • Have you considered websockets?
    – RubberDuck
    Oct 27, 2020 at 0:44
  • Will those Pi's actually have a publicly accessible IP address, or is there any chance the will get deployed in a private network behind a firewall/NAT? Oct 27, 2020 at 7:08
  • Thanks for the comments, they are helpful. I wasn't sure how taxing 25 requests per second would be, good to know that isn't a big deal.To be honest I started looking at Websockets, and they appear to be fairly complicated (for me). Maybe I'll take a closer look. And yes it is possible they will be behind a firewall so maybe I should just stick with my original plan or use websockets
    – MattG
    Oct 27, 2020 at 8:43

1 Answer 1


The essential difference between poll and push is that if you poll, you can control when and how much you pull, but you never know whether it is actually worth it. If the other one pushes, you will only do work when you need to, but you have no control over when that happens.

In your case, you also have a second dimension, in that you have two different kinds of communication partners. So, you actually have 4 options:

  • Pi polls (what you have now)
  • Pi pushes
  • Django polls (what you are proposing)
  • Django pushes

It all depends on how often you expect what to happen. Do you expect there being so many users that they constantly request data from the Pis? In that case, why not let the Pis just push the data to Django, since you know the data is probably needed anyway.

What you are proposing is definitely sound, but don't lose sight of the other two options you are not mentioning in your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.