Flux A Language for Programming  High-Performance Servers Brendan Burns ,  Kevin Grimaldi, Alex Kostadinov, Emery Berger, ...
Motivation: Image Server <ul><li>Client </li></ul><ul><ul><li>Requests image @ desired quality, size </li></ul></ul><ul><l...
Problem: Concurrency <ul><li>Sequential fine until: </li></ul><ul><ul><li>More  clients </li></ul></ul><ul><ul><li>Bigger ...
The Flux Programming Language <ul><li>Flux  =  Components  +  Flow  +  Atomicity </li></ul><ul><ul><li>Components = off-th...
Outline <ul><li>Intro to Flux: building a server </li></ul><ul><ul><li>Components </li></ul></ul><ul><ul><li>Flows </li></...
Flux Server: Main <ul><li>Source : one flow per connection </li></ul><ul><ul><li>Conceptually: separate thread </li></ul><...
Flux Image Server <ul><li>Basic image server requires: </li></ul><ul><ul><li>HTTP parsing ( http ) </li></ul></ul><ul><ul>...
Adding Caching <ul><li>Cache frequently requested images </li></ul><ul><ul><li>Increase performance </li></ul></ul><ul><li...
Supporting Concurrency <ul><li>Many clients = concurrent flows </li></ul><ul><ul><li>Must keep cache consistent </li></ul>...
Preventing Deadlock <ul><li>Naïve execution can deadlock </li></ul><ul><li>Establish  canonical lock order </li></ul><ul><...
Preventing Deadlock, II <ul><li>Harder with abstract nodes </li></ul>A = B; C = D; atomic  A{z}; atomic  B{y}; atomic  C{y...
Finally: Handling Errors <ul><li>What if image requested doesn’t exist? </li></ul><ul><ul><li>Error = negative return valu...
Complete Flux Image Server <ul><li>Concise, readable expression of  server  logic </li></ul><ul><ul><li>No threads, etc.: ...
Outline <ul><li>Intro to Flux: building a server </li></ul><ul><ul><li>Components, flow </li></ul></ul><ul><ul><li>Atomici...
Results <ul><li>Four servers: </li></ul><ul><ul><li>Image server (+ libjpeg)  [23 lines of Flux] </li></ul></ul><ul><ul><l...
Web Server
Performance Prediction observed parameters
Future Work <ul><li>Different runtimes </li></ul><ul><li>Distributed architectures </li></ul><ul><ul><li>Clusters </li></u...
Conclusion <ul><li>Flux: language for server programming </li></ul><ul><ul><li>Uses sequential code </li></ul></ul><ul><ul...
Backup Slides
Relaxed Atomicity <ul><li>Reader / writer constraints </li></ul><ul><ul><li>Multiple readers  or  single writer </li></ul>...
Upcoming SlideShare
Loading in...5
×

Flux: A Language for Programming High-Performance Servers

4,108

Published on

Flux is a concise programming language for writing servers that scale and are deadlock-free. A Flux programmer uses off-the-shelf, sequential C and C++ code, and describes their composition; the Flux compiler then generates a deadlock-free, high-concurrency server. Flux also makes it easy to analyze and predict server performance, because the Flux compiler can also generate discrete event simulators that reflect actual server performance.

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,108
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
56
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Flux: A Language for Programming High-Performance Servers"

  1. 1. Flux A Language for Programming High-Performance Servers Brendan Burns , Kevin Grimaldi, Alex Kostadinov, Emery Berger, Mark Corner University of Massachusetts Amherst
  2. 2. Motivation: Image Server <ul><li>Client </li></ul><ul><ul><li>Requests image @ desired quality, size </li></ul></ul><ul><li>Server </li></ul><ul><ul><li>Images: RAW </li></ul></ul><ul><ul><li>Compresses to JPG </li></ul></ul><ul><ul><li>Caches requests </li></ul></ul><ul><ul><li>Sends to client </li></ul></ul>http://server/Easter-bunny/ 200x100/75 not found client image server
  3. 3. Problem: Concurrency <ul><li>Sequential fine until: </li></ul><ul><ul><li>More clients </li></ul></ul><ul><ul><li>Bigger server </li></ul></ul><ul><ul><ul><li>Multicores , multiprocessors </li></ul></ul></ul><ul><li>One approach: threads </li></ul><ul><ul><li>Limit reuse , risk deadlock , burden programmer </li></ul></ul><ul><ul><li>Complicate debugging </li></ul></ul><ul><ul><li>Mixes program logic & concurrency control </li></ul></ul>clients image server
  4. 4. The Flux Programming Language <ul><li>Flux = Components + Flow + Atomicity </li></ul><ul><ul><li>Components = off-the-shelf C, C++, or Java </li></ul></ul><ul><ul><li>Flow = path through components </li></ul></ul><ul><ul><ul><li>Implicitly parallel </li></ul></ul></ul><ul><ul><li>Atomicity = lightweight constraints </li></ul></ul><ul><li>Compiler generates: </li></ul><ul><ul><li>Deadlock-free server </li></ul></ul><ul><ul><ul><li>Runtime independent (threads, events, …) </li></ul></ul></ul><ul><ul><li>Discrete event simulator </li></ul></ul>High-performance & deadlock-free concurrent programming w/ sequential components
  5. 5. Outline <ul><li>Intro to Flux: building a server </li></ul><ul><ul><li>Components </li></ul></ul><ul><ul><li>Flows </li></ul></ul><ul><ul><li>Atomicity </li></ul></ul><ul><li>Performance results </li></ul><ul><ul><li>Server performance </li></ul></ul><ul><ul><li>Performance prediction </li></ul></ul><ul><li>Future work </li></ul>
  6. 6. Flux Server: Main <ul><li>Source : one flow per connection </li></ul><ul><ul><li>Conceptually: separate thread </li></ul></ul><ul><ul><li>Executes inside implicit infinite loop </li></ul></ul>Listen source Listen  Image; image server ReadRequest Write Compress Complete ReadRequest Write Compress Complete ReadRequest Write Compress Complete
  7. 7. Flux Image Server <ul><li>Basic image server requires: </li></ul><ul><ul><li>HTTP parsing ( http ) </li></ul></ul><ul><ul><li>Socket handling ( socket ) </li></ul></ul><ul><ul><li>JPEG compression ( libjpeg ) </li></ul></ul><ul><li>Single flow implements basic server: </li></ul>ReadRequest Write Compress Complete libjpeg socket http http Image = ReadRequest  Compress  Write  Complete; image server
  8. 8. Adding Caching <ul><li>Cache frequently requested images </li></ul><ul><ul><li>Increase performance </li></ul></ul><ul><li>Direct data flow with predicates </li></ul><ul><ul><li>Type test applied to output </li></ul></ul>Listen ReadRequest ReadInFromDisk Write CheckCache Compress StoreInCache Complete hit typedef hit TestInCache; Handler:[_,_,hit] = ; Handler:[_,_,_] = ReadFromDisk  Compress  StoreInCache; handler handler
  9. 9. Supporting Concurrency <ul><li>Many clients = concurrent flows </li></ul><ul><ul><li>Must keep cache consistent </li></ul></ul><ul><li>Atomicity constraints </li></ul><ul><ul><li>Same name = mutual exclusion </li></ul></ul><ul><ul><li>Multiple names, reader/writer, per-client (see paper) </li></ul></ul>atomic CheckCache {cacheLock}; atomic Complete {cacheLock}; atomic StoreInCache {cacheLock}; Listen ReadRequest ReadInFromDisk Write CheckCache Compress StoreInCache Complete hit ReadRequest ReadInFromDisk Write CheckCache Compress StoreInCache Complete hit ReadRequest ReadInFromDisk Write CheckCache Compress StoreInCache Complete hit ReadRequest ReadInFromDisk Write CheckCache Compress StoreInCache Complete hit handler handler
  10. 10. Preventing Deadlock <ul><li>Naïve execution can deadlock </li></ul><ul><li>Establish canonical lock order </li></ul><ul><ul><li>Currently alphabetic by name </li></ul></ul>atomic A: {z,y}; atomic B: {y,z}; atomic A: {y,z}; atomic B: {y,z};
  11. 11. Preventing Deadlock, II <ul><li>Harder with abstract nodes </li></ul>A = B; C = D; atomic A{z}; atomic B{y}; atomic C{y,z} A = B; C = D; atomic A{y,z}; atomic B{y}; atomic C{y,z} <ul><li>Solution: Elevate constraints </li></ul>B A C B A:{z} C B A:{z} C:{y} B A:{y,z} C
  12. 12. Finally: Handling Errors <ul><li>What if image requested doesn’t exist? </li></ul><ul><ul><li>Error = negative return value from component </li></ul></ul><ul><li>Can designate error handlers </li></ul><ul><ul><li>Go to alternate paths on error </li></ul></ul>Listen FourOhFour handle error ReadInFromDisk  FourOhFour; ReadRequest ReadInFromDisk Write CheckCache Compress StoreInCache Complete hit handler handler
  13. 13. Complete Flux Image Server <ul><li>Concise, readable expression of server logic </li></ul><ul><ul><li>No threads, etc.: simplifies programming, debugging </li></ul></ul>Listen image server source Listen  Image; Image = ReadRequest  CheckCache  Handler  Write  Complete; Handler[_,_,hit] = ; Handler[_,_,_] = ReadFromDisk  Compress  StoreInCache; atomic CheckCache: {cacheLock}; atomic StoreInCache: {cacheLock}; atomic Complete: {cacheLock}; handle error ReadInFromDisk  FourOhFour; ReadRequest ReadInFromDisk Write CheckCache Compress StoreInCache Complete hit handler handler
  14. 14. Outline <ul><li>Intro to Flux: building a server </li></ul><ul><ul><li>Components, flow </li></ul></ul><ul><ul><li>Atomicity, deadlock avoidance </li></ul></ul><ul><li>Performance results </li></ul><ul><ul><li>Server performance </li></ul></ul><ul><ul><li>Performance prediction </li></ul></ul><ul><li>Future work </li></ul>
  15. 15. Results <ul><li>Four servers: </li></ul><ul><ul><li>Image server (+ libjpeg) [23 lines of Flux] </li></ul></ul><ul><ul><li>Multi-player online game [54] </li></ul></ul><ul><ul><li>BitTorrent (2 undergrads: 1 week!) [84] </li></ul></ul><ul><ul><li>Web server (+ PHP) [36] </li></ul></ul><ul><li>Evaluation </li></ul><ul><ul><li>Benchmark: variant of SPECweb99 </li></ul></ul><ul><ul><li>Three different runtimes </li></ul></ul><ul><ul><ul><li>Thread, Thread pool, Event-Driven </li></ul></ul></ul><ul><ul><li>Compared to Capriccio [SOSP03] , SEDA [SOSP01] </li></ul></ul>
  16. 16. Web Server
  17. 17. Performance Prediction observed parameters
  18. 18. Future Work <ul><li>Different runtimes </li></ul><ul><li>Distributed architectures </li></ul><ul><ul><li>Clusters </li></ul></ul><ul><li>Embedded, power-aware systems </li></ul><ul><ul><li>Turtles! </li></ul></ul><ul><ul><li>Embedded space similar to servers </li></ul></ul><ul><ul><li>eFlux: includes power constraints </li></ul></ul><ul><ul><ul><li>Removes/adds flows dynamically in response to power </li></ul></ul></ul>
  19. 19. Conclusion <ul><li>Flux: language for server programming </li></ul><ul><ul><li>Uses sequential code </li></ul></ul><ul><ul><li>Separates logic and runtime </li></ul></ul><ul><ul><li>Deadlock-free high-performance servers + simulators </li></ul></ul><ul><li>flux.cs.umass.edu </li></ul><ul><ul><li>Hosted by Flux web server; download via Flux BitTorrent </li></ul></ul>flux : from Latin fluxus, p.p. of fluere = “to flow”
  20. 20. Backup Slides
  21. 21. Relaxed Atomicity <ul><li>Reader / writer constraints </li></ul><ul><ul><li>Multiple readers or single writer </li></ul></ul><ul><ul><ul><li>atomic ReadList: {listAccess ? }; </li></ul></ul></ul><ul><ul><ul><li>atomic AddToList: {listAccess ! }; </li></ul></ul></ul><ul><li>Per-session constraints </li></ul><ul><ul><li>One constraint per client / session </li></ul></ul>atomic AddHasChunk: {chunks (session) };
  1. ¿Le ha llamado la atención una diapositiva en particular?

    Recortar diapositivas es una manera útil de recopilar información importante para consultarla más tarde.

×