Tokopedia carts IT overhaul with YugabyteDB

E-commerce firms live and die by the reliability and convenience of their platforms, making agility and scalability a must for any modern enterprise — especially ones that people rely on to do their shopping.

Indonesia’s Tokopedia has recognised this, and decided that its reliance on Postgres as a database management system simply won’t cut it, especially since the e-commerce sector is set to grow in the coming years.

While Postgres is sufficiently robust for scaling large datasets, the company can leverage only limited techniques like replication and manual sharding, said Vijay Patil, Vice President of Engineering, Tokopedia.

“Implementing and managing these runtime instances requires meticulous planning and can quickly become highly complex when scaled. Tokopedia mentioned a replication technique involving multiple read replicas. While this addresses read scalability, write operations remain limited to a single node. Scaling write throughput is equally important as scaling read throughput,” he explained.

Patil noted that this limitation has led to higher latencies and intermittent failures, becoming a bottleneck in Tokopedia’s operations.

Critical hour

Various incidents can jeopardise Tokopedia’s database — be it hardware failures, software errors, or network issues— each capable of triggering an outage.

Vijay Patil, Vice President of Engineering, Tokopedia. Image courtesy of Tokopedia.

While Postgres supports active-standby failover via streaming and logical replication, setting up and managing a highly available configuration proved too complex and time-consuming for the e-commerce platform.

“Even with these safeguards, some downtime is inevitable during unplanned failures, which are extremely difficult to avoid. Regular maintenance and software upgrades are essential for keeping a database system running smoothly and securely. However, managing these tasks and performing upgrades while maintaining uptime is a significant challenge,” Patil remarked.

After evaluating a few NoSQL distributions, Tokopedia opted for Yugabyte’s cloud-native database, YugabyteDB, due to its growth rate.

Patil highlighted several factors that influenced this decision:

  • YugabyteDB’s dual API support addresses scalable Postgres API (YSQL) and a Cassandra-compatible API (YCQL), meeting NoSQL requirements.
  • Postgres’ wire compatibility and feature richness, including secondary indexes, partial indexes, triggers, functions, and UDTs.
  • A fully automated, ClickOps-driven portal for seamless Day 0 and Day 2 operations management.
  • A robust, expandable platform with fault tolerance at various levels, including disks, nodes, availability zones, and regions.
  • Capabilities to scale both reads and writes with consistently low latency.
  • A smart application driver that is cluster, topology, and shard aware, adapting to cluster topology in real time.

Setting the stage

Migrating and modernising a company’s database is a complex task that requires careful planning.

A crucial step in this process is the initial database schema design, which can significantly influence the smooth execution of the program or any unexpected issues that may arise during production.

With the significant amount of Tokopedia’s data that had to be transferred to YugabyteDB, a well-thought-out schema design was non-negotiable, said Vish Phaneendra, Senior Director, Technology APJ, Yugabyte.

“This design directly affects the system’s efficiency, performance, and reliability. A well-designed schema simplifies the process for organisations and their employees to retrieve and manage information efficiently,” he stated.

Vish Phaneendra, Senior Director, Technology APJ, Yugabyte. Image courtesy of Yugabyte.

To ensure a smooth migration, Yugabyte started by identifying and proactively resolving potential challenges, thus preventing any migration delays or data discrepancies during the modernisation process.

“Although a straightforward ‘lift and shift’ could have achieved the desired results, YugabyteDB, being a distributed Postgres system, necessitated design changes primarily focused on optimising the existing schema,” Phaneendra explained.

Further, Yugabyte provided guidance on distributed SQL principles, as well as training resources and recommended approaches.

As for the design changes, Tokopedia’s Vijay Patil said the focus was more on optimising the existing schema for the distributed system.

“Tokopedia had already developed the CDC workflow from Postgres primary to standby, so from a migration perspective, we leveraged the current workflow to transfer data from Postgres to YugabyteDB. We used dual writes during the switchover to synchronise real-time data between the old Postgres database and YugabyteDB,” he said.

Smooth-sailing

After migrating to YugabyteDB, Tokopedia experienced immediate improvements in its operations. The company now enjoys seamless version upgrades without any business disruptions, a process that used to be cumbersome.

“We can now do on-demand seamless cluster expansion during business hours, execute online schema changes without business disruptions, and use real-time-monitoring-enabled SREs to make proactive, metrics-driven business decisions,” Patil revealed.

As Tokopedia continues to scale its operations, the need for a highly available, horizontally scalable, and reliable database remains a priority for additional use cases, the Vice President added.

“Our familiarity with known technology, the team’s expertise, and our partnership with vendors play a significant role in expanding existing offerings like Yugabyte to meet future needs,” he said.

Meanwhile, Yugabyte is developing more use cases to serve a broader enterprise audience.

“We recently introduced the YugabyteDB Voyager, a unified database migration solution that allows organisations to simplify data migration from various relational sources to YugabyteDB,” Phaneendra said.

To further democratise access to YugabyteDB’s database capabilities, the company recently added Microsoft Azure as its third cloud service provider for the YugabyteDB Managed service. This addition aims to better support customers in creating managed databases and handling data management across all major cloud providers.