Windows Azure User Group<br />Event Driven Architecture on the Azure Services Platform27/05/2010<br />
Yours truly<br />Yves Goeleven<br />Solution Architect @ Capgemini<br />MS Community Lead @ Capgemini<br />Board member @ ...
Introduction<br />What are we going to discuss today?<br />
Agenda<br />Introduction<br />Design challenges<br />Event driven architecture<br />Event Flow Layers<br />Event Processin...
Windows Azure<br />
.Net Service Bus<br />
SQL Azure<br />Business Analytics<br />Reporting<br />Data Sync<br />Database<br />
The beauty of cloud computing<br />Infinite compute and storage capacity<br />On demand<br />Extreme flexibility<br />With...
Design challenges<br />Aren’t there any downsides to cloud computing then?<br />
Impact of scale<br />Large scale systems suffer from<br />Data latency<br />No distributed transactions<br />Global system...
Latency<br />Azure Fabric<br />Data overlay<br />Data replication over peers<br />Multiple failure & upgrade domains<br />...
No distributed transactions<br />The very nature of 2 phase commit<br />Makes each machine confirm twice in the commit pro...
Instance availability<br />Azure is a global platform<br />Can be used by anyone from anywhere, 24 / 7<br />No windows for...
Traditional composite SOA<br />Synchronous request reply integration <br />It assumes little to no latency<br />It assumes...
Event Driven Architecture<br />If synchronous composite SOA is unsuitable for the cloud, what is?<br />
What’s an event anyway<br />Notable, interesting, thing that happens in the business<br />State change, opportunity, thres...
Inversion of communication<br />Event generators<br />EventStream<br />Time<br />Eventconsumers<br />
Eventflowlayers<br />Event generator<br />Event Channel<br />Event Processing Engine<br />Downstream activity<br />Event P...
Event Processing Styles<br />What does ‘interesting event’ mean ?<br />
SimpleEvent Processing<br />Event generator<br />Event Channel<br />Event Processing Engine<br />Downstream activity<br />...
StreamEvent Processing<br />Event generator<br />Event Channel<br />Event Processing Engine<br />Downstream activity<br />...
Complex Event Processing<br />Event generator<br />Event Channel<br />Event Processing Engine<br />Downstream activity<br ...
Extreme Loose Coupling<br />Event driven architecture delivers…<br />
Extreme loose coupling<br />Decoupling in multiple dimensions<br />Implementation<br />Event generator and consumer’s impl...
Extreme loose coupling<br />Decoupling (Continued)<br />Time<br />Events encapsulate all information<br />They can be stor...
Brewers CAP Theorem<br />A distributed system can satisfy any two of these guarantees at the same time, but not all three<...
Eventual consistency<br />EDA sacrifices consistency<br />But will eventually become consistent<br />Compensating events <...
Eventual consistency<br />Local transactions, or similar mechanics, are still supported<br />So even if a role goes down w...
Service Autonomy<br />How to achieve it?<br />Make every event consumer (aggregate root)<br />a stand alone state machine<...
Service Autonomy<br />Give it a memory (Partner state machine)<br />The relevant last known states of it’s remote partners...
Apology based computing<br />Eventual Consistency presents some challenges to the UI<br />Users need to be informed that t...
Relationship to CQRS<br />Haven’t I seensome of thisbefore?<br />
Similar to CQRS* <br />Events<br />* Command QueryResponsibilitySegregation<br />Browser<br />Workerrole<br />Web role<br ...
It happened, live with it<br />Events<br />Blog Post <br />Submitted<br />Workerrole<br />Browser<br />Web role<br />Event...
Open for extension<br />ExtensionPoints<br />Blog Post <br />Submitted<br />Workerrole<br />Browser<br />Web role<br />Eve...
Answering The Challenges<br />How does all of thissolve the design challenges in the cloud?<br />
Answering the challenges<br />Latency<br />Event consumers listen to what’s happening<br />They react to events when they ...
Answering the challenges<br />Availability<br />If the event channel technology is durable<br />Like azure storage queues<...
Answering the challenges<br />Availability<br />The absence of events in the stream<br />Can be detected by a stream event...
Answering the challenges<br />No distributed transactions<br />Compensating events<br />Compensation logic , local transac...
Technology Mapping<br />What technology could I use to implement this…<br />
Event channel<br />Table storage queues<br />Durable <br />might lead to dead queues though<br />Queue management required...
Event processing engine<br />Microsoft StreamInsight<br />Stream event processing<br />Complex event processing<br />.NetS...
Event processing engine<br />Open source to the rescue<br />NServicebus<br />Library to implement service busses<br />Rout...
Demo<br />Canyou show me anexample?<br />
Architecture<br />Web<br />Web<br />Web<br />Web<br />Web<br />Queue Storage<br />StreamInsight<br />NServicebus<br />Azur...
Implementation Details<br />How the helldidyou do that!<br />
NHibernate<br />Interaction with Azure is through REST API’s<br />Manually crafting requests<br />Manually parsing respons...
NhibernateDriver<br />Walkingthrough the code…<br />
NServiceBus<br />Performs messaging on Queue Storage<br />Client API ( IBus )<br />Server API ( IHandleMessages<T> )<br />...
NServiceBus<br />Custom extensions<br />Azure Queue Transport<br />Subscription storage <br />Worker availability manageme...
Nservice Bus extensions<br />Walkingthrough the code…<br />
Modules<br />In order to cut costs<br />Modules loaded ad runtime<br />From blob storage<br />For all components<br />Allo...
CMS Module WORKER<br />Walkingthrough the code…<br />
StreamInsight<br />Event<br />Event<br />Event<br />Event<br />Event<br />Event<br />Event<br />Event<br />Event<br />Even...
STREAMINSIGHT EXTENSIONS<br />Walkingthrough the code…<br />
Web Role<br />ASP.Net MVC<br />Heavy use of JQuery<br />Asynchronous semantics<br />WYSYWIG style<br />Extremely apology b...
CMS Module web<br />Walkingthrough the code…<br />
RUNTIME<br />Walkingthrough the code…<br />
Let’sRecap<br />We’refinallythere!<br />
ANY QUESTIONS?<br />Wouldthisguystill have a sociallife?<br />
Thank you for coming!<br />Spread the word! www.azug.be<br />
Upcoming SlideShare
Loading in …5
×

Eda on the azure services platform

1,996 views

Published on

The slides for my talk on how to implement an event driven architecture on top of the azure platform

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,996
On SlideShare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
33
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Services do not communicate directlyInstead event generators constantly report what is happening Resulting in a stream of eventsEvent consumers may subscribe to these events And might react to them
  • Event generatorEvent sources come in many forms: Devices, humans, software, nature, …Event generators capture events from the sources, and translate them into a format understood by the event channelEvents are pushed onto the event channel by the generatorEvent ChannelThe event channel is a communication medium,transports the events throughout the systemPreferably it is durable, supports local transactionsAzure offerings that can fulfill this role: Queue storage, .NetServicebus’ messagebuffers, WCF’s RelaybindingsEvent Processing EngineContinuous and incremental processing of event streams with near-zero latencyIdentification of eventsStanding queries (aggregation, grouping, …)Event correlationEvent transformationWindow inspectionEvent forwardingDownstream activityResult of event processingPush : Service Invocation, Notification (Email, sms), Business Process Invocation (Workflow)Pull : Message handler from queue, RSS, Event Stores
  • Separation betweenreads (queries) and writes (commands)QueryUI queries directly from data storeData is potentially staleIs read-only from a UI perspectiveCan cache the data in memoryWill send messages to the command processing sideCommand processingAsynchronous by defaultTypically on other data or event storedoesn’t make sense for Azure table storageSynchronization Real time by means of eventsOr background processes
  • Used as a libraryIn a worker roleNot as easy to deploy as it looks …Standing QueriesImplemented with LinqOn top of the CepStream&lt;T&gt; constructCustom AdaptersInput AdapterOutput AdapterImplemented on top of the custom NServiceBus transport for queue storage
  • Eda on the azure services platform

    1. 1. Windows Azure User Group<br />Event Driven Architecture on the Azure Services Platform27/05/2010<br />
    2. 2. Yours truly<br />Yves Goeleven<br />Solution Architect @ Capgemini<br />MS Community Lead @ Capgemini<br />Board member @ Azug<br />Contact me @<br />Cloudshaper.wordpress.com<br />Mscop.be.capgemini.com<br />Twitter.com/YvesGoeleven<br />Facebook<br />Linkedin<br />Yves@goeleven.com<br />
    3. 3. Introduction<br />What are we going to discuss today?<br />
    4. 4. Agenda<br />Introduction<br />Design challenges<br />Event driven architecture<br />Event Flow Layers<br />Event Processing Styles<br />Extreme Loose coupling<br />Relationship to CQRS<br />Answering the challenges<br />Technology Mapping<br />Demo & Implementation Details<br />Questions<br />
    5. 5. Windows Azure<br />
    6. 6. .Net Service Bus<br />
    7. 7. SQL Azure<br />Business Analytics<br />Reporting<br />Data Sync<br />Database<br />
    8. 8. The beauty of cloud computing<br />Infinite compute and storage capacity<br />On demand<br />Extreme flexibility<br />Without upfront investments<br />Reduces overall costs<br />Better for the environment<br />
    9. 9. Design challenges<br />Aren’t there any downsides to cloud computing then?<br />
    10. 10. Impact of scale<br />Large scale systems suffer from<br />Data latency<br />No distributed transactions<br />Global systems <br />No guaranteed instance availability<br />
    11. 11. Latency<br />Azure Fabric<br />Data overlay<br />Data replication over peers<br />Multiple failure & upgrade domains<br />Machines in different racks<br />Or even different datacenters<br />Depending on traffic and data size<br />This might lead to latency<br />
    12. 12. No distributed transactions<br />The very nature of 2 phase commit<br />Makes each machine confirm twice in the commit process<br />Adding more machines<br />Makes the commit process exponentially slower<br />This drastically limits scalability<br />So distributed transactions are not supported in the cloud!<br />
    13. 13. Instance availability<br />Azure is a global platform<br />Can be used by anyone from anywhere, 24 / 7<br />No windows for maintenance and upgrades<br />The automated update system will take your system down <br />whenever it feels like it!<br />Failure & upgrade domains counteract this<br />Need at least 2 instances of each role<br />
    14. 14. Traditional composite SOA<br />Synchronous request reply integration <br />It assumes little to no latency<br />It assumes data from queries to be accurate<br />It assumes distributed transactions<br />To undo the work of services in case of failure<br />It assumes service availability<br />As consumer is waiting for service completion<br />
    15. 15. Event Driven Architecture<br />If synchronous composite SOA is unsuitable for the cloud, what is?<br />
    16. 16. What’s an event anyway<br />Notable, interesting, thing that happens in the business<br />State change, opportunity, threshold, deviation<br />From a technical perspective<br />Message: header & payload<br />Events are completely self descriptive<br />All relevant state is encapsulated<br />But whom decides what ‘interesting’ means?<br />
    17. 17. Inversion of communication<br />Event generators<br />EventStream<br />Time<br />Eventconsumers<br />
    18. 18. Eventflowlayers<br />Event generator<br />Event Channel<br />Event Processing Engine<br />Downstream activity<br />Event Processing Actions<br />Publish<br />Event Processing Engine<br />Notify<br />Standing<br />Query<br />Invoke service<br />Start business process<br />Capture<br />
    19. 19. Event Processing Styles<br />What does ‘interesting event’ mean ?<br />
    20. 20. SimpleEvent Processing<br />Event generator<br />Event Channel<br />Event Processing Engine<br />Downstream activity<br />Event Processing Actions<br />Publish<br />Event Processing Engine<br />Notify<br />Simple Event<br />Invoke service<br />Start business process<br />Capture<br />
    21. 21. StreamEvent Processing<br />Event generator<br />Event Channel<br />Event Processing Engine<br />Downstream activity<br />Event Processing Actions<br />Publish<br />Event Processing Engine<br />Notify<br />Simple Event<br />Invoke service<br />Start business process<br />Capture<br />
    22. 22. Complex Event Processing<br />Event generator<br />Event Channel<br />Event Processing Engine<br />Downstream activity<br />Event Processing Actions<br />Publish<br />Event Processing Engine<br />Notify<br />Simple Event<br />Invoke service<br />Complex Event Series<br />Start business process<br />Capture<br />
    23. 23. Extreme Loose Coupling<br />Event driven architecture delivers…<br />
    24. 24. Extreme loose coupling<br />Decoupling in multiple dimensions<br />Implementation<br />Event generator and consumer’s implementation are not bound<br />They even don’t know about the other’s existance<br />All information encapsulated in event<br />Distribution<br />Event generator and consumer can be physically separated<br />As long as they can access the event channel<br />
    25. 25. Extreme loose coupling<br />Decoupling (Continued)<br />Time<br />Events encapsulate all information<br />They can be stored for later processing<br />Evolution<br />Event generators and consumers can evolve independently<br />Usually they are ‘added’ instead of ‘changed’, contributing to ease of management<br />
    26. 26. Brewers CAP Theorem<br />A distributed system can satisfy any two of these guarantees at the same time, but not all three<br />Consistency<br />all nodes see the same data at the same time<br />Availability<br />node failures do not prevent survivors from continuing to operate<br />Partition Tolerance<br />The system continues to operate even if it becomes partitioned due to loss of connectivity<br />
    27. 27. Eventual consistency<br />EDA sacrifices consistency<br />But will eventually become consistent<br />Compensating events <br />Errors and exceptions are events as well<br />And should end up in the event stream<br />Compensating transactions<br />Event Consumers should subscribe to compensating events<br />To make things right again<br />
    28. 28. Eventual consistency<br />Local transactions, or similar mechanics, are still supported<br />So even if a role goes down while processing a compensating event<br />The local transaction will ensure that the event gets processed later<br />Event consumers must be completely autonomous<br />They should not rely on other services<br />The long forgotten SOA principle ‘Service Autonomy’, is mandatory in an EDA<br />
    29. 29. Service Autonomy<br />How to achieve it?<br />Make every event consumer (aggregate root)<br />a stand alone state machine<br />Blog Comment (Submitted, Accepted, Rejected)<br />Encapsulate state transitions with <br />Tentative operations <br />Submit / Accept / Reject<br />Internally it uses <br />the currently known state <br />risk mitigation logic <br />
    30. 30. Service Autonomy<br />Give it a memory (Partner state machine)<br />The relevant last known states of it’s remote partners<br />Required to properly implement risk mitigation logic<br />This allows for<br />Stale, locally stored, state <br />out of order events<br />
    31. 31. Apology based computing<br />Eventual Consistency presents some challenges to the UI<br />Users need to be informed that the system<br />Is working on it, instead of waiting for the result<br />The system will get back to them later<br />In case of failure or success<br />Task oriented UI’s <br />support this better than data oriented UI’s<br />
    32. 32. Relationship to CQRS<br />Haven’t I seensome of thisbefore?<br />
    33. 33. Similar to CQRS* <br />Events<br />* Command QueryResponsibilitySegregation<br />Browser<br />Workerrole<br />Web role<br />Submit New <br />Blog Post<br />Command<br />Request/Reply<br />Publish<br />Query<br />Request/Reply<br />View Recent <br />Blog Posts<br />
    34. 34. It happened, live with it<br />Events<br />Blog Post <br />Submitted<br />Workerrole<br />Browser<br />Web role<br />Event<br />Oneway<br />EventStream<br />Query<br />Request/Reply<br />View Recent <br />Blog Posts<br />
    35. 35. Open for extension<br />ExtensionPoints<br />Blog Post <br />Submitted<br />Workerrole<br />Browser<br />Web role<br />Event<br />Oneway<br />EventStream<br />Query<br />Request/Reply<br />View Recent <br />Blog Posts<br />
    36. 36. Answering The Challenges<br />How does all of thissolve the design challenges in the cloud?<br />
    37. 37. Answering the challenges<br />Latency<br />Event consumers listen to what’s happening<br />They react to events when they receive them<br />Time between event occurrence and processing<br />Is probably irrelevant for the event consumer<br />As all information is encapsulated inside the event<br />Take into account that events may arrive out of order<br />Risk mitigation strategies required<br />Based on local state and partner state machine<br />
    38. 38. Answering the challenges<br />Availability<br />If the event channel technology is durable<br />Like azure storage queues<br />Event consumers can go down without impact<br />They will receive the events once they come back up again<br />
    39. 39. Answering the challenges<br />Availability<br />The absence of events in the stream<br />Can be detected by a stream event processing<br />This can result into a new event<br />Triggering a self healing process<br />Or human intervention<br />
    40. 40. Answering the challenges<br />No distributed transactions<br />Compensating events<br />Compensation logic , local transactions<br />Humans can subscribe to them as well<br />To fix the issues manually<br />
    41. 41. Technology Mapping<br />What technology could I use to implement this…<br />
    42. 42. Event channel<br />Table storage queues<br />Durable <br />might lead to dead queues though<br />Queue management required<br />Supports queue-peek-lock<br />Similar to local transactions<br />.NetServicebus’ messagebuffers<br />Temporarily durable <br />will disappear if unused<br />Supports queue-peek-lock<br />Similar to local transactions<br />WCF’s Relaybindings<br />Can reach outside of the cloud <br />Even across NAT &Firewalls<br />No transaction support<br />
    43. 43. Event processing engine<br />Microsoft StreamInsight<br />Stream event processing<br />Complex event processing<br />.NetServicebus used to* have routers<br />Ideal for forwarding events<br />Supported any / all forwarding<br />*Rumored to come back soon<br />
    44. 44. Event processing engine<br />Open source to the rescue<br />NServicebus<br />Library to implement service busses<br />Routing scenarios<br />Publisher (All)<br />Distributor (Any)<br />Simple event processing<br />Message handlers<br />Complex event processing<br />Saga pattern<br />
    45. 45. Demo<br />Canyou show me anexample?<br />
    46. 46. Architecture<br />Web<br />Web<br />Web<br />Web<br />Web<br />Queue Storage<br />StreamInsight<br />NServicebus<br />AzureRoles<br />CEP<br />Publisher<br />Publisher<br />(All)<br />Table<br />Storage<br />Distributor<br />Distributor<br />(Any)<br />Worker<br />Worker<br />Worker<br />Worker<br />Worker<br />
    47. 47. Implementation Details<br />How the helldidyou do that!<br />
    48. 48. NHibernate<br />Interaction with Azure is through REST API’s<br />Manually crafting requests<br />Manually parsing responses<br />Is cumbersome<br />Co-created an NHibernate driver<br />To do the heavy lifting of interacting with table storage<br />Provides persistence ignorance<br />
    49. 49. NhibernateDriver<br />Walkingthrough the code…<br />
    50. 50. NServiceBus<br />Performs messaging on Queue Storage<br />Client API ( IBus )<br />Server API ( IHandleMessages<T> )<br />Pub/Sub with durable subscriptions<br />Distribution based on worker availability<br />Uses Nhibernate and azure storage driver internally<br />For all it’s storage needs<br />
    51. 51. NServiceBus<br />Custom extensions<br />Azure Queue Transport<br />Subscription storage <br />Worker availability management<br />Saga support (not yet finished)<br />
    52. 52. Nservice Bus extensions<br />Walkingthrough the code…<br />
    53. 53. Modules<br />In order to cut costs<br />Modules loaded ad runtime<br />From blob storage<br />For all components<br />Allows for dynamic views, message handlers and CEP queries<br />Plan to switch to MEF<br />StructureMap as IOC<br />Wires it all together<br />
    54. 54. CMS Module WORKER<br />Walkingthrough the code…<br />
    55. 55. StreamInsight<br />Event<br />Event<br />Event<br />Event<br />Event<br />Event<br />Event<br />Event<br />Event<br />Event consumers<br />Event generators<br />CEP Application at Runtime<br />CEP Engine<br />Devices, Sensors<br />Pagers & Monitoring devices<br />Standing Queries<br />Output Adapters<br />Input Adapters<br />Web & Worker Roles<br />Web & Worker roles<br />Event stores & Databases<br />Event Stores & Databases<br />Monitoring Systems<br />Static reference data<br />55<br />
    56. 56. STREAMINSIGHT EXTENSIONS<br />Walkingthrough the code…<br />
    57. 57. Web Role<br />ASP.Net MVC<br />Heavy use of JQuery<br />Asynchronous semantics<br />WYSYWIG style<br />Extremely apology based<br />Nhibernate’s second level cache on by default<br />Effectively queries memory most of the time<br />Synchronization through events of course<br />Switching to IronRuby as view engine<br />Views stored in blob storage<br />Allows for runtime customization<br />
    58. 58. CMS Module web<br />Walkingthrough the code…<br />
    59. 59. RUNTIME<br />Walkingthrough the code…<br />
    60. 60. Let’sRecap<br />We’refinallythere!<br />
    61. 61. ANY QUESTIONS?<br />Wouldthisguystill have a sociallife?<br />
    62. 62. Thank you for coming!<br />Spread the word! www.azug.be<br />

    ×