Reliable crypto transactions at Coinbase

coinbaseW

Industry

Crypto

Use Case

Crypto

Company Size

250-2000

SDK

Go

Temporal

Self-Hosted


Reliable crypto transactions at Coinbase

NOTE: This case study outlines Coinbase usage of the Cadence project, a precursor to Temporal.

Coinbase plays a significant role in the cryptocurrency ecosystem by providing accessible and reliable services for buying, selling, storing, and using digital assets. Its user-friendly interface, strong security measures, and compliance with regulatory standards have contributed to its widespread adoption among cryptocurrency enthusiasts and investors.

Primarily a technical platform, Coinbase operates with significant reliability and availability demands. Identifying crucial tools within their development stack becomes paramount, aiming not only to accelerate the delivery of new features but also to mitigate risks, particularly concerning their core transactional operations.

Problem: SAGA for compensating transactions

Coinbase handles millions of cryptocurrency transactions on a daily basis. For users, each transaction boils down to a simple outcome: either "succeeded" or "failed." However, behind the scenes, every transaction comprises a sequence of steps. To illustrate, here's a simplified example of a transaction's steps:

  • Withdraw foocoin from user A’s wallet
  • Withdraw barcoin from user B’s wallet
  • Deposit foocoin into user B’s wallet
  • Deposit barcoin into user A’s wallet

If all steps are successful, the transaction proceeds successfully. Conversely, if any step encounters a failure, the transaction cannot be deemed failed until the already executed steps are reverted. Traditionally, this rollback necessity is addressed using SAGA, a widely adopted pattern for managing rollbacks in distributed transactions.

Until recently Coinbase relied on a custom engine to handle this data integrity requirement. It was quite reliable and well-suited for SAGA support, but the team struggled to use the system for other domains. Each additional use case translated into a large amount of complex plumbing and developer work.

Searching for alternatives

Coinbase quickly realized that they were going to need a flexible, general-purpose solution if they wanted a continued pace of scale and innovation.

The team researched a few alternatives; namely, Zeebe, and AWS Step Functions. The team quickly realized that both the Zeebe and AWS Step Functions were limiting as the development models forced them to predefine all of their possible execution paths. This meant that each step required one or more prebuilt DAGs to handle the potential failures. If your SAGA consists of a few simple steps, prebuilding DAGs might be feasible, but as complexity increases the overhead becomes enormous.

Temporal/Cadence, a natural fit

Temporal/Cadence enables users to handle failures programmatically and doesn't require upfront, unfriendly DAGs. It is developer-friendly and naturally allows for SAGA but is extendable.

The Coinbase team decided to use Temporal/Cadence and layed out a conservative, yet efficient migration path for the transactional application. They outlined a plan to shift each existing component into a Temporal/Cadence workflow and they relied on Coinbase’s existing open source deployment system to build containers for each new workflows and make them available via blue/green deployments. There was no change to their existing supply chain necessary and before long, the majority of existing workflows had been successfully migrated to Temporal/Cadence.

In the end, Development velocity has increased as developers can focus exclusively on writing code instead of maintaining a homegrown SAGA solution.

Temporal/Cadence has opened up use cases which weren’t even imaginable with the homegrown system.

Build invincible apps

Ready to learn why companies like Netflix, Doordash, and Stripe trust Temporal as their secure and scalable way to build and innovate?