Your SlideShare is downloading. ×
Concurrent Processing Techniques
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Concurrent Processing Techniques

989
views

Published on

Traditional concurrent development on the Java Platform requires in depth knowledge of threads, locks, and queues. Fortunately, new languages and frameworks that run on the Java Platform, such as …

Traditional concurrent development on the Java Platform requires in depth knowledge of threads, locks, and queues. Fortunately, new languages and frameworks that run on the Java Platform, such as Akka, have made concurrent programming easier. This presentation covers concurrent processing techniques using these technologies.

Published in: Technology, Education

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
989
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
28
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Concurrent  Processing  Techniques   Jeremy  Deane     h6p://jeremydeane.net/  
  • 2. Agenda      Mulit-­‐Core  ImperaBve      Concurrent  Processing  Impediments      Demo  Web  ApplicaBon      Java  Concurrency  Package      Akka  Actors      Asynchronous  Web  Services      QuesBons  and  Feedback  
  • 3. MulB-­‐Core  Crisis  2006   h6p://smoothspan.wordpress.com/2007/09/06/a-­‐picture-­‐of-­‐the-­‐mulBcore-­‐crisis/  
  • 4. MulB-­‐Core  ImperaBve  (Arg!!!  Its  2014)   The  ugly  truth  about  mulBple  cores  is  that  soVware  has  to  be   wri6en  to  take  advantage  of  all  the  addiBonal  processors.   Instead  of  doing  everything  in  a  linear  fashion  (with  one  step   following  the  compleBon  of  another),  programmers   need  to  ensure  their  applica3ons  are  designed   to  be  able  to  do  many  tasks  simultaneously.   NetworkWorld  September  2009   Concurrency  was  once  considered  esoteric,  something  we   could  consider  to  avoid  in  the  past.  However,  with  the   improved  hardware  capabiliBes,  we  may  not  have  a   choice  here,  it  is  a  challenge  we've  been  drawn   into,  whether  we  wanted  it  or  not.   Venkat  Subramaniam  January  2012  
  • 5. Concurrent  Processing  Impediments   Task  or  Data  DecomposiBon   Deadlocks  and  StarvaBon   Race  CondiBons   Concurrent  TesBng   Concurrent  Processing  is  Fracken  Hard!  
  • 6. Orders  Web  ApplicaBon      Spring  MVC  Web  ApplicaBon      Spring  MVC  4  &  Servlet  3      Res_ul  Web  Services        Java  Concurrency  Library      Akka  Actors      Concurrency  Pa6erns        Fire  &  Forget      Pipeline      Map-­‐Reduce      Fork-­‐Join      Producer-­‐Consumer  
  • 7. Order  Processing  –  Single-­‐Threaded  Processing   RESTFUL WEB SERVICE BATCH SERVICE ORDER PROCESS Single Thread …  |  492438277@qtp-­‐1840511017-­‐0  |  ORD  X1414  PRI  $12  ST  $60.0  DISC  .10%  T  $54   …  |  492438277@qtp-­‐1840511017-­‐0  |  ORD  X1415  PRI  $8  ST  $32.0  DISC  .5%  T  $16   …  |  492438277@qtp-­‐1840511017-­‐0  |  ORD  X1419  PRI  $10  ST  $60.0  T  $60  
  • 8. Java  Concurrency  Library  
  • 9. Order  Processing  –  Java  Fire  &  Forget   RESTFUL WEB SERVICE BATCH SERVICE ORDER RUNNABLE Original Thread New Thread 20:55:01:811  |  pool-­‐2-­‐thread-­‐5  |  ORD  X1218  PRI  $10  ST  $100.0  T  $100   20:55:01:812  |  pool-­‐2-­‐thread-­‐5  |  ORD  X1419  PRI  $10  ST  $60.0  T  $60   20:55:01:818  |  pool-­‐2-­‐thread-­‐1  |  ORD  X1406  PRI  $6  ST  $48.0  T  $48  
  • 10. Order  Processing  –  Java  Fork-­‐Join   RESTFUL WEB SERVICE BATCH SERVICE Original Thread New Thread ORDER CALLABE 20:57:59:691  |  pool-­‐4-­‐thread-­‐36  |  ORD  X1363  PRI  $6  ST  $60.0  DISC  .15%  T  $51   20:57:59:694  |  pool-­‐4-­‐thread-­‐12  |  ORD  X1218  PRI  $10  ST  $100.0  T  $100   20:57:59:695  |  492438277@qtp-­‐1840511017-­‐0  |  Batch  Total  $11080.0  
  • 11. Order  Processing  –  Java  Producer-­‐Consumer   RESTFUL WEB SERVICE BATCH SERVICE Original Thread New Thread ORDER CALLABE 15:18:17:883  |  qtp1624616274-­‐16  |  order  X1420  submitted   {processing}   15:18:17:883  |  qtp1624616274-­‐16  |  Consumed  Task  #1   15:18:17:884  |  qtp1624616274-­‐16  |  Consumed  Task  #2   {processing}   15:18:17:907  |  pool-­‐3-­‐thread-­‐17  |  ORD  X1420  PRI  $6  ST  $24.0  DISC  .15%  T  $20   {processing}   15:18:22:753  |  qtp1624616274-­‐16  |  Batch  Total  $11080.0  
  • 12. Actor  System   Client Untyped Actor Client Untyped Actor Untyped Actor Actors   Dispatcher Supervisor Router Transactor
  • 13. Parent Actor Client Typed Actor Typed Actor Actors   Actor  System   Typed Actor Client
  • 14. Akka  Actors      Actors  Framework  (Scala  &  Java  API)      Standalone  (Microkernel)  or  Embedded      High  Availability  (Remote  Actors)      Fault  Tolerant  (Supervision  &  Monitoring)      SoVware  TransacBonal  Memory  (STM)  
  • 15. Order  Processing  –  Akka  Actors  Pipeline   RESTFUL WEB SERVICE BATCH SERVICE PRICE ACTOR Original Thread New Thread DISCOUNT ACTOR New Thread …|  akka:event-­‐driven:dispatcher:global-­‐1  |  Order  ID:  X1418   Amount  SubTotal:  $100.0  Discounted  SubTotal:  $   …|  akka:event-­‐driven:dispatcher:global-­‐1  |  Order  ID:  X1419   Amount  SubTotal:  $60.0  Discounted  SubTotal:  $   …|  akka:event-­‐driven:dispatcher:global-­‐11  |  Order  ID:  X1418   Amount  SubTotal:  $100.0  Discounted  SubTotal:  $100.0   …|  akka:event-­‐driven:dispatcher:global-­‐1  |  Order  ID:  X1420   Amount  SubTotal:  $24.0  Discounted  SubTotal:  $   …|  akka:event-­‐driven:dispatcher:global-­‐11  |  Order  ID:  X1419   Amount  SubTotal:  $60.0  Discounted  SubTotal:  $60.0  
  • 16. Order  Processing  –  Akka  Actors  Fork-­‐Join   RESTFUL WEB SERVICE BATCH SERVICE PRICE ACTOR Original Thread New Thread DISCOUNT ACTOR New Thread …|  akka:event-­‐driven:dispatcher:global-­‐1  |  Order  ID:  X1420  Discount:  15%   …|  akka:event-­‐driven:dispatcher:global-­‐11  |  Order  ID:  X1420  Amount   SubTotal:  $24.0   …|  492438277@qtp-­‐1840511017-­‐0  |  Batch  Total  $11080.0  
  • 17. Order  Processing  –  Akka  Actors  Map-­‐Reduce   RESTFUL WEB SERVICE BATCH SERVICE MAP ACTOR Original Thread New Thread REDUCE ACTOR New Thread…|  akka:event-­‐driven:dispatcher:global-­‐1  |  Mapped  Item  Types     …|  akka:event-­‐driven:dispatcher:global-­‐2  |  Reduce  Item  Types   …|  akka:event-­‐driven:dispatcher:global-­‐2  |  {Card  Deck=36,  Dice=36,   Marbles=16,  Quarters=28,  Rabbit=16,  Rainbow  Scarf=16,  Rings=24,  Top   Hat=28}  
  • 18. Asynchronous  Web  Service  Magic    
  • 19. Order  Processing  –  Web  Service  Future   BATCH CACHE RESTFUL WEB SERVICE BATCH SERVICE BATCH RUNNABLE Original Thread New Thread RESTFUL WEB SERVICE BATCH SERVICE Polling Thread
  • 20. Order  Processing  –  Asynchronous  Web  Service   SPRING FRAMEWORK 4.0 Servlet 3.0 RESTFUL WEB SERVICE BATCH SERVICE BATCH DEFERRED Original Thread New Thread
  • 21. QuesBons  &  Feedback  QuesBons  &  Feedback   My  Contact   informa3on:   Jeremy  Deane     Director  of  SoVware  Architecture   NaviNet   jeremy.deane@gmail.com   h6p://jeremydeane.net/   h6ps://github.com/jtdeane/demo-­‐spring-­‐orders