we have a dream distributed reac5ve programming with
play

We Have a DREAM: Distributed Reac5ve Programming with - PowerPoint PPT Presentation

We Have a DREAM: Distributed Reac5ve Programming with Consistency Guarantees Alessandro Margara, Guido Salvaneschi Presented by Wilfried Daniels Introduc5on


  1. We ¡Have ¡a ¡DREAM: ¡Distributed ¡ Reac5ve ¡Programming ¡with ¡ Consistency ¡Guarantees ¡ Alessandro ¡Margara, ¡Guido ¡Salvaneschi ¡ ¡ Presented ¡by ¡Wilfried ¡Daniels ¡

  2. Introduc5on ¡ • Designing, ¡implemen5ng ¡and ¡maintaining ¡ reac5ve ¡systems ¡is ¡difficult ¡ – Asynchronous ¡callbacks ¡ – Hard ¡to ¡trace/understand ¡control ¡flow ¡ ¡ è ¡Solu5on: ¡Reac5ve ¡Programming ¡

  3. Introduc5on ¡ • Key ¡concepts: ¡ – 5me-­‑varying ¡values ¡ – tracking ¡of ¡dependencies ¡ – automa5c ¡propaga5on ¡of ¡changes ¡ 1 var a: int = 10 1 var a: int = 10 2 var b: int = a + 2 2 var b: int := a + 2 3 println(b) // 12 3 println(b) // 12 4 a = 11 4 a = 11 5 println(b) // 12 5 println(b) // 13 Impera5ve ¡ Reac5ve ¡

  4. Introduc5on ¡ • Advantages ¡vs. ¡classic ¡event-­‑based ¡arch: ¡ – No ¡explicit ¡update ¡logic ¡ – Declara5ve ¡specifica5on ¡of ¡dependencies ¡ – Run5me ¡manages ¡correct ¡propaga5on ¡(e.g. ¡glitch ¡ freeness/consistency) ¡ • This ¡work ¡focuses ¡on ¡distributed ¡reac5ve ¡ programming ¡(DRP) ¡

  5. Introduc5on ¡ • Previous ¡DRP ¡solu5ons ¡do ¡not ¡guarantee ¡ distributed ¡consistency ¡(only ¡local) ¡ • This ¡paper ¡presents ¡DREAM ¡, ¡a ¡ Distributed ¡ REAc/ve ¡Middleware ¡with ¡three ¡different ¡ levels ¡of ¡consistency ¡guarantees ¡

  6. Background ¡and ¡Mo5va5on ¡ • Mo5va5on ¡for ¡different ¡levels ¡of ¡consistency ¡ • Running ¡example: ¡financial ¡applica5on ¡system ¡ 1 var marketIndex = InputModule.getMarketIndex() Observable ¡ 2 var stockOpts = InputModule.getStockOpts() 5me-­‑varying ¡variables ¡ 3 var news = InputModule.getNews() 4 5 // Forecasts according to di ff erent models Dependent ¡ 6 var f1 := Model1.compute(marketIndex,stockOpts) Reac5ve ¡expressions ¡ 7 var f2 := Model2.compute(marketIndex,stockOpts) 8 var f3 := Model3.compute(marketIndex,news) 9 V1 Reac5ve ¡expressions ¡ 10 var gui := Display.show(f1,f2,f3) resul5ng ¡in ¡3 ¡ 11 12 var financialAlert := ((f1+f2+f3)/3) < MAX V2 alterna5ve ¡outputs, ¡ 13 if (financialAlert) decrease(stockOpts) each ¡requiring ¡ 14 15 var financialAlert _ n := computeAlert _ n(f1,f2,f3) different ¡consistency ¡ V3 16 if (financialAlert _ n) adjust _ n(stockOpts) guarantees ¡

  7. Background ¡and ¡Mo5va5on ¡ • Variant ¡1: ¡Smartphone ¡app ¡ – Just ¡displays ¡output ¡of ¡3 ¡models ¡ – No ¡consistency ¡required ¡ 9 V1 10 var gui := Display.show(f1,f2,f3) • Variant ¡2: ¡Models ¡aggregator ¡ 11 – Aggregates ¡output ¡of ¡3 ¡models ¡ – Undertakes ¡ac5on ¡when ¡below ¡threshold ¡ 11 12 var financialAlert := ((f1+f2+f3)/3) < MAX V2 13 if (financialAlert) decrease(stockOpts) 14

  8. Background ¡and ¡Mo5va5on ¡ • Variant ¡2: ¡Models ¡aggregator ¡ – Requires ¡glitch ¡freedom ¡ – Assume ¡ini5ally ¡ f1 :110, ¡ f2 :95, ¡ f3 :99 ¡with ¡ MAX :100 ¡ – New ¡ marketIndex : ¡ all ¡models ¡recalculate. ¡ – Model ¡ f1 ¡ finishes ¡first ¡with ¡ f1 : ¡90 ¡ à ¡STOCKS ¡DECREASED ¡(GLITCH!) ¡ – Other ¡models ¡finish: ¡ f2 :111, ¡ f3 :103 ¡ 11 12 var financialAlert := ((f1+f2+f3)/3) < MAX V2 13 if (financialAlert) decrease(stockOpts) 14

  9. Background ¡and ¡Mo5va5on ¡ • Variant ¡3: ¡Mul5ple ¡aggregators ¡ – f1 , ¡ f2 , ¡ f3 ¡are ¡dispatched ¡to ¡ n ¡aggregators, ¡that ¡ work ¡autonomously ¡ – In ¡case ¡of ¡devia5ng ¡behaviour, ¡any ¡aggregator ¡can ¡ adjust ¡stockOpts ¡ – No ¡glitch ¡freedom ¡required, ¡but ¡every ¡single ¡ aggregator ¡needs ¡to ¡see ¡ f1 , ¡ f2 ¡and ¡ f3 ¡change ¡in ¡ the ¡same ¡order ¡ 14 15 var financialAlert _ n := computeAlert _ n(f1,f2,f3) V3 16 if (financialAlert _ n) adjust _ n(stockOpts)

  10. A ¡model ¡for ¡DRP ¡ • Formal ¡defini5on ¡of ¡DRP ¡system ¡architecture/ consistency ¡guarantees ¡ • Components : ¡networked ¡nodes ¡in ¡system ¡ ts c 1 . . . c n • Variables : ¡state ¡of ¡component ¡ ¡ ¡ ¡ ¡ ¡is ¡ t c i as represented ¡by ¡ les V i = { v i 1 : τ i 1 . . . v im : τ im } , me of variable j in component c c c c c vi1 c Communication c vi2 Channel c c vin c c c

  11. A ¡model ¡for ¡DRP ¡ • Besides ¡tradi5onal ¡ impera)ve ¡variables, ¡ reac)ve ¡and ¡ observable ¡variables ¡are ¡defined ¡ • Reac/ve : ¡variable ¡that ¡is ¡automa5cally ¡ updated ¡based ¡on ¡reac5ve ¡expression ¡ • Observable : ¡con5nuously ¡changing ¡var ¡that ¡is ¡ used ¡to ¡build ¡expressions. ¡Local ¡or ¡Global. ¡ • e.g. ¡stock ¡market: ¡ f3 ¡:= ¡ Model3.compute(marketIndex,news) ¡ ¡ Reac5ve ¡(+ ¡observable) ¡variable ¡ Observable ¡variables ¡

  12. A ¡model ¡for ¡DRP ¡ • Dependency ¡Graph: ¡ – Directed ¡graph ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡where ¡ ¡ ¡ ¡ ¡is ¡the ¡set ¡of ¡ re V ph D = { V, E } , of al all ¡observable/reac5ve ¡variables ¡and ¡ ¡ ¡ ¡is ¡the ¡set ¡of ¡ nd E all ¡edges ¡that ¡connect ¡directly ¡depending ¡ variables ¡ – E.g. ¡stock ¡market ¡for ¡Variant ¡1 ¡+ ¡2: ¡ f1 marketIndex f2 gui stockOpts financialAlert f3 news

  13. A ¡model ¡for ¡DRP ¡ • Events: ¡ – Write ¡event: ¡ t w x ( v ) • Occurs ¡when ¡value ¡x ¡is ¡wrifen ¡to ¡variable ¡v ¡ – Read ¡event: ¡ t r x ( v ) from a va • Occurs ¡when ¡value ¡x ¡is ¡read ¡from ¡variable ¡v ¡ – Update ¡ event: ¡ t u ( S, w x ( v )), S = { w y 1 ( v 1 ) . . . w yn ( v n ) } • Depending ¡variable ¡v ¡is ¡reac5vely ¡update ¡with ¡value ¡x ¡ due ¡to ¡the ¡write ¡events ¡contained ¡in ¡the ¡set ¡S ¡

  14. A ¡model ¡for ¡DRP ¡ • Consistency ¡Guarantees ¡ – Exactly ¡once ¡delivery: ¡ensures ¡that, ¡in ¡absence ¡of ¡ failure, ¡the ¡communica5on ¡channel ¡does ¡not ¡lose ¡ or ¡duplicate ¡an ¡update. ¡More ¡formally: ¡ only onc ables depending on v . More ¡ ¡ ¡ ¡ ¡ If ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡occurs, ¡then ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡occurs ¡ if w x ( v ) u ( S i , w y ( v i )), w x ( v ) ∈ S i exactly ¡once. ¡ e and onl such that v depends on v . ¡

  15. A ¡model ¡for ¡DRP ¡ • Consistency ¡Guarantees ¡ – FIFO ¡ordering: ¡changes ¡to ¡a ¡a ¡variable ¡ ¡ ¡ ¡in ¡a ¡ ble v component ¡ ¡ ¡are ¡propagated ¡to ¡depending ¡ in c . reac5ve ¡expressions ¡in ¡the ¡same ¡order ¡they ¡occur ¡ in ¡ ¡ . ¡More ¡formally: ¡ in c . ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡such ¡that ¡ ¡ ¡ ¡ ¡depends ¡on ¡ ¡ ¡ ¡ ¡, ¡if ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡occurs ¡ t v j n v i , i ∀ v i , v j , if w x 1 ( v i ) before ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡then ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡occurs ¡before ¡ n u ( ) ∈ S re w x 2 ( v i ) n u ( S 1 ), w x 1 ( v i ) ∈ S 1 x 2 i w x 2 ( v i ) ∈ S 2 . ¡ re u ( S 2 ), ( v ) ∈ S

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend