Successfully reported this slideshow.

Seda与Java并行编程点滴

1,280 views

Published on

杭州程序员圆桌会议(2010.03.20)演讲稿v1

Published in: Technology

Seda与Java并行编程点滴

  1. 1. SEDA Java Benjamin Tan Team Leader@DBAppSecurity Twitter: tanbamboo
  2. 2. Agenda • SEDA • Java • Actor
  3. 3. SEDA • SEDA: A new architecture for Internet services • A general-purpose framework for high concurrency and load conditioning • Decomposes applications into stages separated by queues • Adopt a structured approach to event-driven concurrency • To appear in the Eighteeth Symposium on Operating Systems Principles (SOSP-18), Chateau Lake Louise, Canada, October 21-24, 2001. • http://www.cs.berkeley.edu/~mdw/
  4. 4. SEDA features • Enable load conditioning • Event queues allow inspection of request streams • Can perform prioritization or filtering during heavy load • Dynamic control for self-tuning resource management • System observes application performance and tunes runtime parameters • Apply control for graceful degradation ‣ Perform load shedding or degrade service under overload • Simplify task of building highly-concurrent services • Decouple load management from service complexity • Use of stages supports modularity, code reuse, debugging • Dynamic control shields apps from complexity of resource management
  5. 5. SEDA Staged Event-Driven Architecture (SEDA) file data I/O request accept handle file connection connection HTTP miss I/O request cache parse check miss packet cache packet packet read send write packet cache hit response packet Decompose service into stages separated by queues • Stage Queue • Each stage performs a subset of request processing • Stages internally event-driven, typically nonblocking • Stage • Queues introduce execution boundary for isolation and conditioning Each stage contains a thread pool to drive stage execution • However, threads are not exposed to applications • Dynamic control grows/shrinks thread pools with demand Stages may block if necessary
  6. 6. • Stage Queue SEDA • •
  7. 7. • •
  8. 8. Java • • CPU
  9. 9. Active List • ThreadLocal • JUC concurrent
  10. 10. Counter • AtomicInteger 1500EPS 1500 • •
  11. 11. Java • : • • •
  12. 12. CPU • CPU MEM Stage CPU ( ) • IO Stage CPU 3~5 HTTP
  13. 13. Actor • SEDA • • Stage Queue • Stage
  14. 14. Actor • Actor Context • Actor Mailbox • Topology Actor
  15. 15. Actor • “self-heals, systems that never stop” ? • CPU ?

×