I have a project that I'm working and I need a real time update from the database. It's currently running on my own PC using WAMP but I will soon run this on a hosted server replacing the current solution.
The Web fronted (PHP) has a bootstrap toggle switch. I'm using Ajax with the toggle switch to change the value in a MySQL database between 1 and 0.
Then I have an Micro Controller (ESP8266) that checks the saved value in the database from a remote location on a very regular basis. If the server returns 1 its on and if 0 it's off. Ideally I want this to be real time and have it check the status every second or less.
The front end allows you to add as many devices as you want, also this service allows other users to connect to it and they may also add as many devices as they like. So say I have 1000 users and each has 5 devices or more connected.
That's 5000 devices checking the database constantly. I feel this is a bad idea. Also sounds like something that could be detected by the hosting provider as a DDOS attack ? I don't nearly have that many users at the moment and devices are checking the DB every 5 Seconds. Currently the setup behaves like a bridge. It fetches multiple statuses then distributes multiple statuses to all the devices via wire locally from the bridge which is a raspberry PI or Arduino with an Ethernet Shield. But I want to get rid of the bridge and have wireless devices connect directly to the service.
Am I under minding MySQL or is it up to this? Or Should I be using something else instead of MySQL? Or Should I approach the whole scenario differently ? Maybe using some sort publish and subscribe I.E RSS (I have no idea how that works yet)
Quickly searching goolge I found this https://redis.io/ But its a server that needs to be installed. Seeing this is a free service and not generating any income I really don't want to pay for a Linux VPS.
Any advice ? Also bear in mind the ESP8266 client has basic HTTP functionality, It's not very efficient when it comes to processing data, So using something like Node.js is going to be tricky if not impossible. Its CPU is tiny and does not have a heck of allot of memory Its not meant to crunch through code neither does it have a built in Java run time environment so everything has to be done on the hosted server.
The Web fronted (PHP) has a bootstrap toggle switch. I'm using Ajax with the toggle switch to change the value in a MySQL database between 1 and 0.
Then I have an Micro Controller (ESP8266) that checks the saved value in the database from a remote location on a very regular basis. If the server returns 1 its on and if 0 it's off. Ideally I want this to be real time and have it check the status every second or less.
The front end allows you to add as many devices as you want, also this service allows other users to connect to it and they may also add as many devices as they like. So say I have 1000 users and each has 5 devices or more connected.
That's 5000 devices checking the database constantly. I feel this is a bad idea. Also sounds like something that could be detected by the hosting provider as a DDOS attack ? I don't nearly have that many users at the moment and devices are checking the DB every 5 Seconds. Currently the setup behaves like a bridge. It fetches multiple statuses then distributes multiple statuses to all the devices via wire locally from the bridge which is a raspberry PI or Arduino with an Ethernet Shield. But I want to get rid of the bridge and have wireless devices connect directly to the service.
Am I under minding MySQL or is it up to this? Or Should I be using something else instead of MySQL? Or Should I approach the whole scenario differently ? Maybe using some sort publish and subscribe I.E RSS (I have no idea how that works yet)
Quickly searching goolge I found this https://redis.io/ But its a server that needs to be installed. Seeing this is a free service and not generating any income I really don't want to pay for a Linux VPS.
Any advice ? Also bear in mind the ESP8266 client has basic HTTP functionality, It's not very efficient when it comes to processing data, So using something like Node.js is going to be tricky if not impossible. Its CPU is tiny and does not have a heck of allot of memory Its not meant to crunch through code neither does it have a built in Java run time environment so everything has to be done on the hosted server.
Last edited: