An electronics giant saved millions after migrating from MySQL to CockroachDB

An electronics giant saved millions after migrating from MySQL to CockroachDB

Upgrading and modernizing your database can sound like an expensive proposition. But it doesn’t have to be. One major electronics company found that shifting from MySQL to CockroachDB saved them $700,000 in their first year, earning them a 149% ROI.

Background: The need for expansion

The company in question, a US-based electronics company that employs more than 10,000 people, initially sold electronic devices with any required software embedded on the device itself. But the Internet-of-Things age opened the door for innovation by allowing devices to connect to software via the web, bypassing the hardware and processing limitations of the devices themselves.

This, however, meant building a cloud-native IoT software and pairing it with a database that was capable of handling the workloads that would be generated by millions of internet-connected devices. Because the company operates globally, they also needed to build a system that would allow them to comply with region-specific regulatory requirements.

Moving on from MySQL

The company built their new IoT applications using a cloud-native microservices architecture, but quickly realized that getting MySQL — the RDBMS they had been using — to work as needed within this new distributed architecture was going to be expensive. Among other things, this would require:

  1. Developers to manually shard (partition) their MySQL database
  2. Developers to write customized routing logic for a data access layer that would allow communication between the microservices and the relevant shards of their MySQL database
  3. Creating a new instance and duplicating large amounts of data for each region, and then maintaining each of these instances
  4. Taking down the system and updating things manually anytime a schema change or software update was required
  5. Executing all of the above in a way that provides users with a low-latency, low-downtime experience

While MySQL itself is free, the company recognized that the cost of this project in developer-hours was massive.

It also recognized that this would not be a one-time expenditure. All of this custom logic, and every instance of the database, would have to be regularly maintained and updated. Some of the work would need to be redone every time the company expanded and wanted to add a new shard or open a new region.

Step 1: Migrating from MySQL to CockroachDB Self-hosted

“I just get so excited about this technology. We would have so much downtime before, we don’t need to deal with that anymore.” — Principal Cloud Architect

Switching to CockroachDB Self-hosted allowed the company to immediately eliminate many of the expenses associated with scaling up and managing MySQL. CockroachDB is a cloud-native distributed SQL database that has been architected from the ground up for distributed transactional workloads, and it does a lot of the manual work that their MySQL system required automatically. Here are some of the benefits of CockroachDB:

  1. Developers don’t have to manually shard anything. CockroachDB partitions itself and optimizes partitions automatically.
  2. Developers don’t have to write any routing logic. CockroachDB handles routing requests to the correct node automatically, so applications can simply send data to it as if it were a single-instance database.
  3. Spinning up new nodes and adding regions in CockroachDB are relatively straightforward tasks that require as little as a few minutes of a developer’s time.
  4. CockroachDB allows for online version updates and schema changes, with zero downtime required.
  5. CockroachDB can be run on multiple public clouds or hosted on-premises and remain fully available even in the event of node, availability zone, or even full cloud region failure.

“CockroachDB removes the need to write application code for how data relates to other data, for managing shards, for ensuring consistency, updating downstream systems, etc. We can move faster because CockroachDB handles things we used to have to address in the application layer.” — Senior Cloud Architect

The shift allowed the company to realize a lot of important goals for their application, including zero downtime for the database, since schema changes and updates didn’t require going offline.

Running CockroachDB themselves did mean that there were still operational costs and developer-hours required to maintain the database, though. They were running seven separate instances of CockroachDB, which made updates and testing a rather painstaking process. And as the company continued to grow and its data needs continued to expand, the costs of this maintenance were growing.

Initially, the company considered creating a database operations team to manage database maintenance and offer a kind of DBaaS internally using their CockroachDB deployments. However, this would have required hiring additional DBAs.

At the same time, CockroachDB’s managed service, CockroachDB Dedicated, became available. The company decided that, rather than expand its own team, it would switch to CockroachDB Dedicated and leave the management of its database to the experts.

Step 2: Moving to CockroachDB Dedicated

The migration itself was no simple task (migrations never are). It took 10 person-months for coordination, performance testing, creating a new broker, micro integration, and setting up CI / CD tooling, monitoring, and alerting.

Ultimately, the migration cost the company an estimated $200,000, and the CockroachDB Dedicated license was more expensive, too. However, the company still ended up with a savings of $700,000 in year one. That’s a first-year ROI of 149% compared to operating CockroachDB Self-hosted:

Costs Self-hosted (with expansion) CockroachDB Dedicated
Labor $700,000 $6,000
License / subscription $340,000 $337,000
Migration expenses (one time, year one) $200,000
Total $1,040,000 $543,000
Difference (net benefit) $497,000
ROI = (return - cost of investment) / cost of investment * 100 // One-year ROI

And although there’s no way to be certain what sticking with MySQL would have cost the company — they never attempted to operate it at this scale — it’s likely that comparison would be even more stark. MySQL has no license cost, but as discussed above, it is significantly more complex to operate than CockroachDB Self-hosted, so the labor and operations costs would have been quite a bit higher.

Of course, CockroachDB Dedicated didn’t just save the company money — it also saved them time, particularly when compared with MySQL. Instead of bogging developers down with database operations tasks, the move to CockroachDB Dedicated meant those tasks were being handled by Cockroach Labs, enabling the company’s developers to focus on improving and adding new features to their own software.

Using CockroachDB Dedicated has also made it easier for the company to create and maintain staging and testing environments that directly mimic production, reducing the time and effort required to test new features after they’ve been developed.

“If we managed the database ourselves, our DevOps team would be potentially 3x bigger […] We want the people who built the database to manage the infrastructure while we keep full focus on customer experience.”
— Senior Cloud Architect

What could your team do with an extra $700,000?

Wondering what CockroachDB could do for you and your team? You might be surprised to learn that upgrading to a next-gen distributed SQL database for your OLTP workloads can actually save you money. Reach out to us and to find out how.

Contact sales

Further reading

About the author

Charlie Custer github link linkedin link

Charlie is a former teacher, tech journalist, and filmmaker who’s now combined those three professions into writing and making videos about databases and application development (and occasionally messing with NLP and Python to create weird things in his spare time).

Keep Reading

Free O'Reilly report on distributed SQL databases

The creation of a truly new category within tech is a rare moment. 

The emergence of a significant new category that …

Read more
Distributed UDFs: How we're building database functions from the ground up

Efficiency matters. When you’re working with large amounts of data, it matters a lot.

Every trip between your …

Read more
How retailers survive Black Friday and Cyber Monday

As retailers gear up for Black Friday and Cyber Monday, they will not be caught flat footed by the tidal wave of …

Read more