SlideShare a Scribd company logo
CLOJURE AT A POST OFFICE
HTTP-KIT
• AWS C1-Medium!
• 7GB Ram!
• 8 Cores
• 313,852 Concurrent Users!
• 4756.79 Requests Per Second
If payment is success: display amount remaining on bill!
If payment fails: display error
Make a payment on a bill!
- Not necessarily a full payment
POST /bills/:bill-id/payments
Session: user-id
Post Data: amount
1. GET credit card token for user!
1.1. POST request to payment gateway!
2. GET how much was left to be payed
CANDIDATES
• Synchronous promises!
• Promise monad let/do!
• Raw promises!
• Raw callbacks!
• core.async!
• Lamina pipeline!
• Meltdown (LMAX
Disrupter)!
• Pulsar promises!
• Pulsar Actors
SOLUTION 0:
SYNCHRONOUS
(GET""/bills/:bill*id/payments""[bill*id"user*id"amount]"
""(let'[token"""""""(auth/card/token"user*id)"
""""""""details"""""(bill/details"bill*id)"
""""""""transaction"(payment/bill"bill*id"amount"@token)]"
""""(if'(success?"@transaction)"
""""""(render/remaining/response"@details"amount)"
""""""error*response)))"
SOLUTION 1.1:
PROMISE MONAD DO
(GET""/bills/:bill*id/payments""[bill*id"user*id"amount]"
"""""(do'[token"""""""(auth/card/token"user*id)"
""""""""""transaction"(payment/bill"bill*id"amount"token)"
""""""""""details"""""(bill/details"bill*id)]"
"""""""""(return"
"""""""""""(if'(success?"transaction)"
"""""""""""""(render/remaining/response"details"amount)"
"""""""""""""error*response))))
SOLUTION 1.2:
PROMISE MONAD LET/DO
(GET""/bills/:bill*id/payments""[bill*id"user*id"amount]"
"""""(let'[token*req"""(auth/card/token"user*id)"
"""""""""""details*req"(bill/details"bill*id)]"
"""""""(do'[token"""""""token*req"
""""""""""""transaction"(payment/bill"bill*id"amount"token)"
""""""""""""details"""""details*req]"
"""""""""""(return"
"""""""""""""(if'(success?"transaction)"
"""""""""""""""(render/remaining/response"details"amount)"
"""""""""""""""error*response)))))
SOLUTION 1.3:
PROMISE MONAD LET/DO/DO
(GET""/bills/:bill*id/payments""[bill*id"user*id"amount]"
"""""(let'[token*req"""(auth/card/token"user*id)"
"""""""""""details*req"(bill/details"bill*id)]"
"""""""(do'[token"""""""token*req"
""""""""""""transaction"(payment/bill"bill*id"amount"token)]"
"""""""""""(if'(success?"transaction)"
"""""""""""""(do'[details"details*req]"
"""""""""""""""""(return"(render/remaining/response"details"amount)))"
"""""""""""""(return"error*response)))))
SOLUTION 3:
RAW PROMISES
(GET""/bills/:bill*id/payments""[bill*id"user*id"amount]"
"""""(let'[transaction*req"(*>"(auth/card/token"user*id)"
"""""""""""""""""""""""""""""""(then"(partial"payment/bill"bill*id"amount)))"
"""""""""""details*req"""""(bill/details"bill*id)]"
"""""""(when"transaction*req"details*req"
"""""""""(fn'[transaction"details]"
"""""""""""(if'(success?"transaction)"
"""""""""""""(render/remaining/response"details"amount)"
"""""""""""""error*response)))))
SOLUTION 4:
RAW CALLBACKS
Not"Viable
SOLUTION 5:
CORE.ASYNC
(GET""/bills/:bill*id/payments""[bill*id"user*id"amount]"
"""""(go"(let'[token"""""""(auth/card/token"user*id)"
"""""""""""""""details"""""(bill/details"bill*id)"
"""""""""""""""transaction"(payment/bill"bill*id"amount"(<!"token))]"
"""""""""""(if'(success?"(<!"transaction))"
"""""""""""""(render/remaining/response"(<!"details)"amount)"
"""""""""""""error*response))))
SOLUTION 6:
LAMINA PIPELINE
(GET""/bills/:bill*id/payments""[bill*id"user*id"amount]"
"""""(let'[details*req"(bill/details"bill*id)]"
"""""""(pipeline"(auth/card/token"user*id)"
"""""""""""""""""(partial"payment/bill"bill*id"amount)"
"""""""""""""""""(fn'[transaction]"
"""""""""""""""""""(if'(success?"transaction)"
"""""""""""""""""""""(on/realized"details*req"
""""""""""""""""""""""""""""""""""(fn'[details]"
""""""""""""""""""""""""""""""""""""(render/remaining/response"details"amount)))"
"""""""""""""""""""""error*response)))))
SOLUTION 7:
MELTDOWN
No"point
SOLUTION 8:
PULSAR PROMISES
(GET""/bills/:bill*id/payments""[bill*id"user*id"amount]"
""#(let'[token"""""""(auth/card/token"user*id)"
"""""""""details"""""(bill/details"bill*id)"
"""""""""transaction"(payment/bill"bill*id"amount"@token)]"
""""(if'(success?"@transaction)"
""""""(render/remaining/response"@details"amount)"
""""""error*response)))
SOLUTION 9:
PULSAR ACTORS
Not"Appropriate
(GET""/bills/:bill*id/payments""[bill*id"user*id"amount]"
""(let'[token"""""""(auth/card/token"user*id)"
""""""""details"""""(bill/details"bill*id)"
""""""""transaction"(payment/bill"bill*id"amount"@token)]"
""""(if'(success?"@transaction)"
""""""(render/remaining/response"@details"amount)"
""""""error*response))) Synchronous
(GET""/bills/:bill*id/payments""[bill*id"user*id"amount]"
""(go"(let'[token"""""""(auth/card/token"user*id)"
""""""""""""details"""""(bill/details"bill*id)"
""""""""""""transaction"(payment/bill"bill*id"amount"(<!"token))]"
""""""""(if'(success?"(<!"transaction))"
""""""""""(render/remaining/response"(<!"details)"amount)"
""""""""""error*response)))) core.async
(GET""/bills/:bill*id/payments""[bill*id"user*id"amount]"
""#(let'[token"""""""(auth/card/token"user*id)"
"""""""""details"""""(bill/details"bill*id)"
"""""""""transaction"(payment/bill"bill*id"amount"@token)]"
"""""(if'(success?"@transaction)"
"""""""(render/remaining/response"@details"amount)"
"""""""(error/response)))) Pulsar
""def"payBill(billId:"Integer,"userId:"Integer,"amount:"Integer):Future[Option[Json]]"="{
""""val"seq"="for"{
""""""token"<*"Auth.cardToken(userId)
""""""tr"<*"Payment.bill(token)
""""}"yield"tr
"
""""async"{
""""""val"transactionProcess"="await(seq.run)
""""""val"detailProcess"="await(BillOps.details(billId))
""""""for"{
""""""""transaction"<*"transactionProcess
""""""""detail"<*"detailProcess
""""""}"yield"renderRemainingResponse(amount,"detail)
""""}
""}
SCALA
REQUESTS PER SECOND
CQRS!
• Want fast reads. Reduce the
number of queries.!
• Don't want to have to
update write code every
time we add a new reader.!
• Don't want to have to
update reader every time
there's a new writer.!
• Would be great to have an
event stream to re-calculate
current state.
1.#Just#write#to#normalised#copy#
1.1.# Just#read#everything#every#time#
1.2.# Read#and#cache#
1.2.1.# Cache#the#page#
1.2.2.# Cache#the#intermediate#data;structure#
2.#Just#write#to#views#
2.1.# Direct#write#
2.2.# Event#stream#
2.2.1.# Persisted#
2.2.1.1.# Domain#events#
2.2.1.1.1.#Live#update#
2.2.1.1.2.#Async#update#
2.2.1.2.# CRUD#event#
2.2.1.2.1.#Live#update#
2.2.1.2.2.#Async#update#
2.2.2.# Ephemeral#
2.2.2.1.# Domain#events#
2.2.2.1.1.#Live#update#
2.2.2.2.# CRUD#event#
2.2.2.2.1.#Live#update#
3.#Write#to#views#and#normalized#copy##
3.1.# Direct#write#
3.2.# Event#stream#
3.2.1.# Persisted#
3.2.1.1.# Domain#events#
3.2.1.1.1.#Live#update#
3.2.1.1.2.#Async#update#
3.2.1.2.# CRUD#event#
3.2.1.2.1.#Live#update#
3.2.1.2.2.#Async#update#
3.2.2.# Ephemeral#
3.2.2.1.# Domain#events#
3.2.2.1.1.#Live#update#
3.2.2.2.# CRUD#event#
3.2.2.2.1.#Live#update#
3.3.# Write#to#normalized#keyspace#causing#
trigger#
3.3.1.# Direct#update#to#views#
3.3.2.# Event#to#be#published#
3.3.2.1.# Persisted#
3.3.2.1.1.#Live#Update#
3.3.2.1.2.#Async#update#
3.3.2.2.# Ephemeral#
3.3.2.2.1.#Live#Update
Write
!
!
Cassandra
Service A
Service B Index Maintainer
Notify
Read Write
Rabbit MQ
Publish
Triggers
CASSANDRATRIGGERS
• Can just throw the Clojure
jar in there!
• Everything is byte buffers!
• Need to know the type of
fields out of band!
• One class per trigger per
table!
• Bizarre key names (format
changes depending on value
type)
User
Service
Mail
Service
Provider
Service
Cassandra
IOS Web Android
User
Service
Authentication
Multi Factor
Authentication
Authorisation
User Profile
Password Reset
Clojure at a post office

More Related Content

Similar to Clojure at a post office

Project report on (atm MAnagment system)
Project report on (atm MAnagment system)Project report on (atm MAnagment system)
Project report on (atm MAnagment system)Muhammad Umer Lari
 
The Real World - Plugging the Enterprise Into It (nodejs)
The Real World - Plugging  the Enterprise Into It (nodejs)The Real World - Plugging  the Enterprise Into It (nodejs)
The Real World - Plugging the Enterprise Into It (nodejs)Aman Kohli
 
transactions-advanced for automatic payment.pptx
transactions-advanced for automatic payment.pptxtransactions-advanced for automatic payment.pptx
transactions-advanced for automatic payment.pptxssusereced02
 
CNIT 129S: Ch 7: Attacking Session Management
CNIT 129S: Ch 7: Attacking Session Management CNIT 129S: Ch 7: Attacking Session Management
CNIT 129S: Ch 7: Attacking Session Management Sam Bowne
 
Introduction to Ethereum
Introduction to EthereumIntroduction to Ethereum
Introduction to EthereumArnold Pham
 
Ch 7: Attacking Session Management
Ch 7: Attacking Session ManagementCh 7: Attacking Session Management
Ch 7: Attacking Session ManagementSam Bowne
 
CNIT 129S Ch 7: Attacking Session Management
CNIT 129S Ch 7: Attacking Session ManagementCNIT 129S Ch 7: Attacking Session Management
CNIT 129S Ch 7: Attacking Session ManagementSam Bowne
 
TrialPay Security Tech Talk at Stanford ACM
TrialPay Security Tech Talk at Stanford ACMTrialPay Security Tech Talk at Stanford ACM
TrialPay Security Tech Talk at Stanford ACMhackingtrialpay
 
Payment Services in Kuwait
Payment Services in KuwaitPayment Services in Kuwait
Payment Services in KuwaitBurhan Khalid
 
FME Cloud Goes Blockchain - Accepting Payments via Bitcoins with FME Server
FME Cloud Goes Blockchain - Accepting Payments via Bitcoins with FME ServerFME Cloud Goes Blockchain - Accepting Payments via Bitcoins with FME Server
FME Cloud Goes Blockchain - Accepting Payments via Bitcoins with FME ServerSafe Software
 
HTTP Services & REST API Security
HTTP Services & REST API SecurityHTTP Services & REST API Security
HTTP Services & REST API SecurityTaiseer Joudeh
 
Demysitifying Bitcoin and Blockchain
Demysitifying Bitcoin and Blockchain Demysitifying Bitcoin and Blockchain
Demysitifying Bitcoin and Blockchain Ganesh Kondal
 
Micro-service architectures with Gilmour
Micro-service architectures with GilmourMicro-service architectures with Gilmour
Micro-service architectures with GilmourAditya Godbole
 
Rate Limiting at Scale, from SANS AppSec Las Vegas 2012
Rate Limiting at Scale, from SANS AppSec Las Vegas 2012Rate Limiting at Scale, from SANS AppSec Las Vegas 2012
Rate Limiting at Scale, from SANS AppSec Las Vegas 2012Nick Galbreath
 
XMPP/Jingle(VoIP)/Perl Ocean 2012/03
XMPP/Jingle(VoIP)/Perl Ocean 2012/03XMPP/Jingle(VoIP)/Perl Ocean 2012/03
XMPP/Jingle(VoIP)/Perl Ocean 2012/03Lyo Kato
 
Wireless Hotspot: The Hackers Playground
Wireless Hotspot: The Hackers PlaygroundWireless Hotspot: The Hackers Playground
Wireless Hotspot: The Hackers PlaygroundJim Geovedi
 
Connect front end to back end using SignalR and Messaging
Connect front end to back end using SignalR and MessagingConnect front end to back end using SignalR and Messaging
Connect front end to back end using SignalR and MessagingParticular Software
 
Devops London 2013 - Robust systems or, not fucking the customer
Devops London 2013 - Robust systems or, not fucking the customerDevops London 2013 - Robust systems or, not fucking the customer
Devops London 2013 - Robust systems or, not fucking the customerSteve Smith
 

Similar to Clojure at a post office (20)

Project report on (atm MAnagment system)
Project report on (atm MAnagment system)Project report on (atm MAnagment system)
Project report on (atm MAnagment system)
 
The Real World - Plugging the Enterprise Into It (nodejs)
The Real World - Plugging  the Enterprise Into It (nodejs)The Real World - Plugging  the Enterprise Into It (nodejs)
The Real World - Plugging the Enterprise Into It (nodejs)
 
transactions-advanced for automatic payment.pptx
transactions-advanced for automatic payment.pptxtransactions-advanced for automatic payment.pptx
transactions-advanced for automatic payment.pptx
 
CNIT 129S: Ch 7: Attacking Session Management
CNIT 129S: Ch 7: Attacking Session Management CNIT 129S: Ch 7: Attacking Session Management
CNIT 129S: Ch 7: Attacking Session Management
 
Introduction to Ethereum
Introduction to EthereumIntroduction to Ethereum
Introduction to Ethereum
 
Ch 7: Attacking Session Management
Ch 7: Attacking Session ManagementCh 7: Attacking Session Management
Ch 7: Attacking Session Management
 
CNIT 129S Ch 7: Attacking Session Management
CNIT 129S Ch 7: Attacking Session ManagementCNIT 129S Ch 7: Attacking Session Management
CNIT 129S Ch 7: Attacking Session Management
 
TrialPay Security Tech Talk at Stanford ACM
TrialPay Security Tech Talk at Stanford ACMTrialPay Security Tech Talk at Stanford ACM
TrialPay Security Tech Talk at Stanford ACM
 
Open web payments
Open web paymentsOpen web payments
Open web payments
 
Payments On Rails
Payments On RailsPayments On Rails
Payments On Rails
 
Payment Services in Kuwait
Payment Services in KuwaitPayment Services in Kuwait
Payment Services in Kuwait
 
FME Cloud Goes Blockchain - Accepting Payments via Bitcoins with FME Server
FME Cloud Goes Blockchain - Accepting Payments via Bitcoins with FME ServerFME Cloud Goes Blockchain - Accepting Payments via Bitcoins with FME Server
FME Cloud Goes Blockchain - Accepting Payments via Bitcoins with FME Server
 
HTTP Services & REST API Security
HTTP Services & REST API SecurityHTTP Services & REST API Security
HTTP Services & REST API Security
 
Demysitifying Bitcoin and Blockchain
Demysitifying Bitcoin and Blockchain Demysitifying Bitcoin and Blockchain
Demysitifying Bitcoin and Blockchain
 
Micro-service architectures with Gilmour
Micro-service architectures with GilmourMicro-service architectures with Gilmour
Micro-service architectures with Gilmour
 
Rate Limiting at Scale, from SANS AppSec Las Vegas 2012
Rate Limiting at Scale, from SANS AppSec Las Vegas 2012Rate Limiting at Scale, from SANS AppSec Las Vegas 2012
Rate Limiting at Scale, from SANS AppSec Las Vegas 2012
 
XMPP/Jingle(VoIP)/Perl Ocean 2012/03
XMPP/Jingle(VoIP)/Perl Ocean 2012/03XMPP/Jingle(VoIP)/Perl Ocean 2012/03
XMPP/Jingle(VoIP)/Perl Ocean 2012/03
 
Wireless Hotspot: The Hackers Playground
Wireless Hotspot: The Hackers PlaygroundWireless Hotspot: The Hackers Playground
Wireless Hotspot: The Hackers Playground
 
Connect front end to back end using SignalR and Messaging
Connect front end to back end using SignalR and MessagingConnect front end to back end using SignalR and Messaging
Connect front end to back end using SignalR and Messaging
 
Devops London 2013 - Robust systems or, not fucking the customer
Devops London 2013 - Robust systems or, not fucking the customerDevops London 2013 - Robust systems or, not fucking the customer
Devops London 2013 - Robust systems or, not fucking the customer
 

Recently uploaded

The AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdfThe AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdfSiskaFitrianingrum
 
How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?Linksys Velop Login
 
Article writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptxArticle writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptxabhinandnam9997
 
The Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case StudyThe Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case StudyDamar Juniarto
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesSanjeev Rampal
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxlaozhuseo02
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shoplaozhuseo02
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEHimani415946
 
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理aagad
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxGal Baras
 
Pvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdfPvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdfPvtaan
 

Recently uploaded (12)

The AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdfThe AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdf
 
How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?
 
Article writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptxArticle writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptx
 
The Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case StudyThe Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case Study
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
 
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
 
The Best AI Powered Software - Intellivid AI Studio
The Best AI Powered Software - Intellivid AI StudioThe Best AI Powered Software - Intellivid AI Studio
The Best AI Powered Software - Intellivid AI Studio
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
Pvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdfPvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdf
 

Clojure at a post office