SlideShare a Scribd company logo
1 of 56
Download to read offline
Architecting a Modern Financial Institution
SOUTHEAST BRAZIL REGION FROM SPACE
CREDIT CARD
September 2014
0,8
1,5
2,3
3,0
Set-14 Jan-15 Mai-15 Set-15 Jan-16 Mai-16 Set-16 Jan-17 Mai-17 Set-17
GROWING QUICKLY IN A COMPLEX DOMAIN
# of clients (M)
Credit Card
Unique applications
10.5M
Countries
198
Customers
2.6M
Purchases
262M
Deploys per day
20
Microservices
120
Engineers
105
IMMUTABLE THEMES FROM OUR STACK
LISP hosted on the JVM
Functional (opinionated), immutable data
structures
Simple, concise, fast, concurrent
Tight REPL feedback cycles
Gradual typing (schemas)
CLOJURE
DATOMIC
CLOUD
KAFKA
IMMUTABLE THEMES FROM OUR STACK
for your data
CLOJURE
DATOMIC
CLOUD
KAFKA
Accumulate-only
Reified ACID transactions, preserve what
changed when
Query using data structures (Datalog)
Cloud native with integrated caching and
scalable reads
IMMUTABLE THEMES FROM OUR STACK
Immutable, persistent, partitioned log
Logical decoupling between services
Temporal decoupling, useful for
asymmetric workloads
Fault isolation and recovery (circuit
breakers, dead letters)
Financial batch jobs expressed as a
streams of messages
CLOJURE
DATOMIC
CLOUD
KAFKA
IMMUTABLE THEMES FROM OUR STACK
Infra as code (AWS)
Immutable upon provisioning (Docker)
Blue-Green deploys at service and
company level
Kubernetes for speed and scalability
CLOJURE
DATOMIC
CLOUD
KAFKA
FUNCTIONAL BENEFITS
HIRING
POSITIVE SELF SELECTION
1-MONTH RAMP
COMPLEXITY
SMALL, PURE FUNCTIONS
STRAIGHTFORWARD TO UNTANGLE
CONSISTENCY
COMPOSING A SMALL NUMBER OF IDIOMATIC
LANGUAGE FEATURES
Nubank HQ
São Paulo, Brazil
CREDIT CARD ARCHITECTURE
Greenfield MVP
Anti-fraud
Collections
General Ledger
Phone + Chat
Authorizer
Securitization ETL
Credit Scoring
Customer
Acquisition
(KYC)
Credit Limits
Logistics
Card
Origination
Billing
Installment
Purchases
FX
Backoffice
(CRM)
Notification
Chargeback
Bill Pay
Infosec
Rewards +
Merchants
Marketing
BANK ACCOUNT
October 2017
13
CORE BANKING + CREDIT CARD ARCHITECTURE
INFRASTRUCTURE
Rewards +
Merchants
Marketing
Investment
Management
Treasury + Risk
Realtime
Transfers
Lending +
Interest
Rates
Tax
Anti-fraud
Collections
General Ledger
Phone + Chat
Authorizer
Securitization ETL
Customer
Acquisition
(KYC)
Credit Scoring Logistics
Card
Origination
Billing
Installment
Purchases
Credit Limits
FX
Backoffice
(CRM)
Notification
Chargeback
Bill Pay
Infosec
PURCHASE AUTHORIZATION
Customer
Acquisition
(KYC)
Credit Scoring Logistics
Anti-fraud
Card
Origination
Authorizer Billing
Installment
Purchases
Credit Limits
Investment
Management
FX
Collections
Treasury + Risk
Rewards +
Merchants
Realtime
Transfers
Backoffice
(CRM)
Lending +
Interest
Rates
Notification
General Ledger
Securitization
Marketing
Chargeback
Tax
Bill Pay
Phone + Chat
Infosec
ETL
INFRASTRUCTURE
MERCHANT
ACQUIRER
NETWORK
ISSUER
PURCHASE AUTHORIZATION VALUE CHAIN
CUSTOMER
NETWORK
ISSUER
ISSUER AUTHORIZATION
MASTERCARD INTERFACE DEVICE
AUTHORIZER
ISSUER AUTHORIZATION
1 Establish a connection
2 Receive authorization requests
MASTERCARD INTERFACE DEVICE
AUTHORIZER
ISSUER AUTHORIZATION: ISO-8583
ISO-8583 Binary Message
HARDWARE SECURITY MODULE
object PANMappingFileD {
import scala.language.reflectiveCalls
val codec: Codec[SE33Subfield] = discriminated[SE33Subfield].by(intPadded(2))
.typecase(1, llvar(str).as[AccountNumberIndicator])
.typecase(2, llvar(intString(intPadded(2))).as[AccountNumber])
.typecase(3, llvar(yearMonth).as[ExpirationDate])
.typecase(4, llvar(str).as[ProductCode])
.typecase(5, llvar(intPadded(2)).as[TokenAssuranceLevel])
.typecase(6, llvar(intString(intPadded(2))).as[TokenRequestorID])
.typecase(7, llvar(intString(intPadded(2))).as[PANAccountRange])
}
SCODEC BINARY PARSER FOR ISO-8583
BRAND INTERFACE DEVICE
AUTHORIZER
ISSUER AUTHORIZATION: REQUIREMENTS
ISO-8583 Binary Message
HARDWARE SECURITY MODULE (HSM)
1.Highly Available
2.Physical Infrastructure
AUTHORIZER SERVICE LAYOUT
fraud fraud
HSM
HSM
crypto crypto
• Small set of highly available
services
• Co-located with the MasterCard
devices in the same datacenters
• Isolated: transaction
authorization hot path does not
need communication with the
cloud
• Active-active disaster recovery
(not shown)
Thrift
Finagle Server
authorizer authorizer authorizer authorizer
Finagle Client
router
ISO 8583
router
Proprietary
protocol
“neverland”
(nubank datacenter)
kafka
“the real world”
(AWS VPC)
100+ microservices
KAFKA AS THE BRIDGE BETWEEN ENVIRONMENTS
0 1 2 3 4 … Kafka Topic Partition
KAFKA-BASED LOG/SNAPSHOT
AWS Service
1 Publish
2 Authorizer consumes
offset
2
4
Generates a
snapshot
3
Snapshot
service
consumes
snapshotter
5
New
authorizer
started
6
Reads
Snapshot
7
Consumes from
snapshot offset
0 %
0,35 %
0,7 %
1,05 %
1,4 %
2016-07 2016-09 2016-11 2017-01 2017-03 2017-05 2017-07
0 %
20 %
40 %
60 %
80 %
2017-03 2017-04 2017-05 2017-06 2017-07 2017-08 2017-09
% stand-in
% fraud capture
% fraud precision
cutover cutover
DRAMATIC IMPROVEMENTS IN RELIABILITY AND FRAUD
DOUBLE ENTRY ACCOUNTING
Customer
Acquisition
(KYC)
Credit Scoring Logistics
Anti-fraud
Card
Origination
Authorizer Billing
Installment
Purchases
Credit Limits
Investment
Management
FX
Collections
Treasury + Risk
Rewards +
Merchants
Realtime
Transfers
Backoffice
(CRM)
Lending +
Interest
Rates
Notification
General Ledger
Securitization
Marketing
Chargeback
Tax
Bill Pay
Phone + Chat
Infosec
ETL
INFRASTRUCTURE
Interest
Chargebacks
Payments Currencies
Purchases
Should we…
authorize a purchase?
block a card?
charge interest?
BUSINESS LOGIC DEPENDS ON DATA ACROSS MANY SERVICES
Double Entry
DOUBLE ENTRY: THE MODEL
ENTRY
CREDIT
BOOK ACCOUNT
DEBIT
BOOK ACCOUNT
$
= 𝚺
BALANCE $
The sum of all credits and debits for one
book-account is its balance
A customer’s balance sheet is a
cumulative function of their entire history
DOUBLE ENTRY: THE RULEBOOK
ENTRY
CREDIT
BOOK ACCOUNT
DEBIT
BOOK ACCOUNT
$
NEW-PURCHASE
NEW-PAYMENT
…
ENTRY 2
CREDIT
BOOK ACCOUNT
DEBIT
BOOK ACCOUNT
$
ENTRY 3
CREDIT
BOOK ACCOUNT
DEBIT
BOOK ACCOUNT
$
MOVEMENT
(def unsettled-purchase
[
{:entry/debit-account :book-account-type.asset/unsettled
:entry/credit-account :book-account-type.liability/unsettled-counterparty
:entry/amount #'transaction-amount
:entry/post-date #'produced-date}
{:entry/debit-account :book-account-type.liability/current-limit-counterparty
:entry/credit-account :book-account-type.asset/current-limit
:entry/amount #'transaction-amount
:entry/post-date #’produced-date}
])
DOUBLE ENTRY: EXAMPLE MOVEMENT
ordering matters (i.e. movements are not commutative)
late arriving events (e.g. a payment was made 3 days ago)
fixing invariants
write throughput
DOUBLE ENTRY: CHALLENGES
(def loss-property
(prop/for-all [adjs (gen/vector (gen/one-of [gen-adjustment gen-payment gen-tx]) 1 10)
initial-state (gen/such-that (comp not #{:late :pre-loss} :state) rbh/initial-state-gen)
loss-event (gen/tuple (gen/no-shrink (gen/elements #{:pre-loss
:credit-loss
:id-fraud-loss
:fraudster}))
(tg/make-generator LocalDateTime)
(tg/make-generator LocalDate))]
(check-properties adjs initial-state loss-event)))
DOUBLE ENTRY: GENERATIVE TESTING OF INVARIANT
ordering actually matters (i.e. movements are not commutative)
late arriving events (e.g. a payment was made 3 days ago)
fixing invariants
write throughput
DOUBLE ENTRY: CHALLENGES
SHARDED, FAULT TOLERANT INFRASTRUCTURE
Customer
Acquisition
(KYC)
Credit Scoring Logistics
Anti-fraud
Card
Origination
Authorizer Billing
Installment
Purchases
Credit Limits
Investment
Management
FX
Collections
Treasury + Risk
Rewards +
Merchants
Realtime
Transfers
Backoffice
(CRM)
Lending +
Interest
Rates
Notification
General Ledger
Securitization
Marketing
Chargeback
Tax
Bill Pay
Phone + Chat
Infosec
ETL
INFRASTRUCTURE
0,8
1,5
2,3
3,0
Set-14 Jan-15 Mai-15 Set-15 Jan-16 Mai-16 Set-16 Jan-17 Mai-17 Set-17
SCALING BOTTLENECKS
# of clients (M)
Credit Card
1. database throughput limits
required throttling writes
2. batch job latency impacting
customer experience
Need to partition the workload
Customer data is spread across services
Interactions between customers are minimal
Safe to partition the user base
SCALING PLAN
Database writes were the worst
bottleneck
Option: horizontally partition each
database
Change every service to route
queries and writes to the appropriate
shard
db shard s0 db shard s1 db shard s2
OPTION #1: PARTITION SERVICE DATABASES
backend service
Enormous effort to change every
service
Doesn’t address non-db bottlenecks
Risks intermingling data infrastructure
code with business logic
OPTION #1: PROBLEMS
OPTION #2: SCALABILITY UNITS
SERVICE 1 SERVICE 2
SERVICE 3
SERVICE 1 SERVICE 2
SERVICE 3
SERVICE 1 SERVICE 2
SERVICE 3
shard S0 shard S1 shard s2 . . .
OPTION #2: SCALABILITY UNITS + GLOBAL ROUTING
SERVICE 1 SERVICE 2
SERVICE 3
SERVICE 1 SERVICE 2
SERVICE 3
shard S1 shard s2
SERVICE 4 SERVICE 5
global
SERVICE 6
purchase deposit
SERVICE 1 SERVICE 2
SERVICE 3
shard S0
OPTION #2: HYPERMEDIA FOR INTERACTIONS
SERVICE 1 SERVICE 2
SERVICE 3
shard S1
SERVICE 4 SERVICE 5
global
SERVICE 6
login
{"_links":
{"account": “https://s1-service2…”}}
{"_links":
{"account": “https://s1-service3…”}}
SCALING LESSONS LEARNED
works in practice, but difficult to move incrementally in that
direction
SCALABILITY UNITS WORK
sharding was a complex project
exponential growth defies intuition: use real growth models for
planning
START EARLY
provide critical flexibility for shard routing
MESSAGING AND HYPERMEDIA
made this process much more tractable
AUTOMATED IMMUTABLE INFRA
business logic may create hot spots
reactivated old prospects overcrowded s0
BEWARE HOTSPOTS
it’s devilishly difficult (we avoided it, mostly)
SPLITTING EXISTING DATA
FAULT TOLERANCE PATTERNS
Simple patterns for fault isolation and recovery
PRODUCER
CONSUMER
1 Publish
2 Consume
TOPIC
DEADLETTER-TOPIC
MORTICIAN
4 Persist
5 Republish
DEADLETTERS CIRCUIT BREAKERS
SERVICE
1 Consume
3 Circuit breaker
trips!
3 Exception!
Produce deadletter
2 Outbound fails
4 Pause consuming
ETL + THE ANALYTICAL ENVIRONMENT
Customer
Acquisition
(KYC)
Credit Scoring Logistics
Anti-fraud
Card
Origination
Authorizer Billing
Installment
Purchases
Credit Limits
Investment
Management
FX
Collections
Treasury + Risk
Rewards +
Merchants
Realtime
Transfers
Backoffice
(CRM)
Lending +
Interest
Rates
Notification
General Ledger
Securitization
Marketing
Chargeback
Tax
Bill Pay
Phone + Chat
Infosec
ETL
INFRASTRUCTURE
01 NOV 10:00
Robot 437aae3 approves R$3K limit
01 NOV 11:00
Mastercard purchase, Starbucks, R$100
09 NOV 08:00
Support agent increases limit to R$5K
15 NOV 15:00
Customer blocks card
15 NOV 17:05
Customer joins waiting list for a card
DATOMIC PRIMER: EVENTS OVER TIME
01 NOV 10:00
01 NOV 11:00
09 NOV 08:00
15 NOV 15:00
15 NOV 17:05
[<customer> :customer/id #uuid “b2c90…” 1]
[<account> :account/customer <customer> 2]
[<account> :account/limit 3000 2]
[<card> :card/account <account> 2]
[<card> :card/status :card.status/active 2]
[<purchase> :purchase/card <card> 3]
[<purchase> :purchase/amount 100 3]
[<purchase> :purchase/merchant “Starbucks” 3]
[<account> :account/limit 5000 4]
[<account> :account/limit 3000 4]
[<card> :card/status :card.status/blocked 5]
[<card> :card/status :card.status/active 5]
DATOMIC PRIMER: FACTS OVER TIME
entity attribute value tx
“The DAG”
Pure functions (Scala SQL)
Take datasets, return
dataset
Metadata (schema, partitions,
path on S3, performance)
Runs on Spark
DB1
Log S0
DB1
Log S1
DB2
Log S0
Dataset
Series
Kafka
topics
Datomic
DB logs
EXTRACTOR
Change capture
Chunking
Format conversion
Auto-correcting
S3
contract 1
contract 2
dataset 1
dataset 2
policy
model
Datomic and Kafka log extraction feeding our data lake (S3) in real time
Analytical schemas (“contracts”) generated from Datomic entities
Shards recombined into a logical table-per-entity incrementally
EXTRACT, TRANSFORM, LOAD
ETL EXAMPLE: CONTRIBUTION MARGIN
from double entry
from ERP
are we making money?
REALTIME TRANSFERS
Customer
Acquisition
(KYC)
Credit Scoring Logistics
Anti-fraud
Card
Origination
Authorizer Billing
Installment
Purchases
Credit Limits
Investment
Management
FX
Collections
Treasury + Risk
Rewards +
Merchants
Realtime
Transfers
Backoffice
(CRM)
Lending +
Interest
Rates
Notification
General Ledger
Securitization
Marketing
Chargeback
Tax
Bill Pay
Phone + Chat
Infosec
ETL
INFRASTRUCTURE
REALTIME MONEY TRANSFER
1 Transfer request
In-shard
Transfers 3 Initiate transfer out
Investments
2 Liquidate investment
Global Transfers 4 Process transfer
(global)
Ledger
4 Debits +
credits SPB Client
EXTERNAL
5 Kafka <> SOAP
5
INTERNAL
Shard routing
RSFN (XML)
SITRAF (TED)
Hundreds
of Brazilian
banks
6 Realtime gross
settlement
BRAZILIAN PAYMENTS SYSTEM
Hub and spoke model for national payments
SPB Client
5 Kafka <> SOAP
RSFN (XML)
SITRAF (TED)
Hundreds
of Brazilian
banks
6 Realtime gross
settlement
Real time gross, irrevocable and unconditional
settlement of unlimited amounts
~R$1 trillion (US$300B) transferred per day
06:30 - 18:30 business days
Proprietary XML protocol, IBM MQ Series messaging
See: https://www.bcb.gov.br/Pom/Spb/Ing/Introduction.asp
DOMAIN MODEL SUMMARY
Customer
Acquisition
(KYC)
Credit Scoring Logistics
Anti-fraud
Card
Origination
Authorizer Billing
Installment
Purchases
Credit Limits
Investment
Management
FX
Collections
Treasury + Risk
Rewards +
Merchants
Realtime
Transfers
Backoffice
(CRM)
Lending +
Interest
Rates
Notification
General Ledger
Securitization
Marketing
Chargeback
Tax
Bill Pay
Phone + Chat
Infosec
ETL
INFRASTRUCTURE
We’re hiring
https://nubank.workable.com
São Paulo, Brazil
We’re hiring
https://nubank.workable.com
Berlin, Germany
THANK YOU!
BACKUP
SOUTHEAST BRAZIL REGION FROM SPACE
EXTERNAL
• Client authentication (mutual TLS)
• authorizing new device with reputation
score
• Immutable infrastructure
• Short-lived instances
• No mutations
• Bootstrap service identity from instance
profiles using IAM
• Uniformity of service architecture enables
rapid patching
KEY SECURITY DECISIONS
INTERNAL
• Auto-revoke of access scopes
• Operational scopes are short lived
• Customer contact enables access
• Employee access bootstrapped from Google
OAuth, 2FA + Yubikeys required
• Realtime monitoring of security events
• Cloudtrail, Slack, Lambdas for fine-grained
operational access control
• Internal red team / incident response team
0
1,25
2,5
3,75
5
0 13 26 39 52 65 78 91 104117130143156169182195208221234247260273286299312325338351364377390403416429442455468481494507520533546559572585598611624
2016-02 2016-06 2016-09 2016-12 2017-03 2017-06 2017-09
GROWING ORGANICALLY THROUGH REFERRALS
Each customer we book leads to 3-4 new leads
# of Leads
Sample Cohorts - Days after release

More Related Content

Similar to QQCOS

(BDT312) Using the Cloud to Scale from a Database to a Data Platform | AWS re...
(BDT312) Using the Cloud to Scale from a Database to a Data Platform | AWS re...(BDT312) Using the Cloud to Scale from a Database to a Data Platform | AWS re...
(BDT312) Using the Cloud to Scale from a Database to a Data Platform | AWS re...Amazon Web Services
 
The Impact of Messaging Standards on Event-Driven Architecture and IoT
The Impact of Messaging Standards on Event-Driven Architecture and IoTThe Impact of Messaging Standards on Event-Driven Architecture and IoT
The Impact of Messaging Standards on Event-Driven Architecture and IoTSolace
 
Rethinking Quicksign's Digital Onboarding - Confluent Streaming Days Paris
Rethinking Quicksign's Digital Onboarding - Confluent Streaming Days ParisRethinking Quicksign's Digital Onboarding - Confluent Streaming Days Paris
Rethinking Quicksign's Digital Onboarding - Confluent Streaming Days ParisCedric Vidal
 
Service Fabric – building tomorrows applications today
Service Fabric – building tomorrows applications todayService Fabric – building tomorrows applications today
Service Fabric – building tomorrows applications todayBizTalk360
 
Benchmark Showdown: Which Relational Database is the Fastest on AWS?
Benchmark Showdown: Which Relational Database is the Fastest on AWS?Benchmark Showdown: Which Relational Database is the Fastest on AWS?
Benchmark Showdown: Which Relational Database is the Fastest on AWS?Clustrix
 
Io t world_2016_iot_smart_gateways_moe
Io t world_2016_iot_smart_gateways_moeIo t world_2016_iot_smart_gateways_moe
Io t world_2016_iot_smart_gateways_moeShawn Moe
 
Open Standards Enabling Digital Transformation
Open Standards Enabling Digital TransformationOpen Standards Enabling Digital Transformation
Open Standards Enabling Digital TransformationSolace
 
Citi Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid CloudCiti Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid Cloudconfluent
 
Meetup Microservices Commandments
Meetup Microservices CommandmentsMeetup Microservices Commandments
Meetup Microservices CommandmentsBill Zajac
 
Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...
Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...
Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...Gary Arora
 
A New Way of Thinking | NATS 2.0 & Connectivity
A New Way of Thinking | NATS 2.0 & ConnectivityA New Way of Thinking | NATS 2.0 & Connectivity
A New Way of Thinking | NATS 2.0 & ConnectivityNATS
 
MindSphere: The cloud-based, open IoT operating system. Damiano Manocchia
MindSphere: The cloud-based, open IoT operating system. Damiano ManocchiaMindSphere: The cloud-based, open IoT operating system. Damiano Manocchia
MindSphere: The cloud-based, open IoT operating system. Damiano ManocchiaData Driven Innovation
 
Enterprise Service Delivery from the AWS Cloud (ARC208) | AWS re:Invent 2013
Enterprise Service Delivery from the AWS Cloud (ARC208) | AWS re:Invent 2013Enterprise Service Delivery from the AWS Cloud (ARC208) | AWS re:Invent 2013
Enterprise Service Delivery from the AWS Cloud (ARC208) | AWS re:Invent 2013Amazon Web Services
 
Apache Kafka® Use Cases for Financial Services
Apache Kafka® Use Cases for Financial ServicesApache Kafka® Use Cases for Financial Services
Apache Kafka® Use Cases for Financial Servicesconfluent
 
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...Mydbops
 
Marketing Automation at Scale: How Marketo Solved Key Data Management Challen...
Marketing Automation at Scale: How Marketo Solved Key Data Management Challen...Marketing Automation at Scale: How Marketo Solved Key Data Management Challen...
Marketing Automation at Scale: How Marketo Solved Key Data Management Challen...Continuent
 
Accelerating a Path to Digital with a Cloud Data Strategy
Accelerating a Path to Digital with a Cloud Data StrategyAccelerating a Path to Digital with a Cloud Data Strategy
Accelerating a Path to Digital with a Cloud Data StrategyMongoDB
 
Cloud - Two examples
Cloud - Two examplesCloud - Two examples
Cloud - Two examplessorenpeter
 
Cloud Experience: Data-driven Applications Made Simple and Fast
Cloud Experience: Data-driven Applications Made Simple and FastCloud Experience: Data-driven Applications Made Simple and Fast
Cloud Experience: Data-driven Applications Made Simple and FastDatabricks
 

Similar to QQCOS (20)

(BDT312) Using the Cloud to Scale from a Database to a Data Platform | AWS re...
(BDT312) Using the Cloud to Scale from a Database to a Data Platform | AWS re...(BDT312) Using the Cloud to Scale from a Database to a Data Platform | AWS re...
(BDT312) Using the Cloud to Scale from a Database to a Data Platform | AWS re...
 
The Impact of Messaging Standards on Event-Driven Architecture and IoT
The Impact of Messaging Standards on Event-Driven Architecture and IoTThe Impact of Messaging Standards on Event-Driven Architecture and IoT
The Impact of Messaging Standards on Event-Driven Architecture and IoT
 
Rethinking Quicksign's Digital Onboarding - Confluent Streaming Days Paris
Rethinking Quicksign's Digital Onboarding - Confluent Streaming Days ParisRethinking Quicksign's Digital Onboarding - Confluent Streaming Days Paris
Rethinking Quicksign's Digital Onboarding - Confluent Streaming Days Paris
 
Service Fabric – building tomorrows applications today
Service Fabric – building tomorrows applications todayService Fabric – building tomorrows applications today
Service Fabric – building tomorrows applications today
 
Benchmark Showdown: Which Relational Database is the Fastest on AWS?
Benchmark Showdown: Which Relational Database is the Fastest on AWS?Benchmark Showdown: Which Relational Database is the Fastest on AWS?
Benchmark Showdown: Which Relational Database is the Fastest on AWS?
 
Io t world_2016_iot_smart_gateways_moe
Io t world_2016_iot_smart_gateways_moeIo t world_2016_iot_smart_gateways_moe
Io t world_2016_iot_smart_gateways_moe
 
AMIS Oracle OpenWorld 2015 Review – part 3- PaaS Database, Integration, Ident...
AMIS Oracle OpenWorld 2015 Review – part 3- PaaS Database, Integration, Ident...AMIS Oracle OpenWorld 2015 Review – part 3- PaaS Database, Integration, Ident...
AMIS Oracle OpenWorld 2015 Review – part 3- PaaS Database, Integration, Ident...
 
Open Standards Enabling Digital Transformation
Open Standards Enabling Digital TransformationOpen Standards Enabling Digital Transformation
Open Standards Enabling Digital Transformation
 
Citi Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid CloudCiti Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid Cloud
 
Meetup Microservices Commandments
Meetup Microservices CommandmentsMeetup Microservices Commandments
Meetup Microservices Commandments
 
Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...
Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...
Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...
 
A New Way of Thinking | NATS 2.0 & Connectivity
A New Way of Thinking | NATS 2.0 & ConnectivityA New Way of Thinking | NATS 2.0 & Connectivity
A New Way of Thinking | NATS 2.0 & Connectivity
 
MindSphere: The cloud-based, open IoT operating system. Damiano Manocchia
MindSphere: The cloud-based, open IoT operating system. Damiano ManocchiaMindSphere: The cloud-based, open IoT operating system. Damiano Manocchia
MindSphere: The cloud-based, open IoT operating system. Damiano Manocchia
 
Enterprise Service Delivery from the AWS Cloud (ARC208) | AWS re:Invent 2013
Enterprise Service Delivery from the AWS Cloud (ARC208) | AWS re:Invent 2013Enterprise Service Delivery from the AWS Cloud (ARC208) | AWS re:Invent 2013
Enterprise Service Delivery from the AWS Cloud (ARC208) | AWS re:Invent 2013
 
Apache Kafka® Use Cases for Financial Services
Apache Kafka® Use Cases for Financial ServicesApache Kafka® Use Cases for Financial Services
Apache Kafka® Use Cases for Financial Services
 
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
Choosing the Right Database: Exploring MySQL Alternatives for Modern Applicat...
 
Marketing Automation at Scale: How Marketo Solved Key Data Management Challen...
Marketing Automation at Scale: How Marketo Solved Key Data Management Challen...Marketing Automation at Scale: How Marketo Solved Key Data Management Challen...
Marketing Automation at Scale: How Marketo Solved Key Data Management Challen...
 
Accelerating a Path to Digital with a Cloud Data Strategy
Accelerating a Path to Digital with a Cloud Data StrategyAccelerating a Path to Digital with a Cloud Data Strategy
Accelerating a Path to Digital with a Cloud Data Strategy
 
Cloud - Two examples
Cloud - Two examplesCloud - Two examples
Cloud - Two examples
 
Cloud Experience: Data-driven Applications Made Simple and Fast
Cloud Experience: Data-driven Applications Made Simple and FastCloud Experience: Data-driven Applications Made Simple and Fast
Cloud Experience: Data-driven Applications Made Simple and Fast
 

Recently uploaded

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 

Recently uploaded (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

QQCOS

  • 1. Architecting a Modern Financial Institution SOUTHEAST BRAZIL REGION FROM SPACE
  • 3. 0,8 1,5 2,3 3,0 Set-14 Jan-15 Mai-15 Set-15 Jan-16 Mai-16 Set-16 Jan-17 Mai-17 Set-17 GROWING QUICKLY IN A COMPLEX DOMAIN # of clients (M) Credit Card Unique applications 10.5M Countries 198 Customers 2.6M Purchases 262M Deploys per day 20 Microservices 120 Engineers 105
  • 4. IMMUTABLE THEMES FROM OUR STACK LISP hosted on the JVM Functional (opinionated), immutable data structures Simple, concise, fast, concurrent Tight REPL feedback cycles Gradual typing (schemas) CLOJURE DATOMIC CLOUD KAFKA
  • 5. IMMUTABLE THEMES FROM OUR STACK for your data CLOJURE DATOMIC CLOUD KAFKA Accumulate-only Reified ACID transactions, preserve what changed when Query using data structures (Datalog) Cloud native with integrated caching and scalable reads
  • 6. IMMUTABLE THEMES FROM OUR STACK Immutable, persistent, partitioned log Logical decoupling between services Temporal decoupling, useful for asymmetric workloads Fault isolation and recovery (circuit breakers, dead letters) Financial batch jobs expressed as a streams of messages CLOJURE DATOMIC CLOUD KAFKA
  • 7. IMMUTABLE THEMES FROM OUR STACK Infra as code (AWS) Immutable upon provisioning (Docker) Blue-Green deploys at service and company level Kubernetes for speed and scalability CLOJURE DATOMIC CLOUD KAFKA
  • 8. FUNCTIONAL BENEFITS HIRING POSITIVE SELF SELECTION 1-MONTH RAMP COMPLEXITY SMALL, PURE FUNCTIONS STRAIGHTFORWARD TO UNTANGLE CONSISTENCY COMPOSING A SMALL NUMBER OF IDIOMATIC LANGUAGE FEATURES Nubank HQ São Paulo, Brazil
  • 9. CREDIT CARD ARCHITECTURE Greenfield MVP Anti-fraud Collections General Ledger Phone + Chat Authorizer Securitization ETL Credit Scoring Customer Acquisition (KYC) Credit Limits Logistics Card Origination Billing Installment Purchases FX Backoffice (CRM) Notification Chargeback Bill Pay Infosec Rewards + Merchants Marketing
  • 11. CORE BANKING + CREDIT CARD ARCHITECTURE INFRASTRUCTURE Rewards + Merchants Marketing Investment Management Treasury + Risk Realtime Transfers Lending + Interest Rates Tax Anti-fraud Collections General Ledger Phone + Chat Authorizer Securitization ETL Customer Acquisition (KYC) Credit Scoring Logistics Card Origination Billing Installment Purchases Credit Limits FX Backoffice (CRM) Notification Chargeback Bill Pay Infosec
  • 12. PURCHASE AUTHORIZATION Customer Acquisition (KYC) Credit Scoring Logistics Anti-fraud Card Origination Authorizer Billing Installment Purchases Credit Limits Investment Management FX Collections Treasury + Risk Rewards + Merchants Realtime Transfers Backoffice (CRM) Lending + Interest Rates Notification General Ledger Securitization Marketing Chargeback Tax Bill Pay Phone + Chat Infosec ETL INFRASTRUCTURE
  • 15. MASTERCARD INTERFACE DEVICE AUTHORIZER ISSUER AUTHORIZATION 1 Establish a connection 2 Receive authorization requests
  • 16. MASTERCARD INTERFACE DEVICE AUTHORIZER ISSUER AUTHORIZATION: ISO-8583 ISO-8583 Binary Message HARDWARE SECURITY MODULE
  • 17. object PANMappingFileD { import scala.language.reflectiveCalls val codec: Codec[SE33Subfield] = discriminated[SE33Subfield].by(intPadded(2)) .typecase(1, llvar(str).as[AccountNumberIndicator]) .typecase(2, llvar(intString(intPadded(2))).as[AccountNumber]) .typecase(3, llvar(yearMonth).as[ExpirationDate]) .typecase(4, llvar(str).as[ProductCode]) .typecase(5, llvar(intPadded(2)).as[TokenAssuranceLevel]) .typecase(6, llvar(intString(intPadded(2))).as[TokenRequestorID]) .typecase(7, llvar(intString(intPadded(2))).as[PANAccountRange]) } SCODEC BINARY PARSER FOR ISO-8583
  • 18. BRAND INTERFACE DEVICE AUTHORIZER ISSUER AUTHORIZATION: REQUIREMENTS ISO-8583 Binary Message HARDWARE SECURITY MODULE (HSM) 1.Highly Available 2.Physical Infrastructure
  • 19. AUTHORIZER SERVICE LAYOUT fraud fraud HSM HSM crypto crypto • Small set of highly available services • Co-located with the MasterCard devices in the same datacenters • Isolated: transaction authorization hot path does not need communication with the cloud • Active-active disaster recovery (not shown) Thrift Finagle Server authorizer authorizer authorizer authorizer Finagle Client router ISO 8583 router Proprietary protocol
  • 20. “neverland” (nubank datacenter) kafka “the real world” (AWS VPC) 100+ microservices KAFKA AS THE BRIDGE BETWEEN ENVIRONMENTS
  • 21. 0 1 2 3 4 … Kafka Topic Partition KAFKA-BASED LOG/SNAPSHOT AWS Service 1 Publish 2 Authorizer consumes offset 2 4 Generates a snapshot 3 Snapshot service consumes snapshotter 5 New authorizer started 6 Reads Snapshot 7 Consumes from snapshot offset
  • 22. 0 % 0,35 % 0,7 % 1,05 % 1,4 % 2016-07 2016-09 2016-11 2017-01 2017-03 2017-05 2017-07 0 % 20 % 40 % 60 % 80 % 2017-03 2017-04 2017-05 2017-06 2017-07 2017-08 2017-09 % stand-in % fraud capture % fraud precision cutover cutover DRAMATIC IMPROVEMENTS IN RELIABILITY AND FRAUD
  • 23. DOUBLE ENTRY ACCOUNTING Customer Acquisition (KYC) Credit Scoring Logistics Anti-fraud Card Origination Authorizer Billing Installment Purchases Credit Limits Investment Management FX Collections Treasury + Risk Rewards + Merchants Realtime Transfers Backoffice (CRM) Lending + Interest Rates Notification General Ledger Securitization Marketing Chargeback Tax Bill Pay Phone + Chat Infosec ETL INFRASTRUCTURE
  • 24. Interest Chargebacks Payments Currencies Purchases Should we… authorize a purchase? block a card? charge interest? BUSINESS LOGIC DEPENDS ON DATA ACROSS MANY SERVICES Double Entry
  • 25. DOUBLE ENTRY: THE MODEL ENTRY CREDIT BOOK ACCOUNT DEBIT BOOK ACCOUNT $ = 𝚺 BALANCE $ The sum of all credits and debits for one book-account is its balance A customer’s balance sheet is a cumulative function of their entire history
  • 26. DOUBLE ENTRY: THE RULEBOOK ENTRY CREDIT BOOK ACCOUNT DEBIT BOOK ACCOUNT $ NEW-PURCHASE NEW-PAYMENT … ENTRY 2 CREDIT BOOK ACCOUNT DEBIT BOOK ACCOUNT $ ENTRY 3 CREDIT BOOK ACCOUNT DEBIT BOOK ACCOUNT $ MOVEMENT
  • 27. (def unsettled-purchase [ {:entry/debit-account :book-account-type.asset/unsettled :entry/credit-account :book-account-type.liability/unsettled-counterparty :entry/amount #'transaction-amount :entry/post-date #'produced-date} {:entry/debit-account :book-account-type.liability/current-limit-counterparty :entry/credit-account :book-account-type.asset/current-limit :entry/amount #'transaction-amount :entry/post-date #’produced-date} ]) DOUBLE ENTRY: EXAMPLE MOVEMENT
  • 28. ordering matters (i.e. movements are not commutative) late arriving events (e.g. a payment was made 3 days ago) fixing invariants write throughput DOUBLE ENTRY: CHALLENGES
  • 29. (def loss-property (prop/for-all [adjs (gen/vector (gen/one-of [gen-adjustment gen-payment gen-tx]) 1 10) initial-state (gen/such-that (comp not #{:late :pre-loss} :state) rbh/initial-state-gen) loss-event (gen/tuple (gen/no-shrink (gen/elements #{:pre-loss :credit-loss :id-fraud-loss :fraudster})) (tg/make-generator LocalDateTime) (tg/make-generator LocalDate))] (check-properties adjs initial-state loss-event))) DOUBLE ENTRY: GENERATIVE TESTING OF INVARIANT
  • 30. ordering actually matters (i.e. movements are not commutative) late arriving events (e.g. a payment was made 3 days ago) fixing invariants write throughput DOUBLE ENTRY: CHALLENGES
  • 31. SHARDED, FAULT TOLERANT INFRASTRUCTURE Customer Acquisition (KYC) Credit Scoring Logistics Anti-fraud Card Origination Authorizer Billing Installment Purchases Credit Limits Investment Management FX Collections Treasury + Risk Rewards + Merchants Realtime Transfers Backoffice (CRM) Lending + Interest Rates Notification General Ledger Securitization Marketing Chargeback Tax Bill Pay Phone + Chat Infosec ETL INFRASTRUCTURE
  • 32. 0,8 1,5 2,3 3,0 Set-14 Jan-15 Mai-15 Set-15 Jan-16 Mai-16 Set-16 Jan-17 Mai-17 Set-17 SCALING BOTTLENECKS # of clients (M) Credit Card 1. database throughput limits required throttling writes 2. batch job latency impacting customer experience
  • 33. Need to partition the workload Customer data is spread across services Interactions between customers are minimal Safe to partition the user base SCALING PLAN
  • 34. Database writes were the worst bottleneck Option: horizontally partition each database Change every service to route queries and writes to the appropriate shard db shard s0 db shard s1 db shard s2 OPTION #1: PARTITION SERVICE DATABASES backend service
  • 35. Enormous effort to change every service Doesn’t address non-db bottlenecks Risks intermingling data infrastructure code with business logic OPTION #1: PROBLEMS
  • 36. OPTION #2: SCALABILITY UNITS SERVICE 1 SERVICE 2 SERVICE 3 SERVICE 1 SERVICE 2 SERVICE 3 SERVICE 1 SERVICE 2 SERVICE 3 shard S0 shard S1 shard s2 . . .
  • 37. OPTION #2: SCALABILITY UNITS + GLOBAL ROUTING SERVICE 1 SERVICE 2 SERVICE 3 SERVICE 1 SERVICE 2 SERVICE 3 shard S1 shard s2 SERVICE 4 SERVICE 5 global SERVICE 6 purchase deposit SERVICE 1 SERVICE 2 SERVICE 3 shard S0
  • 38. OPTION #2: HYPERMEDIA FOR INTERACTIONS SERVICE 1 SERVICE 2 SERVICE 3 shard S1 SERVICE 4 SERVICE 5 global SERVICE 6 login {"_links": {"account": “https://s1-service2…”}} {"_links": {"account": “https://s1-service3…”}}
  • 39. SCALING LESSONS LEARNED works in practice, but difficult to move incrementally in that direction SCALABILITY UNITS WORK sharding was a complex project exponential growth defies intuition: use real growth models for planning START EARLY provide critical flexibility for shard routing MESSAGING AND HYPERMEDIA made this process much more tractable AUTOMATED IMMUTABLE INFRA business logic may create hot spots reactivated old prospects overcrowded s0 BEWARE HOTSPOTS it’s devilishly difficult (we avoided it, mostly) SPLITTING EXISTING DATA
  • 40. FAULT TOLERANCE PATTERNS Simple patterns for fault isolation and recovery PRODUCER CONSUMER 1 Publish 2 Consume TOPIC DEADLETTER-TOPIC MORTICIAN 4 Persist 5 Republish DEADLETTERS CIRCUIT BREAKERS SERVICE 1 Consume 3 Circuit breaker trips! 3 Exception! Produce deadletter 2 Outbound fails 4 Pause consuming
  • 41. ETL + THE ANALYTICAL ENVIRONMENT Customer Acquisition (KYC) Credit Scoring Logistics Anti-fraud Card Origination Authorizer Billing Installment Purchases Credit Limits Investment Management FX Collections Treasury + Risk Rewards + Merchants Realtime Transfers Backoffice (CRM) Lending + Interest Rates Notification General Ledger Securitization Marketing Chargeback Tax Bill Pay Phone + Chat Infosec ETL INFRASTRUCTURE
  • 42. 01 NOV 10:00 Robot 437aae3 approves R$3K limit 01 NOV 11:00 Mastercard purchase, Starbucks, R$100 09 NOV 08:00 Support agent increases limit to R$5K 15 NOV 15:00 Customer blocks card 15 NOV 17:05 Customer joins waiting list for a card DATOMIC PRIMER: EVENTS OVER TIME
  • 43. 01 NOV 10:00 01 NOV 11:00 09 NOV 08:00 15 NOV 15:00 15 NOV 17:05 [<customer> :customer/id #uuid “b2c90…” 1] [<account> :account/customer <customer> 2] [<account> :account/limit 3000 2] [<card> :card/account <account> 2] [<card> :card/status :card.status/active 2] [<purchase> :purchase/card <card> 3] [<purchase> :purchase/amount 100 3] [<purchase> :purchase/merchant “Starbucks” 3] [<account> :account/limit 5000 4] [<account> :account/limit 3000 4] [<card> :card/status :card.status/blocked 5] [<card> :card/status :card.status/active 5] DATOMIC PRIMER: FACTS OVER TIME entity attribute value tx
  • 44. “The DAG” Pure functions (Scala SQL) Take datasets, return dataset Metadata (schema, partitions, path on S3, performance) Runs on Spark DB1 Log S0 DB1 Log S1 DB2 Log S0 Dataset Series Kafka topics Datomic DB logs EXTRACTOR Change capture Chunking Format conversion Auto-correcting S3 contract 1 contract 2 dataset 1 dataset 2 policy model Datomic and Kafka log extraction feeding our data lake (S3) in real time Analytical schemas (“contracts”) generated from Datomic entities Shards recombined into a logical table-per-entity incrementally EXTRACT, TRANSFORM, LOAD
  • 45. ETL EXAMPLE: CONTRIBUTION MARGIN from double entry from ERP are we making money?
  • 46. REALTIME TRANSFERS Customer Acquisition (KYC) Credit Scoring Logistics Anti-fraud Card Origination Authorizer Billing Installment Purchases Credit Limits Investment Management FX Collections Treasury + Risk Rewards + Merchants Realtime Transfers Backoffice (CRM) Lending + Interest Rates Notification General Ledger Securitization Marketing Chargeback Tax Bill Pay Phone + Chat Infosec ETL INFRASTRUCTURE
  • 47.
  • 48. REALTIME MONEY TRANSFER 1 Transfer request In-shard Transfers 3 Initiate transfer out Investments 2 Liquidate investment Global Transfers 4 Process transfer (global) Ledger 4 Debits + credits SPB Client EXTERNAL 5 Kafka <> SOAP 5 INTERNAL Shard routing RSFN (XML) SITRAF (TED) Hundreds of Brazilian banks 6 Realtime gross settlement
  • 49. BRAZILIAN PAYMENTS SYSTEM Hub and spoke model for national payments SPB Client 5 Kafka <> SOAP RSFN (XML) SITRAF (TED) Hundreds of Brazilian banks 6 Realtime gross settlement Real time gross, irrevocable and unconditional settlement of unlimited amounts ~R$1 trillion (US$300B) transferred per day 06:30 - 18:30 business days Proprietary XML protocol, IBM MQ Series messaging See: https://www.bcb.gov.br/Pom/Spb/Ing/Introduction.asp
  • 50. DOMAIN MODEL SUMMARY Customer Acquisition (KYC) Credit Scoring Logistics Anti-fraud Card Origination Authorizer Billing Installment Purchases Credit Limits Investment Management FX Collections Treasury + Risk Rewards + Merchants Realtime Transfers Backoffice (CRM) Lending + Interest Rates Notification General Ledger Securitization Marketing Chargeback Tax Bill Pay Phone + Chat Infosec ETL INFRASTRUCTURE
  • 55. EXTERNAL • Client authentication (mutual TLS) • authorizing new device with reputation score • Immutable infrastructure • Short-lived instances • No mutations • Bootstrap service identity from instance profiles using IAM • Uniformity of service architecture enables rapid patching KEY SECURITY DECISIONS INTERNAL • Auto-revoke of access scopes • Operational scopes are short lived • Customer contact enables access • Employee access bootstrapped from Google OAuth, 2FA + Yubikeys required • Realtime monitoring of security events • Cloudtrail, Slack, Lambdas for fine-grained operational access control • Internal red team / incident response team
  • 56. 0 1,25 2,5 3,75 5 0 13 26 39 52 65 78 91 104117130143156169182195208221234247260273286299312325338351364377390403416429442455468481494507520533546559572585598611624 2016-02 2016-06 2016-09 2016-12 2017-03 2017-06 2017-09 GROWING ORGANICALLY THROUGH REFERRALS Each customer we book leads to 3-4 new leads # of Leads Sample Cohorts - Days after release