Cloud Design Patterns with Microsoft Azure
=============================================
Christopher Fahey
Discuss benefits and considerations for patterns.Cloud computing -> running on other peoples hardwareBuild in a manner to get as much value as possiblePattern = Problem -> SolutionsPatterns offer flexible solutions to common problems in software developmentproven practices for predicable resultsCache-Aside
Improve performanceSync with data storeHelp keep cache up to date.Application update the data store, invalidates corresponding item in the cache.Problem
Usually impractical to expect that cached data will always be completely consistent with the data in the data store.
Solution
Load data on demand into a cache from a data store.
Notes
Circuit Breaker
Handle faults that may take a variable amount of time to rectify
Retry pattern, stop trying!Pointless to keep trying.Resources get exhausted.Problem
In a distributed environment, unexpected events may cause resources to break and try to rectify themselves continously.
Solution
Quickly accept that the operation has failed and handle this failure accordingly (backoff logic or stop trying).
Notes
proxy for operations that may fail.
proxy should monitor recent failures that have occurredUsually partners with the Retry Pattern.Problem
Data may be spread across an assortment of data sources held in a variety of geographic locations. Data store must be undone reliably.
Solution
Intelligent process that takes into account any work done by concurrent instances.
Notes
May involve invoking the service again and performing another action that reverses the effects of the first.Competing Consumers
Enable concurrent consumers to process messages received on the same messaging channel.throughput, scalability and availability, and to balance the workload.reduces blocking by avoiding synchronous operations.Problem
System may be overloaded by an influx of messages coming from the application.
Solution
System can run multiple instances of the consumer service. Coordinated effort so work isn't duplicated.
Notes
Compute Resource Consolidation
Consolidate multiple tasks or operations into a single computational unitIncrease compute resource utilization, reduce costsProblem
Deploying lots of instances as part of the same application can increase runtime hosting costs and make management of the system more complex.
Solution
Consolidate multiple tasks or operations into a single computational unit. (Separation of Concerns anti-pattern).
Notes
Separation of Conerns working against you financially, complexCommand and Query Responsibility Segregation (CQRS)
Separate read and update operationsPerformance, security, scalability
Same business logic for all CRUD
Conflicts with simulatenous collaboratorsProblem
Traditional CRUD designs work well when there is only limited business logic applied to the data operations.
Solution
Segregate operations that read(queries) and update(commands) data. Use Separate interfaces.
Notes
Separation of the read and write stores also allows each to be scaled appropriately to match the load.CQRS Separation
Undo work performed by a series of steps
Eventual consistency modeEvent Sourcing
maintain full audit trails and historyProblem
Data will be read, modified, and updated. Current state of the data with the new values may be locked by transactions.
Solution
Handle operations on data that is driven by a sequence of events, each of which is recorded in an append-only store.
Notes
LayeringProblems: overhead, concurrent users, no history and audit trail.Materialize the current state of an entity by effectively playing back.External Configuration Store
Move configuration information out of the application deployment package to a centralized locationProblem
Changes to the configuration require the application to be redeployed, resulting in unacceptable downtime. Securing sensitive configurations.
Solution
Store the configuration information in external storage, and provide an interface that can be used to quickly and efficiently read and update configuration settings.
Notes
Federated Identity
Delegate authentication to an external identity provider.Simplify development, improve user experience.Problem
Users may be forced to use specific (and different) credentials for applications. Complicated user management.
Solution
Separating user authentication from the application code, and delegating authentication to a trusted identity provider.
Notes
Gatekeeper
validates and sanitizes requestsProvide an additional layer of security, and limit the attack surface of the system.Problem
Code that accepts requests from clients, likely to accesses storage with sensitive information. If one host compromised, other areas may be impacted.
Solution
Decouple hosts or tasks that expose public endpoints from the code that processes requests and accesses storage.
Notes
Health Endpoint Monitoring
Verify that applications and services are performing correctlyProblem
You do not have full control of the hosting environment. Services typically depend on other services provided by platform others.
Solution
Implement health monitoring by sending requests to an endpoint. Do a check and then analysis of the result.
Notes
Index Table
Create indexes over the fields in data stores that are frequently referenced by query criteria.
Denormalization of data.Problem
Application might not be able to use the primary key if it needs to retrieve data based on some other field.
Solution
Emulate secondary indexes by creating your own index(fact) tables. An index table organizes the data by a specified key.
Notes
May require the application to fetch and examine every record.Leader Election
distributed environment
collaborating task instances, one is elected leader to coordinating tasksProblem
Multiple instances of the same task could be running simultaneously with each instance servicing a different user, overwritting others work.
Solution
Instance is elected as leader. This instance should coordinate the actions of the other subordinate task instances.
Notes
Materialized View
Prepopulated views over the data in one or more data storesTypically used when data cannot be efficiently queriedProblem
When aggregates are needed, extract all of the data for the relevant entities in order to obtain the required information.
Solution
Generate (in advanced) a view that materializes the data in a format most suited to the required results set
Notes
Improve performance of quering data.define materialize: become actual fact; happen.Pipes and Filters
Decompose a task that performs complex processing into a series of discrete elements that can be reused.perform the processing to be deployed and scaled independently.Some tasks may be compute intensive, need dedicated hardwareProblem
Application requires many tasks of various complexities that is developed as a monolithic module. Limited code reuse.
Solution
Decompose the processing required for each stream into a set of discrete components (or filters), each of which performs a single task.
Notes
scale independentlyMicroservices that can be updated/swapped out adhoc.Priority Queue
Requests with a higher priority are received and processed more quickly than those of a lower priority.different service levels guarantees to different clients.Problem
Message queues are typically used to delegate tasks to background processing. Some tasks are more important than others.
Solution
Messages in the queue are automatically reordered so that messages with a higher priority will be received before those of a lower priority.
Notes
Define the priorities in the context of the solution Identify the requirements for handling high priority items, and what other resources must be allocated to meet these criteria. i.e. processes within 3 seconds.Queue-based Load Leveling
Requests received at a variable rate, processed at a constant rate.otherwise cause the service to fail or the task to time out.Problem
Difficult to predict the volume of requests to which the service might be subjected at any given point in time.
Solution
Introduce a queue between the task and the service as a buffer.
Notes
Thottling with third parties.service can handle the messages at its own pace irrespective of the volume of requests from concurrent tasks.control costs because the number of service instances deployed needs only to be sufficient to meet average load, not peakRetry
Stability
Handle anticipated, temporary failures
Expectation that the cause of the failure is transient.Problem
Temporary faults can occur in your own or others services and are not uncommon.
Solution
Application detects a failure when it attempts to send a request to a remote service, and trys again.
Notes
service might be getting an unexpected high number of requests and busymitigate single point of failures.
parameterize policies.Runtime Reconfiguration
minimize downtime
Reconfigured without requiring redeployment or restartingProblem
Necessary to reconfigure the application to change specific behavior or settings while it is deployed and in use.
Solution
Application code will respond to events that are raised by the hosting infrastructure when it detects a change to the application configuration.
Notes
Granularity of logging levels
Polling mechanism that regularly checks for changes to the configuration.Scheduler Agent Supervisor
Coordinate a set of actions, recover and retry actions that failProblem
Perform tasks that comprise a number of steps, some of which may fail.
Solution
Restore the system to a consistent state and ensure integrity of the entire end-to-end operation.
Notes
-
Scheduler: Arranges for the individual steps that comprise the overall task.
-
Agent: Contains logic that makes calls to a remote service.
-
Supervisor: Monitors the status of the steps in the task being performed by the Scheduler.
- https://msdn.microsoft.com/en-us/library/dn589780.aspx
Sharding
Divide a data store into a set of horizontal partitionsProblem
Data store hosted by a single server may be subject to limitations such as storage space, bandwidth, computing resources and location.
Solution
Divide the data store into horizontal partitions or shards. Each shard has the same schema, but holds its own distinct subset of the data.
Notes
To ensure optimal performance and scalability, it is important to split the data in a way that is appropriate for the types of queries the application performsStatic Content Hosting
Offload static content to deliver these directly to the client.Problem
App server must handle requests to download static content. This absorbs processing cycles that could often be put to better use.
Solution
Locate some of an application’s resources and static pages in a storage service. The cost for cloud-hosted storage is typically much less than for compute instances.
Notes
Save money minimize the requirement for compute instances.Throttling
Control the consumption of resourcesProblem
Load on a cloud application typically varies over time based on the number of active users or the types of activities they are performing.
Solution
System should monitor how it is using resources so that, when usage exceeds some system-defined threshold, it can throttle requests from one or more users to enable the system to continue functioning.
Notes
Auto-scaling with provisioning is not instantaneousValet Key
restricted direct accessProblem
Application will handle the movement of the data. This approach absorbs valuable resources such as compute, memory, and bandwidth.
Solution
Restrict access to the data store’s public connection and provide the client with a key or token that the data store itself can validate.
Notes
provides time-limited access to specific resources and allows only predefined operations such as reading and writing to storage or queuesAdditional Materials
-
12 Factor App
- In the modern era, software is commonly delivered as a service: called web apps, or software-as-a-service. The twelve-factor app is a methodology for building software-as-a-service apps.
Cloud Design Patterns with Microsoft Azure
=============================================
Christopher Fahey
Discuss benefits and considerations for patterns.Cloud computing -> running on other peoples hardwareBuild in a manner to get as much value as possiblePattern = Problem -> SolutionsPatterns offer flexible solutions to common problems in software developmentproven practices for predicable results