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?