At the JavaOne Conference, Mark Heckler, principal technologist at Pivotal explained some of the best practices...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
for spinning up a new Internet of Things (IoT) application in the cloud quickly. His approach makes it easier to experiment with different use cases, which can be refined once their business value has been demonstrated.
As an example, Heckler explained how to build the basic framework for a renewable energy monitoring and control application. He built this for his house in St. Louis, but the same principles can be adopted for a wide variety of IoT applications that can be deployed to the cloud quickly.
The key thing is to create a software development tool chain that automates as much of the code generation as possible for both the IoT devices and the cloud back end. Spring Boot makes it easy to bring in a wide variety of services for communications, monitoring, databases and application logic. This starting template can be passed to Cloud Foundry to automatically generate code for different server platforms running in the cloud.
Keep the physical side of IoT simple
The physical side of IoT is important, but it constitutes only about 20% of the work that goes into creating IoT applications. Engineers and architects need to pay close attention to the back-end IoT software, Heckler said. This is where most of the value comes from.
On the physical side, Heckler recommends that the physical infrastructure should be fast and easy to configure. A minimal physical and logical footprint should support reliability, good communication options and standards. For example, Heckler's energy monitoring app used a physical infrastructure comprised of an Arduino board, Raspberry Pi gateways, and supported Wi-Fi and WebSockets protocols for communications.
Heckler said it is important to think about sufficient performance for the device rather than optimal performance, because better performance tends to require more processing power and complexity on the endpoint. This strategy means that most of the heavy processing needs to be done in the cloud. Heckler said the Arduino platform is a good choice for testing a proof of concept, but it lacks low-cost communication capabilities. He recommends adopting a Raspberry Pi as a node concentrator because it supports Linux and Java and has better low-cost communication options.
Focus on standards
As much as possible, Heckler said, you should build cloud IoT applications on top of existing infrastructure and tools that support standards. Heckler showed how he was able to spin up a cloud application environment for energy monitoring quickly using Cloud Foundry so that all interactions between the cloud-based portal, a node concentrator and separate IoT devices could communicate via REST and WebSockets.
Heckler used this approach to develop his renewable energy monitoring and controlling system in a short period of time. The application had inputs from various sensors and controls for cooling, heating and vents.
Configure as much as possible
Starting with a rich set of software tooling makes it easier to develop and redeploy an application architecture using different approaches so you can identify the best one, Heckler said. He has targeted GlassFish, WebLogic and WildFly servers with the CloudFoundry platform. Heckler said it is a better practice to target these servers using existing tools to generate code programmatically than to port existing applications across platforms by manually customizing code.
Using CloudFoundry as the back end makes it easier to use the same approach for processing and deployment on local, on-premises or cloud environments. This can help reduce the effort in developing the proof of concept and then moving to the optimal environment for production.
Another good practice is to use Spring Boot to provide autoconfiguration and external binding capabilities to make it easier to generate the Cloud Foundry starting code. This makes it easier to choose components to include in the application quickly, which can be deployed to run in different target environments. In essence, Spring Boot makes it easy to set up the core framework that is passed to Cloud Foundry, which generates the code for GlassFish, WebLogic or WildFly servers. This allows developers to focus more time on fine-tuning the logic behind the application for the specific IoT use case.
Choose the right components
Heckler also recommends using Spring Boot Actuator, which provides the ability to monitor and manage the application for the price of including the dependency during the configuration of the Spring Boot process. This makes it easy to examine the environment, look at class paths and memory usage, which is useful during development and testing.
The Hypertext Application Language makes it easier to explore and address APIs related to the application. It is also important to include a database or data store in the application for managing data in the event of network interruptions.
Once these Spring Boot elements have been selected, a developer can quickly generate a fully functional -- although minimally useful -- application using the Spring Boot code generation tool. This can be quickly imported into a Java IDE to be customized for the given use case. The final result is then easy to push out to a build tool to generate a Gradle or Maven project.
Put REST to rest and use WebSockets
REST and JSON are good for building Web applications, but they add considerable overhead for IoT applications. REST messages can add a few hundred bytes of header information while IoT applications often send only a few bytes related to measurements or control messaging. Heckler recommends using WebSockets instead. The overhead is much smaller and the communications can be bidirectional when required.
You still need to create a WebSocket class to handle the data, which can be done by extending the WebSocket handler. Heckler said he still has a parameter that can access cloud systems via REST, but he said, "It is so heavy that I don't use it."
This basic framework that leverages Spring Boot, Cloud Foundry and a build tool makes it easy to spin up a cloud application for IoT devices in a short period. Heckler said he has reused this same framework for a variety of enterprise-related applications. He recommends that organizations focus on using existing tools to work out the basic logic for IoT applications. It can be challenging to identify the ultimate use case driving the IoT application. Starting with components makes it easier to identify the business case first, which can then be optimized with the appropriate architecture later.
Making IoT application design choices
AWS opens door to IoT applications
IoT security and privacy concerns
IoT applications expected to grow in the supply chain