CASE STUDY

Transportation

Movatic deploys CockroachDB in Kubernetes for IoT workloads

Thousands of different rental assets, like bikes and scooters, send data to Movatic at a rate as high as once every 5 seconds — and CockroachDB handles it all with ease

  • 2,000+ rental locations

  • Thousands of devices each pinging the database every 5s

  • 60+ microservices running CockroachDB

The database challenges of IoT workloads

“There is a big difference between being able to offer a service, and being able to offer a service people can count on.” -Ansgar Strother, Co-Founder & CTO

Movatic is a growth stage company in the micro-mobility industry whose mission is to simplify mobility to help create greener communities. The engineers at Movatic have built the premier software platform from which to launch a bike sharing or rental system. Their software is used by over 300 different bike, scooter, and locker rental services worldwide, including Gotcha and Frog, two of the largest mobility brands.

Since Movatic is providing the software for IoT devices, the end user-experience must be incredibly good. A large part of that user-experience depends on reliable data access. For context, consider three of Movatic’s use cases:

Locker Rentals: Movatic provides software for smart lockers. The database has to guarantee availability to ensure that people are always able to open their lockers.

Bike-Share Mobile Apps: users need to be able to log into their mobiles app and see where the closest bikes are, so location data must be up-to-date everywhere.

Scooter Rides: Scooter rental sessions cause sudden spikes in data logging and updates about metrics like GPS coordinates, battery percentage, speed, and direction. The database needs to handle these surges.

Before Movatic grew to where they are today, they built out a proof of concept on Postgres, hosted in AWS. While building on Postgres, the Movatic team began to see that Postgres was not a good long term partner for building a resilient, scalable service.

Why Postgres was not a viable long term fit for Movatic

“We did not feel confident that Postgres was a good long term fit for us because we knew we’d need to increase VM size and there was not a clear path to roll over to a new instance without downtime.” -Ansgar Strother, CTO

Movatic proactively began searching for a Postgres replacement after one long and frustrating night updating the database. There was something wrong with the folder hierarchy booting from the wrong data directory and the database was offline all night while they got the update done. Afterwards, Ansgar and his co-founder Adam Jakiela looked at each other and said, “We’re never doing this again.”

Both founders had experience working with Postgres in the past and knew of the limitations. Movatic had grown to a point where they were running into those limitations. The downtime required for Postgres upgrades, the lack of horizontal scalability, and the awkward fit with Kubernetes were the primary reasons that Movatic began looking for a better long term partner.

“Our long term vision is to build a solution that can manage anything from a 4 byte amenity system to hundreds of thousands of tracking assets that we’re pinging off of all the time. We were ready to find a database partner that could get us there.” -Ansgar Strother, CTO

Database requirements for IoT workloads

To build a micro-mobility service that people can truly count on, Movatic established the following database requirements:

Stability - the database needs to be resilient

Scale - the database needs to scale horizontally

SQL - the database needs to be user friendly

ACID Transactions - the transactions have to be perfectly correct at all times

K8s-compatible - the database needs to be easy to deploy in Kubernetes

Data Locality - Movatic needs to comply with data storage regulations everywhere

How Movatic deploys CockroachDB

“If you want to see how CockroachDB is performing just look at our app ratings! We’re a bootstrapped startup and we’re competing with huge incumbent companies.” -Ansgar Strother, CTO

Movatic found CockroachDB, set it up, ran some tests, liked everything they saw, and then migrated all their data over from Postgres. Movatic particularly appreciated that the identity and mission of CockroachDB aligned perfectly with Movatic’s mission. Both companies aim to deliver the most stable service in their industry.

CockroachDB is Movatic’s general purpose database. It stores data from rides, devices, transactions and events. CockroachDB is deployed on Kubernetes in Google Cloud Platform. They have over 60 microservices running on CockroachDB - all of which are written in Python. Through test cases, they spin up CockroachDB in docker-compose files to run tests for all their microservices. And they use SQL Alchemy to do raw SQL queries against the database.

Movatic chose CockroachDB in large part for it’s resilience and scalability. But they also highly valued the way that CockroachDB was architected specifically to be run in microservices. Kubernetes gives Movatic the ability to roll back easily (which makes disaster recovery super quick). It allows them to set up a very robust dev, beta, and production cycle. And Kubernetes gives them nice ingress and allows them to keep the code seperated in modules. Nobody wants to do one push and update all services at one time. With Kubernetes they can simply test limited scope areas prior to pushing everything into production.

Scalabale application architecture

“With CockroachDB we don’t have to worry about how to scale when we add new customers. We technically know that the database will take care of anything that we throw at it. We can add huge new customers with confidence that the database will scale and rebalance on its own.” -Ansgar Strother, CTO

With CockroachDB, Movatic can add a couple thousand units of data without having to stress about the database. For example, Movatic recently partnered with a rental company called Gotcha that has over 50 locations in 25 different states. To begin that partnership, Movatic first imported all of Gotcha’s hardware data, without worrying about scale. Then they piloted the software for a week in which they scaled from 200 scooters actively in circulation to 400 scooters. They were doing thousands of rentals per day without missing a beat. They successfully demonstrated to Gotcha that Movatic’s software scales and remains stable.

During one of these rental sessions, a bike or a scooter can send up data at a rate of once every 5 seconds. In one ping from a scooter the database receives location, battery status, and state. They parse the payload from the scooter and save data off to a state table, a battery table, and a location table, while also updating a hardware table. For each of these pings from a piece of hardware Movatic does 4 inserts and one update. CockroachDB meets this demand without issue. It scales and rebalances all without asking Movatic to think about infrastructure.

“Generally speaking, we just don’t have to think about the database. This allows us to focus on strengthening our existing features and developing new ones.” -Ansgar Strother, CTO

Data partitioning in Asia & Europe

The resilience of CockroachDB guarantees that Movatic can deliver the stability required in their industry. Deploying in Kubernetes increases developer efficiency in part because of the automated CI/CD set up. The database is simple to update, and painless to maintain. Soon Movatic will scale to different countries, and when that happens, they’ll use CockroachDB’s geo-partitioning tool to pin user data to a location at the row level. This will allow Movatic to comply with data storage regulations in places like Asia and Europe.

All of these CockroachDB qualities help Movatic focus on improving their services, growing their business, and out-performing incumbent competition.

Ready to get started?