IoT (Internet of things) allows us to keep millions of devices connected, sharing relevant business data, we can transform this data into information and make more informed decisions to improve productivity, reduce waste and increase incomes.
Any IoT solution can be split into 3 big sections: Hardware, Network, and Platform. We are going to talk about IoT Platforms in this blog, especially how to use serverless technology to boost performance and reduce costs. Any IoT solution intends to transform, store and present relevant information, based on data collected from the environment using IoT devices (Sensors).
What is Serverless?
Serverless is a technology that allows us to execute programming code without the need for servers. With serverless, we have the illusion of unlimited resources and scalability. This illusion is just that, an illusion, we do know there are limited resources, however, any cloud provider will take care of provisioning resources, so we can focus on running our code. Some examples of serverless services in AWS Cloud:
AWS DynamoDB: On-demand database, we can use it as a service (no need for provisioning)
AWS SQS: On demand Queue management
AWS Lambda: On-demand code execution (python, java, c#, among others)
Key modules in IoT Platforms & DataFlow
1. Data Input
This stage is responsible for receiving data from authorized devices. You can use IoT Core or HttpGateway for this purpose. With IoT Core you can keep a MQTT communication channel, on the other hand, HttpGateway provides a simple interface for implementing rest and WebSockets.
2. Decoding & Storage
In this stage, you have to transform or decode the received data and store it in the corresponding DB.
Keen in mind you can use tools like Kinesis, SNS, SQS for optimizing cloud usage
For hot storage, you can use DynamoDB or RDS. For long-term storage, you can use Redshift or S3 (Athena).
AWS IoT Analytics is a nice middle point between hot and cold storage.
You could have business rules for determining if a notification needs to be sent, for example, temperature out of range. You can post a message to SNS or any other notification system you want (Email, Telegram, Twilio, etc)
Keep in mind that you’re retrieving a huge amount of data, so you will need a visual tool to organize, filter, and present information in the best possible way. A good idea is to use visual tools like Kibana, Grafana, or even some chart libraries such as d3.js, echarts, charts.js among others.
Key advantages: Serverless in IoT
When we use serverless, we run functions and the vendor containers/instances will make sure our code is executed, we don’t have to take care of any instance, this allows us to keep a flexible platform for escaping from 1 device to thousands of devices in seconds.
When we work with IoT we need the flexibility to have 1-5 devices and pay only for them but we want to have the flexibility to escalate to millions of devices, serverless provide us that flexibility, if you have 1 device you pay for 1 device if you scale up to 1000 devices, you pay for those 1000 devices.
Serverless works with multiple elements in architecture and it can be a headache, however, the best way to keep a low maintenance cost is by implementing your architecture as code. We can use frameworks such as Serverless for keeping track of our complete architecture in a source file in our repository. We don’t have to maintain services such as servers, networks, VPNs.
When we use serverless we operate in the higher layer of clouds. Clouds provide isolation between functions, redundancy between physical areas, and almost a 100% availability guarantee. This means any application following recommended patterns can absorb almost 100% of failures and deliver an acceptable service level to the business.
Head of Software development @Lantern