MyDoc, a digital healthcare company, switched from MySQL to CockroachDB for ease of scale and the ability to comply with regional data storage regulations in Asia
1 global relational database
6 countries of operation
2 cloud providers
MyDoc is a fast-growing digital healthcare company that was looking to migrate from MySQL to a database that would scale easily as the company expands its operations from Singapore and India into Vietnam, Hong Kong, the Philippines, and Indonesia. Initially, MyDoc was interested in CockroachDB for the ability to partition data by region in order to optimize performance. As MyDoc got closer to expanding into neighboring countries, they realized that compliance with local data storage regulations was another reason to use CockroachDB. Additionally, MyDoc chose Kubernetes to run all of their backend services, which are hosted in the cloud, and they needed a cloud-native database that would work natively with Kubernetes. After narrowing their decision down to Google Spanner and CockroachDB, they decided to move forward with CockroachDB. The ease with which CockroachDB can scale to new regions, the ability to comply with data regulations, and the compatibility with Kubernetes fit the needs of MyDoc.
MyDoc, the digital healthcare company, has established a 24/7/365 fully integrated online-to-offline platform that streamlines all aspects of primary healthcare. Mark Ridley, the CTO of MyDoc, and his team wanted to replace MySQL with a cloud-native, distributed SQL database to handle all data pertaining to patients, doctors and vendors in their system. Their applications rely on storing sensitive data like lab results and prescriptions that must be passed back and forth from labs, to patients, to doctors, and pharmacists all via a combination of chatbot, email, and patient portal. Many use cases are time-sensitive (e.g., virtual appointment with doctor) and require perfectly consistent records (e.g., lab results), making low-latency reads, database resiliency, and consistency important.
The impetus for modernizing their database was business expansion from Singapore and India into four other Asian countries. The MyDoc team knew they could deploy read-only MySQL nodes to other regions; however, this strategy is not truly scalable and would not achieve their goals to scale internationally. They came up with four options to solve the problem: dump MySQL databases and store backups regionally, create MySQL read-only nodes regionally, use CockroachDB to store read-write data regionally, or use CockroachDB to shard read-write data regionally, storing specific in-country data within the border.
Two other factors influenced their need to find a cloud-native database. First, they had already made the move to microservices and wanted a database that would work with Kubernetes. Second, most Asian countries either have or will have data storage regulations that MySQL was not built to handle.
“Seeing how easy it is to fire up a Cockroach cluster and then looking back at what I had to do with MySQL—the difference is quite amazing.” - Mark Ridley, CTO
The MyDoc technical team began looking for solutions that could achieve the goal of a global relational database. They needed a distributed SQL solution that could keep pace with their global aspirations without compromising on consistency or resiliency. They needed the database to shard automatically to reduce the operational complexity of rapid growth, and they wanted the ability to partition data in order to comply with the storage regulations found throughout Asia. Also, the operational team within MyDoc had requirements for faster deployments for clients.
MyDoc decided that only Google Spanner and CockroachDB were viable options. Ultimately they chose CockroachDB because it delivers a significantly higher ROI, and it gives MyDoc the opportunity to geo-partition data at the row level.
When MyDoc began to vet the migration process they found that CockroachDB’s MySQL imports would make it easier than expected to get data from MySQL into CockroachDB without any errors or loss of data. The challenge was navigating inconsistencies with Time Stamps across all of their applications. Migrating the data into CockroachDB forced them to clean up all these inconsistencies which has improved performance. According to Ridley, “The migration helped us clean out our data. We put in all these missing indexes that we didn’t have. So, in a way, the migration has helped us massively increase performance.”
CockroachDB is a cloud-native distributed SQL database that was built from the ground up for multi-region deployments such as the deployment that MyDoc is growing towards. CockroachDB uses serializable isolation to guarantee a high level of isolation to ensure that transactional consistency is not compromised by the distributed environment. CockroachDB is particularly resilient (hence the name “Cockroach”) because all the data in each cluster is replicated three times which guarantees that data can never be lost and recover time is near zero. Because of the distributed architecture, the database can also be used to geo-partition data based on a field in a table. It can also be used to have data follow a user to reduce latency. Geo-partitioning is the capability that MyDoc will use to comply with regulations where necessary in the different Asian countries.
Currently, MyDoc is in production with CockroachDB in Singapore. In the following weeks, the cluster will expand to Hong Kong, India and Vietnam.
“We're going to launch in the Philippines and there's some due diligence for me to do, but I'm not worried about the database side of things at all. I'll just fire up another cluster, fire up more nodes to the cluster, and connect them all, and we're done. I mean, to me, that is remarkably simple.” - Mark Ridley, CTO
Currently, MyDoc is using CockroachDB to store read-write data regionally. In the near future, MyDoc will begin leveraging CockroachDB’s geo-partitioning feature to shard read-write data regionally, storing specific in-country data within the appropriate borders both to enhance performance and to comply with regulations. (This could also be a means of unlocking business opportunities in China).
MyDoc will give consideration to adding AWS as an additional cloud host (they currently use Google Cloud). As they grow from Singapore into the rest of Asia and eventually move west they will take advantage of the flexibility to use multiple cloud providers with CockroachDB.