Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Алексей Сахаров "Акторная модель программирования в Microsoft Orleans"

DotNetRu
August 08, 2019

Алексей Сахаров "Акторная модель программирования в Microsoft Orleans"

Акторная модель — это подход для организации параллельных вычислений, позволяющий улучшить инкапсуляцию и сегрегировать ответственность. Разработчики применяют акторные модели, чтобы сделать приложение пригодным для горизонтального масштабирования при нагрузках. Расскажу как они работают на примере Microsoft Orleans, их плюсы и минусы.

DotNetRu

August 08, 2019
Tweet

More Decks by DotNetRu

Other Decks in Programming

Transcript

  1. The Actor model • Method call • Do something •

    Shared memory • OOP • – Obje ct • Receive message • Do somethin g • No shared memory •Actor mode l – Actor
  2. The Actor model • Create more actors • Send message

    to other actors • Decide what to do with the next message (change state) •Receive messag e
  3. The Actor model • No shared state • Internal state

    (shared nothing) • Fire-and- forget • Asynchrono us • Lightwei ght process • 1 message – 1 actor • Fault- tolerance • Distributio n
  4. The Actor model • .NET • Microsoft Orleans • Akka.NET

    • PostSharp • JAVA • Akka • Jetlang • Actor • Actr • Python • Pykka • Pulsar • JavaScript • NAct • Vert.x • Comedy
  5. Microsoft Orleans - Overview • Framework • Build distributed high-scale

    computing applications • No need to learn and apply complex concurrency or other scaling patterns
  6. Microsoft Orleans - Benefits • Familiar OOP paradigm • Single-

    threaded execution of grains • Transparent activation • Location transparency • Integration with persistent store • Automatic propagation of errors
  7. Microsoft Orleans - Grains • long • GUID • string

    • GUID + string • long + string
  8. Microsoft Orleans - Grains • Request Context Observabl e (actor)

    Observer (actor) Observer (actor) Observer (client) Reentranc y
  9. Microsoft Orleans - Grains • Memory Grain Storage • Azure

    Table Storage • Azure Blob Storage • Dynamo DB • ADO.NET • SQL Server • MySQL/MariaDB • PostgreSQL • Oracle
  10. Microsoft Orleans - Grains • Tasks • Intercepto rs •

    Incoming Call Filters • Silo-wide • Per-grain • Outgoing Call Filters • Grain Services • Stateless Worker Grains • Transactio ns
  11. Microsoft Orleans - Silo, Cluster & Clients Handler counters of

    activity • receiving a method call • receiving a reminder • receiving an event • via streaming Doens't handled counter of activity • performing a call (to another grain or to an Orleans client) • timer events • arbitrary IO operations or external calls not involving Orleans framework
  12. Microsoft Orleans - Deployment • Azure Web Apps + Azure

    Cloud Services • Docker • Service Fabric • Multi- Cluster Supp ort
  13. Microsoft Orleans - Hints • Avoid chatty interfaces between grains

    • Avoid bottleneck grains • Use TPL & await • Use smaller grains (or based on app domain model) • Use timer to re-read state • Use unit tests