SlideShare uma empresa Scribd logo
1 de 29
Asynchronous Service Servers Based on AMQP for Ruby
Versapay Point of sales eCommerce payment processing Partner with JPChase No.1 Growth Company in Canada (Profit50)
Prelude: ConcurrencyOr, ouch, it hurts…
Nietzsche on Concurrency …if you gaze for long into an abyss, the abyss gazes also into you.
Spectrum of Grainedness Parallelism The Multicore Future™ Code structuring (e.g. block/wait) Concurrency Simultaneous tasks Distributed Services Internet/REST REST (all its constraints: stateless, layered, cacheable, uniform interace, …)
Lazy Scalability Worry Later? Very hard to fix a wrong architecture Get it right, right now! Architecture (constraints) makes scaling possible Actual scaling when you need it Path from concurrency to SOA Actor Model (e.g. Erlang) Key-value store (no join)
Actor Model     The Actor model is characterized by inherent concurrency of computation within and among actors, dynamic creation of actors, inclusion of actor addresses in messages, and interaction only through direct asynchronous message passing with no restriction on message arrival order. N.B. From wikipedia
Actor Model Identified by address Mobile (doesn’t matter which machine) Transient (doesn’t matter which process) Decouples the “who” of computation Message passing Ask, don’t tell Decouples the “what” of computation Asynchrony Event-based Decouples the “when” of computation
Erlang-Style Concurrency Creating and destroying processes is very fast. Sending messages between processes is very fast. Processess behave the same way on all operating systems. We can have very large numbers of processes. Processes share no memory and are completely independent. The only way for processes to interact is through message passing. Joe Armstrong
More on Erlang Message passing is asynchronous. Processes can monitor each other. It is possible to selectively receive messages. Remote processes appear largely the same as local processes. Ulf Wiger
ASS kicking with RabbitMQ Stealing Ideas from Erlang
AMQP Just a protocol specification Open, interoperable Binary Extensible Dynamic creation of entities For enterprise message middleware RabbitMQ is a free implementation Qpid is an Apache project
AMQP(<1.0) Details AMQP Entities Exchange (publish messages here) Queue (route messages here) Binding (establishes routing between exchange and queue) AMQP Error Model The sound of success is silence An error just closes connection QOS, prefetch window
ASS Inspired by Erlanggen_server Hide concurrency behind generic server Parameterize generic server with modules Familiar sequential programming Pass around Ruby objects by marshalling Switch to JSON? Full access to AMQP if you need it
A Simple ASS Actor require 'rubygems' require 'ass' ASS.start do ASS.actor("demo") {     def echo(o)       o     end   } end
Demo Server/Client Load distribution Store and forward Zero downtime Future & RPC Wait in batches Failure recovery with :ack => true
RPC is an Illusion ASS is fundamentally asynchronous Async/event-based programming is unfamiliar RPC client does blocking wait to simulate sequential programming “Future” gives some asynchrony back Timeout as generic exception Usually just give up and die
RPC is EVIL when… Hides too much Random failures Doesn’t hide enough Exposing the implementation Leaky abstraction See: http://steve.vinoski.net/blog/2008/07/01/convenience-over-correctness/
Experiences So Far
Programming Murphy’s Computer Anything can fail at any time… Think in critical sections Retry is the bedrock of reliability :ack => true FSM is a good mental aid Mark progress with a database (ACID state) It’s ok to die… process is transient, data is forever
API Message verification Pattern Matching http://github.com/hayeah/matchmaker Fail Fast and Hard at the API Avoid error spreading through the services Share the API spec among services Weak API
Processes, Not Threads Avoid threads, avoid horrors The stack is opaque, you don’t know if anything you use might cause blocking Let OS and DB do the hard work Process isolation Anything wrong? Easy, kill it! IPC cost, but you don’t care (most of the time)
Testing Concurrent App No established practice… Test the real thing, not mocks Pretty easy with ASS, hard with web-services Test in a single process, deploy to multiple processes, then hosts, then networks Invariants are super important Some kind of property testing Must test with enough load
Future Work Like, TODO, right now!
System Health Monitoring Event based Metrics Logging Self-management Supervisor hierarchy Zookeeper?
Better Testing Stress Test Testing with generated message sequences Some kind of proxy to force message order Some kind of code injection technique System invariant checker Test failures (connection dying, db dying, etc) Continuous integration
What Datastore? We are using ActiveRecord at the moment Because it’s there… Some kind of schemaless key-value store Like Friendsfeed
Conclusion
Three Legged Stool Scalability gives, Distributability gives, Reliability gives scalability http://github.com/hayeah/ASS ZERO documentation Quirks It’s not Rails

Mais conteúdo relacionado

Semelhante a Asynchronous Service Server

RestMS Introduction
RestMS IntroductionRestMS Introduction
RestMS Introductionpieterh
 
Building Asynchronous Applications
Building Asynchronous ApplicationsBuilding Asynchronous Applications
Building Asynchronous ApplicationsJohan Edstrom
 
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
Java Core | Modern Java Concurrency | Martijn Verburg & Ben EvansJava Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
Java Core | Modern Java Concurrency | Martijn Verburg & Ben EvansJAX London
 
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016DevOpsDays Tel Aviv
 
Scalable Apache for Beginners
Scalable Apache for BeginnersScalable Apache for Beginners
Scalable Apache for Beginnerswebhostingguy
 
High powered messaging with RabbitMQ
High powered messaging with RabbitMQHigh powered messaging with RabbitMQ
High powered messaging with RabbitMQJames Carr
 
Achieving mass scale with Quasar Fibers
Achieving mass scale with Quasar FibersAchieving mass scale with Quasar Fibers
Achieving mass scale with Quasar FibersIdan Sheinberg
 
Natural Laws of Software Performance
Natural Laws of Software PerformanceNatural Laws of Software Performance
Natural Laws of Software PerformanceGibraltar Software
 
Succeding with the Apache SOA stack
Succeding with the Apache SOA stackSucceding with the Apache SOA stack
Succeding with the Apache SOA stackJohan Edstrom
 
Cartographer, or Building A Next Generation Management Framework
Cartographer, or Building A Next Generation Management FrameworkCartographer, or Building A Next Generation Management Framework
Cartographer, or Building A Next Generation Management Frameworkansmtug
 
Air traffic controller - Streams Processing meetup
Air traffic controller  - Streams Processing meetupAir traffic controller  - Streams Processing meetup
Air traffic controller - Streams Processing meetupEd Yakabosky
 
UnConference for Georgia Southern Computer Science March 31, 2015
UnConference for Georgia Southern Computer Science March 31, 2015UnConference for Georgia Southern Computer Science March 31, 2015
UnConference for Georgia Southern Computer Science March 31, 2015Christopher Curtin
 
The Art of Message Queues - TEKX
The Art of Message Queues - TEKXThe Art of Message Queues - TEKX
The Art of Message Queues - TEKXMike Willbanks
 
APIs & Underlying Protocols #APICraftSF
APIs & Underlying Protocols #APICraftSFAPIs & Underlying Protocols #APICraftSF
APIs & Underlying Protocols #APICraftSFAndrei Savu
 
Shopzilla On Concurrency
Shopzilla On ConcurrencyShopzilla On Concurrency
Shopzilla On ConcurrencyWill Gage
 
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attacDefcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attacPriyanka Aash
 
The Joy Of Functional Programming
The Joy Of Functional ProgrammingThe Joy Of Functional Programming
The Joy Of Functional Programmingjasondew
 
Everyone loves PHP
Everyone loves PHPEveryone loves PHP
Everyone loves PHPAbhijit Das
 
Domain oriented development
Domain oriented developmentDomain oriented development
Domain oriented developmentrajmundr
 

Semelhante a Asynchronous Service Server (20)

RestMS Introduction
RestMS IntroductionRestMS Introduction
RestMS Introduction
 
Building Asynchronous Applications
Building Asynchronous ApplicationsBuilding Asynchronous Applications
Building Asynchronous Applications
 
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
Java Core | Modern Java Concurrency | Martijn Verburg & Ben EvansJava Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
 
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
 
Scalable Apache for Beginners
Scalable Apache for BeginnersScalable Apache for Beginners
Scalable Apache for Beginners
 
High powered messaging with RabbitMQ
High powered messaging with RabbitMQHigh powered messaging with RabbitMQ
High powered messaging with RabbitMQ
 
Achieving mass scale with Quasar Fibers
Achieving mass scale with Quasar FibersAchieving mass scale with Quasar Fibers
Achieving mass scale with Quasar Fibers
 
Natural Laws of Software Performance
Natural Laws of Software PerformanceNatural Laws of Software Performance
Natural Laws of Software Performance
 
Succeding with the Apache SOA stack
Succeding with the Apache SOA stackSucceding with the Apache SOA stack
Succeding with the Apache SOA stack
 
Cartographer, or Building A Next Generation Management Framework
Cartographer, or Building A Next Generation Management FrameworkCartographer, or Building A Next Generation Management Framework
Cartographer, or Building A Next Generation Management Framework
 
Air traffic controller - Streams Processing meetup
Air traffic controller  - Streams Processing meetupAir traffic controller  - Streams Processing meetup
Air traffic controller - Streams Processing meetup
 
UnConference for Georgia Southern Computer Science March 31, 2015
UnConference for Georgia Southern Computer Science March 31, 2015UnConference for Georgia Southern Computer Science March 31, 2015
UnConference for Georgia Southern Computer Science March 31, 2015
 
The Art of Message Queues - TEKX
The Art of Message Queues - TEKXThe Art of Message Queues - TEKX
The Art of Message Queues - TEKX
 
APIs & Underlying Protocols #APICraftSF
APIs & Underlying Protocols #APICraftSFAPIs & Underlying Protocols #APICraftSF
APIs & Underlying Protocols #APICraftSF
 
Shopzilla On Concurrency
Shopzilla On ConcurrencyShopzilla On Concurrency
Shopzilla On Concurrency
 
Azure and cloud design patterns
Azure and cloud design patternsAzure and cloud design patterns
Azure and cloud design patterns
 
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attacDefcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
 
The Joy Of Functional Programming
The Joy Of Functional ProgrammingThe Joy Of Functional Programming
The Joy Of Functional Programming
 
Everyone loves PHP
Everyone loves PHPEveryone loves PHP
Everyone loves PHP
 
Domain oriented development
Domain oriented developmentDomain oriented development
Domain oriented development
 

Último

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 

Último (20)

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 

Asynchronous Service Server

  • 1. Asynchronous Service Servers Based on AMQP for Ruby
  • 2. Versapay Point of sales eCommerce payment processing Partner with JPChase No.1 Growth Company in Canada (Profit50)
  • 4. Nietzsche on Concurrency …if you gaze for long into an abyss, the abyss gazes also into you.
  • 5. Spectrum of Grainedness Parallelism The Multicore Future™ Code structuring (e.g. block/wait) Concurrency Simultaneous tasks Distributed Services Internet/REST REST (all its constraints: stateless, layered, cacheable, uniform interace, …)
  • 6. Lazy Scalability Worry Later? Very hard to fix a wrong architecture Get it right, right now! Architecture (constraints) makes scaling possible Actual scaling when you need it Path from concurrency to SOA Actor Model (e.g. Erlang) Key-value store (no join)
  • 7. Actor Model The Actor model is characterized by inherent concurrency of computation within and among actors, dynamic creation of actors, inclusion of actor addresses in messages, and interaction only through direct asynchronous message passing with no restriction on message arrival order. N.B. From wikipedia
  • 8. Actor Model Identified by address Mobile (doesn’t matter which machine) Transient (doesn’t matter which process) Decouples the “who” of computation Message passing Ask, don’t tell Decouples the “what” of computation Asynchrony Event-based Decouples the “when” of computation
  • 9. Erlang-Style Concurrency Creating and destroying processes is very fast. Sending messages between processes is very fast. Processess behave the same way on all operating systems. We can have very large numbers of processes. Processes share no memory and are completely independent. The only way for processes to interact is through message passing. Joe Armstrong
  • 10. More on Erlang Message passing is asynchronous. Processes can monitor each other. It is possible to selectively receive messages. Remote processes appear largely the same as local processes. Ulf Wiger
  • 11. ASS kicking with RabbitMQ Stealing Ideas from Erlang
  • 12. AMQP Just a protocol specification Open, interoperable Binary Extensible Dynamic creation of entities For enterprise message middleware RabbitMQ is a free implementation Qpid is an Apache project
  • 13. AMQP(<1.0) Details AMQP Entities Exchange (publish messages here) Queue (route messages here) Binding (establishes routing between exchange and queue) AMQP Error Model The sound of success is silence An error just closes connection QOS, prefetch window
  • 14. ASS Inspired by Erlanggen_server Hide concurrency behind generic server Parameterize generic server with modules Familiar sequential programming Pass around Ruby objects by marshalling Switch to JSON? Full access to AMQP if you need it
  • 15. A Simple ASS Actor require 'rubygems' require 'ass' ASS.start do ASS.actor("demo") { def echo(o) o end } end
  • 16. Demo Server/Client Load distribution Store and forward Zero downtime Future & RPC Wait in batches Failure recovery with :ack => true
  • 17. RPC is an Illusion ASS is fundamentally asynchronous Async/event-based programming is unfamiliar RPC client does blocking wait to simulate sequential programming “Future” gives some asynchrony back Timeout as generic exception Usually just give up and die
  • 18. RPC is EVIL when… Hides too much Random failures Doesn’t hide enough Exposing the implementation Leaky abstraction See: http://steve.vinoski.net/blog/2008/07/01/convenience-over-correctness/
  • 20. Programming Murphy’s Computer Anything can fail at any time… Think in critical sections Retry is the bedrock of reliability :ack => true FSM is a good mental aid Mark progress with a database (ACID state) It’s ok to die… process is transient, data is forever
  • 21. API Message verification Pattern Matching http://github.com/hayeah/matchmaker Fail Fast and Hard at the API Avoid error spreading through the services Share the API spec among services Weak API
  • 22. Processes, Not Threads Avoid threads, avoid horrors The stack is opaque, you don’t know if anything you use might cause blocking Let OS and DB do the hard work Process isolation Anything wrong? Easy, kill it! IPC cost, but you don’t care (most of the time)
  • 23. Testing Concurrent App No established practice… Test the real thing, not mocks Pretty easy with ASS, hard with web-services Test in a single process, deploy to multiple processes, then hosts, then networks Invariants are super important Some kind of property testing Must test with enough load
  • 24. Future Work Like, TODO, right now!
  • 25. System Health Monitoring Event based Metrics Logging Self-management Supervisor hierarchy Zookeeper?
  • 26. Better Testing Stress Test Testing with generated message sequences Some kind of proxy to force message order Some kind of code injection technique System invariant checker Test failures (connection dying, db dying, etc) Continuous integration
  • 27. What Datastore? We are using ActiveRecord at the moment Because it’s there… Some kind of schemaless key-value store Like Friendsfeed
  • 29. Three Legged Stool Scalability gives, Distributability gives, Reliability gives scalability http://github.com/hayeah/ASS ZERO documentation Quirks It’s not Rails