Trace Id is missing
November 05, 2021

Bosch builds smart homes using Dapr and Azure

Technical Story

World-renowned manufacturer Bosch is at the center of the Internet of Things (IoT), combining devices with AI to create intelligent, climate-friendly solutions for people and industries. In the home, Bosch smart devices make life easier with kitchen touchscreens, coffee machines that adapt to user tastes, and web-enabled refrigerators that recognize food, just to name a few. Smart as these devices are, however, there hasn’t been an easy way for owners to coordinate all that intelligence in their home across manufacturers and brands—including but not limited to Bosch.

Residential IoT Services GmbH - Bosch-Group

Bosch created a startup called Residential IoT Services GmbH (RIoT) to focus on a solution. Today RIoT operates a smart home platform for automation and information across devices and appliances, and it’s the power behind the success of the Home Connect Plus app. Home users can connect, automate, and centrally control various smart home devices and entire systems from different brands. An instant hit, the Home Connect Plus service attracted a large number of users in its first month.

To meet the anticipated scale of the service, RIoT engineers made an early decision to use Azure and Distributed Application Runtime (Dapr), an open-source framework that makes it easier to build microservices for the cloud and the edge. RIoT benefits from the global scale of Azure and the integration of Dapr with Azure Kubernetes Service (AKS), which helped the team bring its innovation to market faster.

“We wanted to go cloud and said let’s go Azure. It fits from a technical point of view, and given the long relationship between Bosch and Microsoft, we knew that we would receive excellent support.”

Frank Puhlmann, Head of Development, RIoT

How to future-proof an IoT vision

RIoT GmbH was chartered to implement and operate a smart home ecosystem that would provide a single user interface for all devices that users may have at home and that would enable novel services for connected homes. According to Frank Puhlmann, Head of Development at RIoT, “Our goal was to create a smart home platform—a horizontal platform where users can integrate all their IoT devices, not just those from Bosch. We envisioned it as one app that customers could use to easily control all their smart home devices.”

To quickly prove the concept, the RIoT team built a functional prototype using a Java code base in a monolithic application architecture. Stefan Jaeger, RIoT Solution Architect, explains that the prototype was more of a demo. “We knew that it wasn’t sustainable. It wasn’t built with mobile apps in mind, or to be highly scalable, or to have many different back-end services, which need to be independently deployable. So, once the concept was proven with the prototype, we moved to a microservices architecture.”

Compared to the monolith based on a Java Spring Boot application stack, a microservices architecture consists of a collection of small, autonomous services. Each service implements a single business capability and can be developed, deployed, and scaled independently—a big benefit for the RIoT platform, since the company hopes to grow to millions of concurrent users.

“We were looking for a new approach to how we could future-proof a system that would scale and protect the privacy of the end users at the highest level possible,” Puhlmann recalls.

He and his team realized early on that to build such a highly scalable, distributed system, they would need to do a lot of groundwork, create cross-functional components, and even write boilerplate code. “We didn't want to develop all that on our own. We wanted to focus on business functionality. Then we learned about an emerging framework that was in early development, and it supported this vision of what we wanted to do.”

That framework was Dapr, and the team became an early adopter.

Dapr eases the move to event-driven microservices

The RIoT platform needs to efficiently support a large number of concurrent users within the first year of the launch and to grow from there. By using microservices, the platform can scale out subsystems that require more resources without scaling out the entire application. But compared to a monolithic architecture, microservices applications have more moving parts. Each part is simpler, but the system as a whole is more complex.

“To ensure reliable services, we learned that we needed to build an event-driven back-end system. Dapr showed us the way to get into it without the need to do a lot of manual work so we could get started quickly,” Jaeger remembers.

Dapr is composed of building blocks that help developers create microservice applications in a standard way and deploy them to any environment. For the RIoT team, Dapr building blocks became modular best practices by exposing public APIs for common capabilities. Using standard HTTP or gRPC calls, developers can easily invoke the building blocks they need—for example, the publish and subscribe (pub/sub) pattern used for RIoT’s event-driven system.

Dapr runs as a separate sidecar process and creates a layer of abstraction that allows the code to run anywhere. It isn’t tied to any particular programming language or hosting environment—another big benefit for the RIoT team. Dapr provides a consistent framework that helps the team meet its requirement to support multiple teams and programming languages, including Java and JavaScript.

“The biggest challenge for us was actually the mindset,” notes Jasper Mang, RIoT Lead Developer. “Before, you had to think in a synchronous way. In setting up microservices, where the communications are sent asynchronously, the services don’t have to wait for each other. It’s a huge performance boost on one hand, but on the other hand, as a developer, you have to think about how you structure the code. But here Dapr helped us, because we didn't have to do our own implementation, so it was quite straightforward for us.”

“We needed to support rapid growth with the right scaling support, and we got that with Azure.”

Frank Puhlmann, Head of Development, RIoT

How RIoT uses Dapr to run on Azure

To control and automate smart home devices, customers use a Home Connect Plus mobile app from RIoT, which sends a request to the RIoT platform. Dapr-enabled services receive the requests and act accordingly. For example, one service validates the user’s subscription. Another service collects the data being sent by the smart home devices, such as a thermostat’s temperature reading or an appliance’s status. Another service connects devices so that users can control smart devices from different brands—for example, automatically setting the thermostat and turning on the lights at the same time each evening.

The Dapr publish and subscribe building block allows each of these services to communicate with each other using messages. A Dapr binding enables Service Bus to pick up a message and send it to the specified microservices for processing. Service Bus is the intermediary message broker. The RIoT developers didn’t have to learn all the Service Bus details for their services to publish and subscribe to messages.

“Dapr gave us a level of abstraction over the infrastructure components, like Service Bus. That made it easier to get into the pub/sub model,” Jaeger explains. “Of course, you also need to know the details underneath, but this way, you can start fast and at a later point, go back for more control over topic policies.”

Azure Kubernetes Service (AKS) is the hosting environment for Dapr, which can be configured to run on any supported versions of Kubernetes. Dapr is launched as a sidecar container in the same pod as the service container, and the containers can talk to one another. To deploy a service and run it in the Kubernetes cluster, a developer adds a few annotations to the Dapr deployment schemes. AKS automates operational and maintenance tasks, such as provisioning, scaling, and monitoring, which helps reduce complexity for developers.

By making a call to the Dapr API, developers can decouple their application code from state management, resource bindings, pub/sub messaging, and other common distributed system challenges.

When new developers join the team, Mang tells them about Dapr. “It makes it easy to explain,” he says. “The new colleagues don't even have to know what the infrastructure looks like. Dapr is hiding it from them. They just need to enable the microservices and the eventing architecture. This is a huge benefit.”

Resource bindings that make it easy to integrate and swap out services

The layer of abstraction that Dapr provides also makes it easy for developers to change the components used in different environments. As mentioned, RIoT developers use Service Bus in the cloud environments as part of the publish and subscribe building block, but they use Redis during local development.

“It's quite easy with Dapr, because we can use the service bindings to Service Bus, and it saves some time in getting the setup on the local machine,” Mang explains. Similarly, for the Dapr state store building block, Azure Cosmos DB is the production state store, and Redis is used for local development and testing.

Other Azure services in this platform include Azure Application Gateway, which acts as the highly available front end to the RIoT services on the back end. Application credentials and other secrets are stored Azure Key Vault. Dapr also provides a Secrets building block that services can call, but “I’m happy we’re using Key Vault,” Jaeger notes. “It was easy to set up.”

Diagram showing key services and their interaction
Azure Application Gateway is the gateway to the RIoT services on the back end, which run in containers in AKS. Application keys and other secrets are stored Azure Key Vault.

“We used the Dapr SDK to publish events, which gave us the time to focus on what we wanted to communicate, instead of, ‘How do I get this communication implemented?’ We could focus on the real things that matter.”

Jasper Mang, Lead Developer, RIoT

Virtual Actor pattern in RIoT

Another benefit the RIoT team sees in Dapr is its actor programming model. An actor is an isolated unit of compute and state with single-threaded execution. Using Dapr actors to represent a device and its logic makes it easier for IoT developers to manage compute tasks across clusters. Dapr knows where each actor is running, what it’s doing, and how to reach it. Azure Cosmos DB serves as the state store for actors.

In the RIoT platform, actors are used to represent time-based automations. “We use the actor timers and reminders functionality that comes with the Dapr actor framework,” Mang points out. “Users can schedule automations, like turning on lights or coffee machines every morning.”

Mang adds that it’s gotten easier to work with actors. It wasn’t so easy in the beginning of the project. Bosch was the first Java customer to use the actor building block, and Mang worked closely with Microsoft on the implementation in Dapr. Back then, Dapr’s Java SDK documentation didn’t even cover this feature, and the RIoT team contributed significantly to the documentation. Since then, more Java customers have explored actors and contributed to Dapr, but the RIoT team at Bosch was the first.

“Recently, I introduced the services where we use actors to one of our new developers,” Mang remembers. “It was quite easy to explain the capabilities to him. Actors are a great idea.”

Next steps

Since launching the RIoT platform, the team has watched it grow. “We want to provide a stable system so we can see how it scales and works,” Puhlmann notes. The team launched Home Connect Plus, the market-facing brand of RIoT, in mid-May 2020, during the COVID-19 lockdowns and built support for dozens of partners while conducting business remotely. Within weeks, the Home Connect Plus app was downloaded more than 50,000 times, and that number is still climbing steadily.

“We needed to support rapid growth with the right scaling support, and we got that with Azure,” Puhlmann states.

Dapr also benefitted from the collaboration with the RIoT engineers, who worked with early versions and tested the framework’s resilience. Using a preview version of Dapr, the RIoT team deployed thousands of instances of its services. Those load and stress tests and the team’s feedback improved Dapr. “There is no doubt that Bosch made Dapr better,” observes the Dapr Program Manager at Microsoft, Ori Zohar. “It was a great partnership since RIoT from Bosch was one of the first adopters. They contributed significantly to Dapr and to Dapr’s Java SDK.”

On the other side of the partnership, Jaeger reports that the Dapr core team and other Microsoft advisory teams were very responsive and approachable. “It was welcome that we tried it out in an early stage, and we learned from each other very well in biweekly calls with Dapr engineers and cloud solution architects. We felt like a very welcome and valued customer.”

“For bigger corporations, it’s not just, ‘Does this stuff work well? Is it best of class?’ but, ‘Does it fit into the IoT landscape and future of my company?’ We selected Azure because it was Bosch-ready.”

Frank Puhlmann, Head of Development, RIoT

Take the next step

Fuel innovation with Microsoft

Talk to an expert about custom solutions

Let us help you create customized solutions and achieve your unique business goals.

Drive results with proven solutions

Achieve more with the products and solutions that helped our customers reach their goals.

Follow Microsoft