I need advice regarding an infrastructure that connects many RPis (about 90) over the internet to a single hosted server. This server hosts a PHP/JS site that lists the current status of each RPi (whether it’s online, uptime, external and internal IP, RPi’s version, my software version, and some additional data).
I can easily send this data via a Python script using a POST request from every RPi , for example, every minute (like i did from three RPis for test). The server, upon receiving this data, would write it into an XML file (one per RPi, so 90 XML files). However, this would result in around 90 POST requests every minute, which amounts to 64,800 HTTP POST requests per day if we consider a 12-hour day. Would this be okay, or could this approach potentially kill or block the server? Considering it’s a hosted server, I can’t afford to bring it down, and that’s my question: how to do it properly, in your opinion?
In the future, I want to establish two-way communication, such as a button for rebooting/updating my software or connecting via SSH terminal. Which method should I pursue?
I was considering websockets regular PHP extension, but the server provider had some issues with installing them. I mean they unhash it but something is wrong and do not want to work with my site. So i was thinking about
something like that https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#receiving_events_from_the_server but what is a diffrence between this and RESTFUL API?
Is there a particular reason to store all the incoming data in XML files? There are many more compact and flexible storage methods (a database, for example). If you really need XML files, then you could create these on demand from a database
It is difficult to say anything useful about how you designed this, or what you can change, without knowing the exact purpose of the RPis. Is it a secret you need to keep from us?
You seem to have several questions. Can a server take 90 HTTP POSTs per second? Absolutely, you just need to spec it appropriately. You might also consider writing your application as several parts, with one being a very, very simple app that just accepts the POST and writes to disk, another app that parses the XML (if this is actually needed), and the final app which is your UI.
For Websockets or SSE, are you wanting to talk to all 90 at once, or just to individual ones? If the latter, there’s lots of JS terminals out there, you might want to start there and see what they require.
@RobEyre i just chose xml files because I’ll overwrite it, so i will have only one file per RPi overwritten every one min. I know in database I can do same with UPDATE, but i chose to have xml name as NAME_macAddress.xml KIKOSoftware there is a regular screen with car/house rental adverts rotating continouously. ChrisHaas i’v got Python script on RPi and POST reciever on server, but wanted to know if I will not block hosted server doing this way… and I want to see all on list if they are online so i set one minutes requests approach. Only one ssh active once a while.