600 likes | 621 Views
Learn how to design event-driven applications efficiently using Azure Cosmos DB, resolve performance issues, and integrate with various tools and technologies for enhanced functionality.
E N D
Event driven application with Azure Cosmos DB Rafat Sarosh Principal Program Manager – Azure Cosmos DB rafats@microsoft.com @rafatsarosh BRK3159
DesignPattern Solution Tools & Technology
Order Shipping Print Label Inventory
Order Order received Queue Event Notification Shipping Inventory Print Label
Order Order received Queue Event Notification Shipping Inventory Print Label
Applications Customer create, read, update and delete Slow performance, responsiveness and limit scalability No Audit. History is lost Updated Conflicts
Applications Customer create, read, update and delete Log Add Address Update Phone Number Customer Login Add Phone Number
Applications Customer Log Customer Login Address Update Phone Number Customer Login Customer Login Address Phone Number
Applications Customer Applications Log Customer Login Address Update Phone Number Customer Login Customer Login Address Phone Number Decoupling Materialized View Integration with other system Auditing Debugging Teleporting
Applications Customer Applications Microservices Log Customer Login Address Update Phone Number Customer Login Customer Login Address Phone Number Decoupling Easy Updates Software versions Fault Tolerant Debugging Stability
Applications Kafka/Event Hub
AZURE COSMOS DB A FULLY-MANAGED GLOBALLY DISTRIBUTED MULTI-MODEL DATABASE SERVICE BUILT TO GUARANTEE EXTREMELY LOW LATENCY AND MASSIVE SCALE FOR MODERN APPS
SQL Key-Value Column-family Graph Documents … more coming soon mongoDB Azure Cosmos DB Global distribution Elastic scale out Guaranteed low latency Five consistency models Comprehensive SLAs A globally-distributed, multi-model database service
Change Feed Persistent log of records within an Azure Cosmos DB container. Documents presented in the order in which they were modified New Events Azure Cosmos DB Change feed
Change Feed Scenarios Event Computing and Notifications Retail, Gaming, Content management Trigger a call to an API when a document is inserted or modified AzureNotification Hubs Azure App Service Azure functions Stream Processing IoT Processing, Data Science & Analytics Perform real-time (stream) processing on updates to data New Events Azure Stream Analytics Azure HDInsight Apache Spark Apache Storm Azure Cosmos DB Change feed Data movement Enterprise Data Management Move, clone, or archive data to cold storage AzureStorage Blob Azure Data Lake Azure Cosmos DB
Event Sourcing for Microservices Trigger Action From Change Feed Persistent Event Store Microservice #1 Microservice #2 New Event … Azure Cosmos DB Change feed Microservice #N
Materializing Views Application Azure Cosmos DB Materialized View Change feed
Replicating Data Secondary Datastore(e.g. archive) Replicated Records CRUD Data Change feed Azure Cosmos DB
Change Feed with partitions Consumer parallelization • Change feed listens for any changes in Azure Cosmos DB collection. It then outputs the sorted list of documents that were changed in the order in which they were modified. • The changes are persisted, can be processed asynchronously and incrementally, and the output can be distributed across one or more consumers for parallel processing. The change feed is available for each partition key range within the document collection, and thus can be distributed across one or more consumers for parallel processing. Event/stream processing app tier Consumer 3 Consumer 2 Consumer 1
What is Azure Functions?An event-based, serverless compute experience that accelerates app development Focus on code, not plumbing No infrastructure management Auto-scale based on your workload No wasted resources, pay only for what you use
Boost developmentefficiency Integrate with Azure Application Insights Get near real-time details about function apps See metrics around failures, executions, etc. Use triggers to define how functions are invoked Avoid hardcoding with preconfigured JSON files Build serverless APIs using HTTP triggers Connect to data with input and output bindings Bind to Azure solutions and third-party services Use HTTP bindings in tandem with HTTP triggers Monitoring Triggers Bindings Define one API surface for multiple function apps Create endpoints as reverse proxies to other APIs Condition proxies to use variables Debug C# and JavaScript functions locally Use debugging tools in Azure portal, VS, and VS Code CI/CD Proxies Local debugging Save time with built-in DevOps Deploy functions using App Service for CI Leverage Microsoft, partner services for CD
Gain flexibility and develop your way Write code in C#, JavaScript, F#, and Java Continuous investment in new, experimental languages Multiple languages Write stateful functions in a serverless environment Simplify complex, stateful coordination problems Add the extension to enable advanced scenarios Durable Functions Simplify coding for new users with native Azure portal Select from popular editors, like VS, VS Code, CLI, Maven* Dev options Choose from six consumption plans to run Functions Run your first million function executions for free Hosting options *VS and VS Code only support C#; Maven only supports Java
Gain flexibility and develop your way Consumption AS Plan AS Environment Azure Stack Runtime IoT Edge Serverless Free, Basic, Standard, Premium Network isolation On-premises Functions on your server On devices Only pay for what you use; charges apply per execution and per GB second Gain all the advantages of Functions along with Microsoft’s financially-backed SLA and the always-on features of an App Service Plan Use a dedicated App Service cloud environment (ASE) that comes with network isolation for apps, greater scale, and secure connectivity to local vNets Bring the power of the entire Azure stack to your own data centers Run Functions on your local server; does not include the entire Azure stack Deploy custom Azure modules on IoT devices Hosting options
Eventing in the cloud Events Event Handlers Blob Storage Serverless Code Resource Groups Functions Event Grid Azure Subscriptions Serverless Workflowand Integration Event Hubs Logic Apps CloudEvents Format Azure Media Service Storage Queues Buffering and Competing Consumers Event Hubs IoT Hub Service Bus Other Servicesand Applications Custom Events (anything) Hybrid Connections (WebSockets) AzureAutomation WebHooks(anything) CloudEvents Sources
Azure Event Grid Fully-managed event routing Near real-time event delivery at scale Broad coverage within Azure and beyond Backbone of event-driven computing
Benefits Focus on innovation and pay per event Ensure reliability and performance for your apps Unlock new scenarios for your apps Manage all events in one place
Build applications efficiently Management SDKs Publish SDKs Consumption SDKs Event Schema Store .Net Python Java Node.js Ruby Go
Ensure reliability and performance in your apps SLA backed 99.99% availability 24-hour retry with exponential back off for events not delivered 10,000,000 events per second per region High availability Massive scale-out High reliability
Applications Customer Applications Log Customer Login Address Update Phone Number Customer Login Customer Login Address Phone Number
Customer Applications
Customer Applications
Customer Customer Checkout Item Added Cart Checkout Cart Created Item Added Jet.Com Microservices Inventory Shipping
AddressBook Customer CQRS Phone Change Contact Blocked Contact Created Display Name Change Skype Microservices Notification Service Spam Detection Service
911 Scenario Web App IoT Cosmos DB ChangeFeed Azure Function Event Grid
Solutions Azure Cosmos DB / Change Feed / Azure Function/ Event Grid Event Notification / Event Sourcing / Microservice
Top 10 reasons why customers useAzure Cosmos DB The 1st and only database with global distribution turnkey capability Deliver massive storage/throughput scalability database Provides guaranteed single digit millisecond latency at 99th percentile worldwide Natively supports different types of data at massive scale Boasts 5 well-defined consistency models to pick the right consistency/latency/ throughput tradeoff Enables mission critical intelligent applications Gives high flexibility to optimize for speed and cost Tackles big data workloads with high availability and reliability Provides multi-tenancy and enterprise-grade security Naturally analytics-ready and perfect for event-driven architectures
Text layout (without bullet points) Main topic: Segoe UI Semilight, size 28pt Segoe UI, size 20pt for second level Segoe UI, size 16pt for third level
Text layout with bulleted text • Main topic: Segoe UI Semilight, size 28pt • Segoe UI, size 20pt for second level • Segoe UI, size 16pt for third level
Example with longer headline textwrapping to a second line When the headline text is 2 lines, move this text block down to align to the lower blue guide If you don’t see guidelines, click on the View menu, and then check the box in front of “Guides” Use a “soft return” Shift + Enter to wrap text without adding extra line spacing
Adjusting list levels • Main topic: Segoe UI Semilight, size 28pt • Segoe UI, size 20pt for second level • Segoe UI, size 16pt for third level Use the “Decrease List Level” and “Increase List Level” tools on the Home menu to change text levels. Try this: Place your cursor in the line of text that says “Segoe UI, size 20pt for second level” Next click the Home tab, and then on the “Decrease List level” tool. Notice how the line moves up one level. Now try placing your cursor in one of the top “Main topic…” line of text. Click the “Increase List Level” tool and see how the text is pushed in one level. Use these 2 tools to adjust your text levels as you work
Bullet points layout with subtitleSet the subtitle to 20pt in the same text block, with character spacing Normal Move the text block down vertically to align to lower guide If you don’t see guidelines, click on the View menu, and then check the box in front of “Guides” Hyperlink style: www.microsoft.com
Enter title text Secondary text