MySQL for the Internet of Things

(Steven Felgate) #1

Check the Requirements


How did we do with the requirements? I like to check the requirements as I’ve written them against the
code once it is finished and working. Actually, I check the requirements at every stage, but checking them
once the sketch has run for a bit will help you examine the data to ensure data was saved correctly. Let’s go
through each requirement (noted by the numbers inline).
From the test, we see all the data was saved (1). We do a test and capture the loss of communication
to the database server (2). Data is cached to a file on the SD card when the connection is lost (3) (4). When
reconnected, any cached data is written to the database (5), and the cached data’s date and time of sample
collection are preserved (6).
There you have it—your first fault-tolerant data collector with recovery. While I used Ethernet in this
example, which is generally more reliable, you can modify this code to use other forms of communication
and thus protect your data collection from loss from communication mechanism failure.
Using techniques like this along with MySQL replication for redundancy, you can achieve an impressive
form of high availability for your IOT solutions. I encourage you to continue to explore code like this for
other nodes hosted on platforms such as Raspberry Pi, Edison, and other single computer boards. What
you will find is those boards have sufficient memory to build even more sophisticated fault-tolerant
mechanisms.

Summary


High availability is all about reliability. The more reliable a solution is, the greater the level of high
availability. The concepts of high availability therefore are not difficult but can be a little challenging to
implement. Fortunately, MySQL provides a number of high availability features; chief among them is MySQL
replication.
In this chapter, you learned more about MySQL replication including some helpful tips and techniques
for setting up and using replication in your IOT solutions. You also saw some examples of high availability
concepts including a simple round-robin read scale-out solution for Python, hardware for building a
redundant data collector with failover, and how to build in fault tolerance for data collectors so that you
don’t lose data should the communication pathway from data collector to database fail.
As you have learned, it is possible not only to achieve some level of high availability in IOT solutions;
you can do so from the lowest level of the IOT network to the highest. From hardware to database to software
application, all can be made to be more reliable and ultimately reach high availability.

ChapTEr 8 ■ DEmonsTraTion of high availabiliTy TEChniquEs

Free download pdf