How Levven Keeps Your Smart Home On When The Internet Goes Out

How Levven Keeps Your Smart Home On When The Internet Goes Out

Remember when people’s vacuum cleaners and doorbells stopped working because a region of AWS went down? That won’t happen to anyone using our smart home products. 

Levven had been in the electronics manufacturing industry for decades before “smart technology” paved the way for “smart homes”. When that happened we saw an opportunity to help make homes more affordable by designing and manufacturing smart home controls that reduce build costs. By eliminating the wire between the wall switch and the light we can offer consumers more eco-friendly home construction saving precious resources.

At Levven we added smart home controls manufacturing 5 years ago - but our cloud connectivity is new. Levven’s goal is to make homes more affordable to build, purchase, and operate for the masses with smart controls. In order to do that we need to build scale-out, low maintenance infrastructure that keeps the cost to the end user low, while also guaranteeing that our smart home controls will always work.


To help us address this IoT challenge we chose CockroachDB’s managed service offering: CockroachCloud. In this blog we’ll explain how we’ve built IoT application architecture that keeps smart devices available at all times.

Why Levven chose CockroachCloud

Our goal at Levven is to make smart home technology affordable to the masses. We do this by keeping our infrastructure overhead costs as small as possible.

Our requirements for the database were simple:

• The database should speak SQL

• The database should scale horizontally 

• The database should be highly available 

• The database should be cost efficient

Those requirements swiftly eliminated Oracle (price/scale issues), Postgres (scale), and MongoDB (I didn’t want to immediately jump to NoSQL solutions when there are fantastic relational solutions available). We did, however, spend some time considering Cassandra. But the complexity of managing the cluster and the machines would have added too much operational overhead for us. Because we’re a small team, aiming for a very low cost per customer, the lack of manual operations is an area where we need to spend efficiently. 

We were interested in what CockroachDB could do from a scale and availability perspective. It was tremendously helpful that they offer a self-service managed version of CockroachDB (CockroachCloud). But the moment I knew for sure that we would use CockroachCloud was when I read about their active-active availability. That was my holy grail! I was thrilled to see that someone had solved it so well.

IoT Smart Controls Use-Case Tech Stack

Right now we’re in the beginning stages of growing out this side of our business. The install base is growing steadily and with a simple tech stack we can deliver reliable robust service. While we use a number of AWS solutions to power our iOS and Android apps, we use CockroachCloud to manage and store data.

Two Kinds of Smart Controls Data

There are basically two different kinds of data being stored on CockroachCloud: Live operational information and metadata. For us the operational data keeps the system running and allows users to personalize their home, experience, and control all the connected electrical loads. Utilizing metadata such as how many times a lightswitch is being pressed, or what temperature a room is, and what the voltage is on a battery allows us to deliver more advanced control and energy saving features.

How Levven’s Smart Controls Work When the Internet is Down

In our industry there are two different data paths. One path depends on internet connection and the other depends on radio frequency (RF). We chose RF because we wanted to architect a system in which our smart home controls still work even when the internet does not.

Why did everyone’s Roomba stop working when the AWS region went out?

The Roomba stopped working because Roomba (and many other smart electronics companies) chose the other path - the one that relies on an internet connection at all times.

Here is a high-level diagram of Levven’s architecture. The “Levven Cloud” contains a lot of details like our load balancers, scaling groups, and such - but, for the purposes of this blog we’ve chosen not to go into all those details. 

A light switch and the load controller are not internet connected. They are connected over a 900 megahertz RF network. The gateway is what bridges the controls with the cloud and access for mobile apps. It listens in on the radio communications and sends it to Levven’s servers. That is where the app connects to the home and can perform actions. What’s important to note here is that even without the internet all your home controls will continue to function intelligently. So if a region fails, the lightswitch will continue to work.

Surprise Benefit of CockroachCloud: DB-Console

The two best things about CockroachCloud are that you don’t have to worry about it because it’s a managed service and it scales easily so you know you can add machines to solve usage problems.

But beyond those obvious benefits we’ve been pleasantly surprised by the look of the DB-Console and how much information I can get out of it. There is a lot of debug information in there that is just running without me having to do anything. I use this to make sure we maintain our p99 latency.

What’s Next: Analytics & Scale with CockroachCloud

We know that we could ask a time-series database to run our analytics but we’re going to ask CockroachCloud to do it. We know that this is not a priority use case for CockroachDB. But they’re perfectly capable of running what we need (particularly with improvements made to the cost based optimizer and vectorized execution in the latest version of 20.2). For us the time, cost, and complexity of adding another database just to run some simple analytics workloads is not worth the effort. 

This is just the beginning of our entry into the smart home industry. Our intention is to establish relationships with all the major builders in North America and scale out our users across the continent. Right now we do not require a multi-region configuration. But expect that to happen rather quickly and we’re ready for it because of CockroachCloud.