SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
COORDINATING
NON-BLOCKING IO
AND
ASYNC HTTP RESPONSES
WHAT IS THE WEB STACK

•
•
•

HttpKit as web server
Compojure for routing
HttpKit for non-blocking http requests
REACTIVE APPROACH
PREFERRED

We are not using either Functional Reactive Programming or
Reactive Programming libraries. Eg. Rx.java
• May satisfy other more broad definitions of reactive
• Are making better use of threads than traditional approaches
•
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. Send request to payment gateway	

2. Find how much was left to be payed	

!

If payment is success: render amount remaining on bill	

If payment fails: render error
CANDIDATES
• Synchronous

promises	


• core.async	


• Promise

monad let/do	


• Lamina

• Promise

monad chain/lift-

• Meltdown

m-2	


pipeline	


(LMAX
Disrupter)	


• Raw

promises	


• Pulsar

promises	


• Raw

callbacks	


• 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:
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.1:
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 1.2:
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.3:
PROMISE + ERROR MONADS
(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	
  (render-­‐remaining-­‐response	
  details	
  amount))))
SOLUTION 2:
PROMISE CHAIN AND LIFT-M-2
(GET	
  "/bills/:bill-­‐id/payments"	
  [bill-­‐id	
  user-­‐id	
  amount]	
  
	
  	
  	
  	
  	
  (let	
  [transaction-­‐req	
  (chain	
  (promise	
  user-­‐id)	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  auth/card-­‐token	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  (partial	
  payment/bill	
  bill-­‐id	
  amount))	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  details-­‐req	
  	
  	
  	
  	
  (bill/details	
  bill-­‐id)]	
  
	
  	
  	
  	
  	
  	
  	
  (lift-­‐m-­‐2	
  (fn	
  [transaction	
  details]	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  (if	
  (success?	
  transaction)	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  (render-­‐remaining-­‐response	
  details	
  amount)	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  error-­‐response)))	
  
	
  	
  	
  	
  	
  	
  	
  transaction-­‐req	
  details-­‐req))	
  
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
SCALA
	
  	
  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)
	
  	
  	
  	
  }
	
  	
  }
REQUESTS PER SECOND
HELLO WORLD
• Single

C1-Medium	


• 7GB
•8

Ram	


Cores	


• 313,852

Concurrent Users	


• 4756.79

Requests Per

Second	


• More

meaningful results
once in SVT with full
implementation
ALL DONE AT	

AUSTRALIA POST	

DIGITAL MAILBOX
They're hiring.	

Send your CV to	

APDMRecruitment@auspost.com.au

Contenu connexe

Similaire à Coordinating non blocking io melb-clj

7 client-state manipulation
7   client-state manipulation7   client-state manipulation
7 client-state manipulationdrewz lin
 
Taming Distribution: Formal Protocols for Akka Typed
Taming Distribution: Formal Protocols for Akka TypedTaming Distribution: Formal Protocols for Akka Typed
Taming Distribution: Formal Protocols for Akka TypedRoland Kuhn
 
aming distribution: formal protocols for Akka Typed
aming distribution: formal protocols for Akka Typedaming distribution: formal protocols for Akka Typed
aming distribution: formal protocols for Akka TypedJ On The Beach
 
Shangz R Brown Presentation
Shangz R Brown PresentationShangz R Brown Presentation
Shangz R Brown Presentationshangbaby
 
Payment Request API with a React high order component
Payment Request API with a React high order componentPayment Request API with a React high order component
Payment Request API with a React high order componentMarco Lanaro
 
The atm system
The atm systemThe atm system
The atm systemLê Đức
 
eZ Publish Workflows and Payment Gateways
eZ Publish Workflows and Payment GatewayseZ Publish Workflows and Payment Gateways
eZ Publish Workflows and Payment GatewaysGraham Brookins
 
Payment create a ppr for multiple legal entities (eft)
Payment create a ppr for multiple legal entities (eft)Payment create a ppr for multiple legal entities (eft)
Payment create a ppr for multiple legal entities (eft)Kotesh Kumar
 
BizSmart Corporate Back Office Guide
BizSmart Corporate Back Office GuideBizSmart Corporate Back Office Guide
BizSmart Corporate Back Office GuideAllianceBankMY
 
Integration of payment gateways using Paypal account
Integration of payment gateways using Paypal account Integration of payment gateways using Paypal account
Integration of payment gateways using Paypal account Phenom People
 
Barcelona Developers Conference 2011
Barcelona Developers Conference 2011Barcelona Developers Conference 2011
Barcelona Developers Conference 2011PayPal
 
Monetize your idea! - Pay Pal
Monetize your idea! - Pay PalMonetize your idea! - Pay Pal
Monetize your idea! - Pay PalDroidcon Spain
 
2012 SVCodeCamp: In App Payments with HTML5
2012 SVCodeCamp: In App Payments with HTML52012 SVCodeCamp: In App Payments with HTML5
2012 SVCodeCamp: In App Payments with HTML5Jonathan LeBlanc
 
DEMATERIALISATION:MODES & PROCEDURE
DEMATERIALISATION:MODES & PROCEDUREDEMATERIALISATION:MODES & PROCEDURE
DEMATERIALISATION:MODES & PROCEDURERavi kumar
 

Similaire à Coordinating non blocking io melb-clj (20)

7 client-state manipulation
7   client-state manipulation7   client-state manipulation
7 client-state manipulation
 
Taming Distribution: Formal Protocols for Akka Typed
Taming Distribution: Formal Protocols for Akka TypedTaming Distribution: Formal Protocols for Akka Typed
Taming Distribution: Formal Protocols for Akka Typed
 
aming distribution: formal protocols for Akka Typed
aming distribution: formal protocols for Akka Typedaming distribution: formal protocols for Akka Typed
aming distribution: formal protocols for Akka Typed
 
Open web payments
Open web paymentsOpen web payments
Open web payments
 
Shangz R Brown Presentation
Shangz R Brown PresentationShangz R Brown Presentation
Shangz R Brown Presentation
 
Payments On Rails
Payments On RailsPayments On Rails
Payments On Rails
 
Payment Request API with a React high order component
Payment Request API with a React high order componentPayment Request API with a React high order component
Payment Request API with a React high order component
 
The atm system
The atm systemThe atm system
The atm system
 
The atm system
The atm systemThe atm system
The atm system
 
eZ Publish Workflows and Payment Gateways
eZ Publish Workflows and Payment GatewayseZ Publish Workflows and Payment Gateways
eZ Publish Workflows and Payment Gateways
 
SQL Server 2008 Portfolio
SQL Server 2008 PortfolioSQL Server 2008 Portfolio
SQL Server 2008 Portfolio
 
Payment create a ppr for multiple legal entities (eft)
Payment create a ppr for multiple legal entities (eft)Payment create a ppr for multiple legal entities (eft)
Payment create a ppr for multiple legal entities (eft)
 
BizSmart Corporate Back Office Guide
BizSmart Corporate Back Office GuideBizSmart Corporate Back Office Guide
BizSmart Corporate Back Office Guide
 
Integration of payment gateways using Paypal account
Integration of payment gateways using Paypal account Integration of payment gateways using Paypal account
Integration of payment gateways using Paypal account
 
Barcelona Developers Conference 2011
Barcelona Developers Conference 2011Barcelona Developers Conference 2011
Barcelona Developers Conference 2011
 
Monetize your idea! - Pay Pal
Monetize your idea! - Pay PalMonetize your idea! - Pay Pal
Monetize your idea! - Pay Pal
 
Banking Database
Banking DatabaseBanking Database
Banking Database
 
2012 SVCodeCamp: In App Payments with HTML5
2012 SVCodeCamp: In App Payments with HTML52012 SVCodeCamp: In App Payments with HTML5
2012 SVCodeCamp: In App Payments with HTML5
 
Look Who's Talking
Look Who's TalkingLook Who's Talking
Look Who's Talking
 
DEMATERIALISATION:MODES & PROCEDURE
DEMATERIALISATION:MODES & PROCEDUREDEMATERIALISATION:MODES & PROCEDURE
DEMATERIALISATION:MODES & PROCEDURE
 

Dernier

The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai KuwaitThe Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwaitdaisycvs
 
Lucknow Housewife Escorts by Sexy Bhabhi Service 8250092165
Lucknow Housewife Escorts  by Sexy Bhabhi Service 8250092165Lucknow Housewife Escorts  by Sexy Bhabhi Service 8250092165
Lucknow Housewife Escorts by Sexy Bhabhi Service 8250092165meghakumariji156
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityEric T. Tung
 
PHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPanhandleOilandGas
 
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAIGetting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAITim Wilson
 
Famous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st CenturyFamous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st Centuryrwgiffor
 
Buy Verified TransferWise Accounts From Seosmmearth
Buy Verified TransferWise Accounts From SeosmmearthBuy Verified TransferWise Accounts From Seosmmearth
Buy Verified TransferWise Accounts From SeosmmearthBuy Verified Binance Account
 
Falcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon investment
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...daisycvs
 
Power point presentation on enterprise performance management
Power point presentation on enterprise performance managementPower point presentation on enterprise performance management
Power point presentation on enterprise performance managementVaishnaviGunji
 
Pre Engineered Building Manufacturers Hyderabad.pptx
Pre Engineered  Building Manufacturers Hyderabad.pptxPre Engineered  Building Manufacturers Hyderabad.pptx
Pre Engineered Building Manufacturers Hyderabad.pptxRoofing Contractor
 
TVB_The Vietnam Believer Newsletter_May 6th, 2024_ENVol. 006.pdf
TVB_The Vietnam Believer Newsletter_May 6th, 2024_ENVol. 006.pdfTVB_The Vietnam Believer Newsletter_May 6th, 2024_ENVol. 006.pdf
TVB_The Vietnam Believer Newsletter_May 6th, 2024_ENVol. 006.pdfbelieveminhh
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with CultureSeta Wicaksana
 
Falcon Invoice Discounting: Aviate Your Cash Flow Challenges
Falcon Invoice Discounting: Aviate Your Cash Flow ChallengesFalcon Invoice Discounting: Aviate Your Cash Flow Challenges
Falcon Invoice Discounting: Aviate Your Cash Flow Challengeshemanthkumar470700
 
Putting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxPutting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxCynthia Clay
 
Falcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to ProsperityFalcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to Prosperityhemanthkumar470700
 
Marel Q1 2024 Investor Presentation from May 8, 2024
Marel Q1 2024 Investor Presentation from May 8, 2024Marel Q1 2024 Investor Presentation from May 8, 2024
Marel Q1 2024 Investor Presentation from May 8, 2024Marel
 
Falcon Invoice Discounting: Tailored Financial Wings
Falcon Invoice Discounting: Tailored Financial WingsFalcon Invoice Discounting: Tailored Financial Wings
Falcon Invoice Discounting: Tailored Financial WingsFalcon Invoice Discounting
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfAdmir Softic
 

Dernier (20)

The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai KuwaitThe Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
 
Lucknow Housewife Escorts by Sexy Bhabhi Service 8250092165
Lucknow Housewife Escorts  by Sexy Bhabhi Service 8250092165Lucknow Housewife Escorts  by Sexy Bhabhi Service 8250092165
Lucknow Housewife Escorts by Sexy Bhabhi Service 8250092165
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League City
 
PHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation Final
 
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAIGetting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
 
Famous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st CenturyFamous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st Century
 
Buy Verified TransferWise Accounts From Seosmmearth
Buy Verified TransferWise Accounts From SeosmmearthBuy Verified TransferWise Accounts From Seosmmearth
Buy Verified TransferWise Accounts From Seosmmearth
 
Falcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business Growth
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
 
Power point presentation on enterprise performance management
Power point presentation on enterprise performance managementPower point presentation on enterprise performance management
Power point presentation on enterprise performance management
 
Pre Engineered Building Manufacturers Hyderabad.pptx
Pre Engineered  Building Manufacturers Hyderabad.pptxPre Engineered  Building Manufacturers Hyderabad.pptx
Pre Engineered Building Manufacturers Hyderabad.pptx
 
TVB_The Vietnam Believer Newsletter_May 6th, 2024_ENVol. 006.pdf
TVB_The Vietnam Believer Newsletter_May 6th, 2024_ENVol. 006.pdfTVB_The Vietnam Believer Newsletter_May 6th, 2024_ENVol. 006.pdf
TVB_The Vietnam Believer Newsletter_May 6th, 2024_ENVol. 006.pdf
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with Culture
 
Falcon Invoice Discounting: Aviate Your Cash Flow Challenges
Falcon Invoice Discounting: Aviate Your Cash Flow ChallengesFalcon Invoice Discounting: Aviate Your Cash Flow Challenges
Falcon Invoice Discounting: Aviate Your Cash Flow Challenges
 
Putting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxPutting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptx
 
Buy gmail accounts.pdf buy Old Gmail Accounts
Buy gmail accounts.pdf buy Old Gmail AccountsBuy gmail accounts.pdf buy Old Gmail Accounts
Buy gmail accounts.pdf buy Old Gmail Accounts
 
Falcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to ProsperityFalcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to Prosperity
 
Marel Q1 2024 Investor Presentation from May 8, 2024
Marel Q1 2024 Investor Presentation from May 8, 2024Marel Q1 2024 Investor Presentation from May 8, 2024
Marel Q1 2024 Investor Presentation from May 8, 2024
 
Falcon Invoice Discounting: Tailored Financial Wings
Falcon Invoice Discounting: Tailored Financial WingsFalcon Invoice Discounting: Tailored Financial Wings
Falcon Invoice Discounting: Tailored Financial Wings
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
 

Coordinating non blocking io melb-clj

  • 2.
  • 3. WHAT IS THE WEB STACK • • • HttpKit as web server Compojure for routing HttpKit for non-blocking http requests
  • 4. REACTIVE APPROACH PREFERRED We are not using either Functional Reactive Programming or Reactive Programming libraries. Eg. Rx.java • May satisfy other more broad definitions of reactive • Are making better use of threads than traditional approaches •
  • 5. 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. Send request to payment gateway 2. Find how much was left to be payed ! If payment is success: render amount remaining on bill If payment fails: render error
  • 6. CANDIDATES • Synchronous promises • core.async • Promise monad let/do • Lamina • Promise monad chain/lift- • Meltdown m-2 pipeline (LMAX Disrupter) • Raw promises • Pulsar promises • Raw callbacks • Pulsar Actors
  • 7. 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)))  
  • 8. SOLUTION 1: 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)))))
  • 9. SOLUTION 1.1: 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)))))
  • 10. SOLUTION 1.2: 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))))
  • 11. SOLUTION 1.3: PROMISE + ERROR MONADS (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  (render-­‐remaining-­‐response  details  amount))))
  • 12. SOLUTION 2: PROMISE CHAIN AND LIFT-M-2 (GET  "/bills/:bill-­‐id/payments"  [bill-­‐id  user-­‐id  amount]            (let  [transaction-­‐req  (chain  (promise  user-­‐id)                                                                      auth/card-­‐token                                                                      (partial  payment/bill  bill-­‐id  amount))                        details-­‐req          (bill/details  bill-­‐id)]                (lift-­‐m-­‐2  (fn  [transaction  details]                                        (if  (success?  transaction)                                            (render-­‐remaining-­‐response  details  amount)                                            error-­‐response)))                transaction-­‐req  details-­‐req))  
  • 13. 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)))))
  • 15. 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))))
  • 16. 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)))))
  • 18. 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)))
  • 20. (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
  • 21. SCALA    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)        }    }
  • 23. HELLO WORLD • Single C1-Medium • 7GB •8 Ram Cores • 313,852 Concurrent Users • 4756.79 Requests Per Second • More meaningful results once in SVT with full implementation
  • 24. ALL DONE AT AUSTRALIA POST DIGITAL MAILBOX They're hiring. Send your CV to APDMRecruitment@auspost.com.au