Datomic Pro and Datomic Cloud are FREE!

Nubank

Disrupting the financial services industry - Nubank uses Datomic to back a nimble, elastic microservices platform.

"I didn’t find a better option than Datomic with this first class concept of time. For me, that makes all of the difference." - Edward Wible, CTO

Who & Why

WWW.NUBANK.COM.BR

INFRASTRUCTURE:

Hadoop and Spark

FAVORITE DATOMIC FEATURES:

Ability to run intense queries on one service without impacting performance of the others

HOW IT WORKS:

Datomic + Spark = Real Time Big Data Analytics

Challenge

Brazil’s banking industry is heavily regulated and concentrated. Five banks control more than 90 percent of the country’s assets and offer customers nearly identical products and price points. The country has one of the highest credit card interest rates in the world.

The founders of Nubank, a financial services startup, aim to change that by launching a bank to compete with the country’s biggest players. “Differentiation through technology” was the strategy from day one. “The goal was to sell financial services, but to be a tech company and have the DNA of a tech company.”

Answer: Datomic

Nubank’s leaders couldn’t rely on legacy technology. They needed a nimble data infrastructure that would allow them to carefully maneuver between the technical and analytical sides of their business to track bugs, to launch analytic queries against live data without interfering with customer activity, and to solve other complex business problems. They chose Datomic as the data foundation upon which to build this new and disruptive venture.

Foundation for Growth

From the very start, Nubank’s leaders knew they needed to plan for growth. They also wanted to build a system that could grow in complexity, meet ever changing regulatory and business rules, and have full auditing capability. “We’re in a heavily regulated industry and that alone creates complexity you don’t find in other business. We needed the flexibility and agility of a startup, and the system of record / audit trail features one would find in legacy banking systems. I didn’t find a better option than Datomic with this first class concept of time. For me, that makes all of the difference.”

With Datomic, Nubank gets crucial transactional performance (ACID for OLTP), but also enjoys horizontal read scalability to allow most analytical questions and machine learning model training to happen without maintaining ETL pipelines. This allows engineers and analysts to work on real time, consistent data with a powerful query language, while at the same time protecting the isolation, performance, and integrity of the production OLTP environment.

Nubank employs a microservices architecture with over a dozen independent Datomic databases; this database fragmentation provides operational and scalability benefits, but has the potential to complicate analytic (OLAP) workloads. However, Datomic queries can take multiple database sources as inputs into a single query so the company can conduct cross service joins to get answers to business questions quickly, and without impacting performance of transactional systems.

Having Datomic’s built-in history has also proven useful when splitting services and databases, enabling the chronological replay of database transactions into multiple new databases while preserving timestamps and fixing historical mistakes. This was especially useful when playing back the history of transactions in the order they occurred to ensure account balance integrity when the Datomic-based double entry accounting system became the system of record, and has been repeatedly useful in recovering from bugs and mistakes.

Datomic’s support for multiple storage backends has also been useful to Nubank, as personally identifying information (PII) must be encrypted at rest, something that is easily achieved using Amazon’s PostgreSQL (RDS) with EBS volume encryption for some services, while using DynamoDB to back other, non-PII services.

Finally, Datomic’s powerful Datalog query language has made it easy to solve certain problems that would traditionally require a specialized database. One example is the temporal graph showing the evolution of Nubank customers inviting other customers over time, and the graph of attribute interactions between those customers over time. This was solved quite elegantly using Datalog’s recursive querying capabilities.

Business Benefits

Nubank’s customers see the benefits of Datomic, as well. Without writing any code, Nubank can show customers the complete history of a transaction, from the addition of a tip in a restaurant, to a change in a foreign exchange rate. It also helps build narratives around attacks on the bank’s services, or investigations of how an unexpected database state came to exist. The company regularly deals with third parties and often comes in contact with corrupted or incorrect data. “Recovering from that is core to our business. Having Datomic there as your safety net allows you to recover from errant data very nicely.”

Cognitect Consulting

Early on, Cognitect helped Nubank’s team with an architectural review that set them on the right course with Datomic. Cognitect’s code review helped Nubank engineers get insights into what the code design would look like over time and avoid common pitfalls. “It was almost like an early warning system for our anatomy of a service, which gets multiplied through all the different services …​ We got a lot of value out of that.”

The Spark Connection

  • Datomic reads are decentralized - they consume the resources of the host where the Datomic peer library is running rather than a centralized database

  • For queries that materialize large amounts of data, such as those commonly useful for feature selection or training machine learning models, it’s common to bump up against the limits of a single host

  • To keep even large queries fast, Nubank has deployed a Spark cluster that supports batch and streaming workloads. Every node in the cluster includes a library for querying multiple Datomic databases, and queries can be sharded across the cluster to parallelize the computation, and store the result in a resilient distributed dataset (RDD)

  • The result is that Nubank’s Datomic querying and analysis capacity can scale horizontally as nodes are added to the Spark cluster, enabling reasonably fast answers to expensive questions, even as data volumes scale superlinearly. Most importantly, this analytical capacity is effectively isolated from other production resources, making it a safe environment for exploratory analysis, while remaining consistent in real time without requiring ETL pipelines.

For more information about how Datomic can boost speed, power and scalability for your business, contact us.