Shy CohenAlon Fliess CEOCTO Not accounting for the cost implications of your architecture design,...

Post on 19-Jan-2016

218 views 0 download

Tags:

Transcript of Shy CohenAlon Fliess CEOCTO Not accounting for the cost implications of your architecture design,...

DPA307 - Cost Oriented Development

Shy Cohen Alon FliessCEO CTO

Not accounting for the cost implications of your architecture design, and implementation will

result in lower cost-efficiency

demo

OptimizingResourcesUsageUsing Your Money Wisely

hardware

software

facilities

power/cooling

IT labor

support

network

security

procurement&

accounting

management tools

disaster recovery

backup

Acquisition cost is 10% of IT Spend

Operating cost is 90% of IT Spend

Source: IDC

Cloud Computing Addressed Many of the

“Hidden Costs”

runtime costs

Emphasizes Others

The Real Cost of Software

storage

maintenance

runtime costs

The Cloud Challenge

Pay-per-use consumption modelHuge cost savingsTrouble if cost is not managed properly

At development timeWhen deployed in the cloud

Raising to the Challenge

Create a cost-management strategyUnderstand your applicationArchitecting & designing with cost in mindImplementing efficiently

The key to all of the above:

Cost Insight

Cost and Your Application

Cost is important at every stage of the application lifecycleFor every application type

Requirement Capturing

Architecture & Design

ImplementationTesting

Operations

Cost Orientation Strategy

Understand Plan Solve ReviewRequirement

Capturing

Architecture & Design

ImplementationTesting

Operations

U P S R

U P S R

U P S R

U P S R

U P S R

Cost Oriented Requirements

Functional RequirementsNon-Functional RequirementsConstraints

Huge impact on construction expenses &operational expenses (OpEx)

Cost Oriented RequirementsHaving the right conversations

Cost-analyze the requirements

Discuss implications & alternatives with stakeholdersPay more for user experience?Cheaper alternative experience?Clever solutions?

Review the options you consideredDocument cost implication of each requirement

Or you will return to these discussions again and again

Understand

Plan

Solve

Review

Functional RequirementsPutting a cost on business needs

Understand the cost of business requirementsAre is absolutely required?Can we perform expensive operations on demand?

Plan & solveThe right feature setMitigationsThe right business models

Review & document the cost for each option, and the decision made

Understand

Plan

Solve

Review

Non-Functional Requirements

Engineering: making compromises

Architecture: building product while answering many quality attributes

OpEx Reduction: one of the more

important quality attributesExpense lasts the longest

Might contradict otherimportant qualities

For example: High availability

Requirements

Time

Quality

Business Value

Resources

Non-Functional RequirementsPutting a cost on quality attributes

Understand the cost of the desired qualitiesAvailability, Latency, Robustness

Plan for the optimal way to achieve themConsider the tradeoffs

Implement right architecture & mitigations

Document the cost for each architectural option

Understand

Plan

Solve

Review

Non-Functional RequirementsCost-oriented tradeoffs on quality attributes

Cost vs. LatencySpeed of processing requests as a factor of the cost of instances

Quality vs. PerformanceImage quality as a factor of the cost to generate and transmit

Data Size vs. Data AccessibilityNormalized vs. DenormalizedCompression vs. SearchabilityRelational vs. No-SQL

Etc.

Cost Oriented Constraints

Constraints come from many placesCompetitiveRegulatoryBusinessBudgetEtc.

They can effect cost drasticallyCompute example: Need to encrypt information at restStorage example: Need to keep users’ data for 7 yearsNetworking example: Data must reside in a certain geography

ConstraintsPutting a cost on things you can’t avoid

Understand the cost of each constraint

Plan for the optimal way to address constraintsDevise a solution to each constraint

This is a good time to assess fiscal feasibility!

Document the cost for each of the constraints, and the decisions made

Understand

Plan

Solve

Review

Cost Orientation: Focusing on Value

Not just about lowering costCost limits are ConstraintsConstraints can be negotiated / managed

Mainly about maximizing your investmentMaximizing value is a Quality Attribute

Requirements & CostKey takeaways

Understand the cost ofFunctional RequirementsNon-Functional RequirementsConstrains

Consider tradeoffs and plan mitigations

Make cost-impact an integral part of project documents

Requirement Capturing

Architecture & Design

ImplementationTesting

Operations

Understanding Your ApplicationYour application’s component utilization characteristics

Understanding Your ApplicationComputational requirements

Is your Application CPU bound?Does it have constant load?Does the load change or fluctuate over time?Can you benefit from throttling? Elasticity?

Instance Size CPU Memory Instance Storage I/O Perf Cost per Hour | Month

Extra Small 1 GHz 768 MB 20 GB Low (5 Mbps) $0.05 | $36

Small 1.6 GHz 1.75 GB 225 GB Moderate (100 Mbps) $0.12 | $86

Medium 2 x 1.6 GHz 3.5 GB 490 GB High (200 Mbps) $0.24 | $173

Large 4 x 1.6 GHz 7 GB 1,000 GB High (400 Mbps) $0.48 | $346

Extra large 8 x 1.6 GHz 14 GB 2,040 GB High (800 Mbps) $0.96 | $691

Understanding Your ApplicationStorage requirements

Estimate the size and type of the storage you needFixed storage sizePer-user storage sizeIs the data really relational?

What is the rate of new data?What types of queries do you need?How long should the data be kept for?How often do you need to retrieve the data?How quickly do you need to retrieve the data when asked for?Would it make sense to save computation by storingpre-processed data?

Storage Type Component Cost

SQL Azure Storage $10 / GB / Month

Windows Azure Storage $0.15 / GB / Month

Transaction $0.01 / 10,000 tx

Understanding Your ApplicationCommunication requirements

Where will your users be located?What are your network traffic patterns?Do you need to connect with existing systems?

Systems of recordConnecting across network boundaries

What’s your expected ingress and egress?Baseline trafficVariable trafficSystem generated trafficUser generated traffic

RegionPrice for 1 GB

In Out

North America andEurope regions

$0.10 $0.15

Asia Pacific Region $0.10 $0.20

Application Cost AnalysisA really simplified example

Our app provides up-to-date Cost Insight & AnalysisCompute Analysis

4 instances (2 front-end, 2 back-end)Application is relatively CPU-light No requirements on instance size

Storage AnalysisProjected data accrual rate is _____ per user per dayData is retained for ____ daysData is not relational we can use Azure Storage

Communication AnalysisWeb: inbound is negligible, est. ___ outbound per user per dayEmail: no inbound, ___ outbound per user per dayMeet communication limits for ___ instance

Throttling StrategyMust scale to sample every account every 5 minutesSoft deadlines on outbound email

Elasticity StrategySoft limit + hard Limit

ConclusionRunning COST will cost a $___ per 1000 clients per month

COA ConsiderationKnown architecture patterns

Worker Role 2Worker Role 1

Worker Role 4Worker Role 3

Web Role 1

SOA and the Cloud

Services are units of functionality and compositionRoles are units of deployment and scalabilityDon’t mix architecture and deployment strategy

Service A

Service C

Service E

Service B

Service D

Worker Role 2Worker Role 1

Web Role 1

Service A

Service C

Service E

Service B

Service D

- 40%

Worker Role 2

Master

SOA and the CloudRethinking solutions

Sometimes, the “standard” solution is not the best oneExample, dividing work

Worker Role 4Worker Role 3

Worker Role 1

Master

SlaveSlave

Reduction of 2/(n+2)

Master-Slave

Worker Role 2Worker Role 1

PeerPeer

Peer-to-Peer

Worker Role 2Worker Role 1

SlaveMaster +

Slave

Non-Dedicated Master

Optimizing Compute ResourcesGuidance

Combine servicesMind the cost boundaryOptimize # of instancesCreate a “Compute Pool”Offload work to worker rolesUse queues to manage compute loadsUse statistical information to pre-load instancesOffload work to deployments in different regionsLeverage AppFabric Caching to share calculation results

Architecting Interfaces

Design a service interface that optimizes cost-benefit

Avoid chatty interfacesProvide the right amount of informationDon’t force complex operations in the implementation

Don’t perform unnatural acts

What will be the cost of implementation and maintenance?Is the saving meaningful?

Architecting InterfacesReduce costs

Design a service interface that optimizes cost-benefit

Architecting InterfacesConsider the impact of the frameworks you use

DataSets are easy to use, but they can be wastefulSend the original value when saving a change(As opposed to using a timestamp or an E-tag)

Using Entity Framework can result in unexpected trafficSelf-tracking entitiesLazy loading of referenced objectsEtc.

Saving Cost of Content Generation

Choosing the right order of the tabsLoading tab content when tab is displayed

Order Instances Hours Cost

Used 100% 23% 89%

Order Cost Instances Hours

Used 100% 37% 22%

Before: 2.1 charts/visit

After: 1.6 charts/visit

Resource Optimization

Creating the Correct user Experience

DEMO

More Ways to SaveAdditional guidance

Avoid computationUse the client CPUUse storage accountUse SQL Azure

Use optimal role sizesDifferent sizes for the different rolesDifferent sizes for the same role at different times

Avoid storage accessUse cookies for client conf

Lower computation costUse storage in tandem with computeUse the CDNDefer content generation until it’s needed

Cost Optimization Techniques

Standard optimization techniquesSpeed of executionMemory usage

Cloud specific code-optimizationOptimal cloud resource usage

Offloading Work to the Client

Generating UI on the Client Side

Demo

Cost Oriented ArchitectureSummary

Use SOA principlesBut don’t conflate architecture with deployment

Create effective interfacesWithout over-complicating their implementation

Determine the actual cost impact of your designMeasure the right things

Requirement Capturing

Architecture & Design

ImplementationTesting

Operations

The Cost of Your Code

Code: Affected by architecture but independent from it

.NET Defers Resource Collection

Better Ways to Manage Connection Cost

using(…)Close the connection explicitlyReuse the connection

Factory patternClose when not being used

Cost profiling & optimization is key

Cost Oriented Development

Understanding the Impact of Code

Demo

Thinking Outside The Code

The Cost Of DataThe Cost Of ConnectivityThe Cost Of Security

The Cost Of DevelopmentThe Cost of QAThe Cost Of Bugs

The Cost of Data

Data SizeWhat’s the required fidelity? (Images, Videos, etc.)Does data compression pay? (CPU vs. Network & Storage)

Data Retention Policy

Optimizing Storage Services

Data storage optionsTable StorageQueue StorageBLOB Storage (page & block), and Azure DrivesSQL AzureAppFabric CachingThe CDN

Understand storage consumption and pricing modelsSelect the right storage option for your needs

Optimizing Storage ServicesGuidance

Compute data at the right timeUse the CDN’s dynamic-content-cachingCreate views over large data dynamicallyBatch operations to reduce store transactionsOptimize serialization formats & compressionMake fewer queries (e.g. use CSS Image Sprites)Leverage AppFabric Caching to share calculation resultsReuse SQL Azure database instances during development

More Ways to SaveAdditional guidance

Protect against "data leaks“Optimize your queue pulling strategyOptimize your SQL Azure data schemaMake sure you are using a “right sized” SQL Azure dbHeed the cost of failed storage requests & poison msgUnderstand the cost using the Azure Client LibraryUnderstand the cost of using Azure DriveDon't blindly cache everything

Optimizing Storage ServicesThings to avoid

Storing large binary data in SQL AzureAllowing unrestricted upload sizesAllowing unrestricted queries

Optimizing Connectivity Services

Connectivity requirements have 2 sourcesArchitectureCode

Understand connectivity consumption & pricing modelsIngress and egress costsThe AppFabric Service Bus costsWindows Azure Connect costs

Optimizing Connectivity ServicesGuidance

Throttle communicationOptimize internet traffic for web rolesMultiplex over service bus connectionsProvide on-premises fan-out for eventsClose connections when you are not using themPut services are in same region as the data they accessUse AppFabric Caching in cross-region comm. Scenarios

Optimizing Connectivity ServicesThings to avoid

Transmitting repetitive dataChatty communication channelsKeeping connections openExcessive cross-region communication

But remember that in some cases it can actually save money!

The Cost Of Development

Understand the cost of the development processUnit Tests & CIIntegration TestsLoad Tests

How much does a check-in cost?

The Cost of QA

The cost of testingManual testingLoad testing

The cost of debugging

How much does a full test-pass cost?Is this bug or change request worth the cost of testing it?

The Cost Of Bugs

LeaksMemorySystem resources (e.g. handles)ConnectionsStorageetc.

Instance crash and recyclingConsuming resources without making progress

Bad handling of poison messages

Operation Is Still Very ImportantRumors of its demise have been greatly exaggerated

Data backupDROP TABLE Customers … Oops!Backup/version of BLOBs via snapshots

Creating cost-effective data retention policies

Monitoring resource consumption on a regular basis

Avoiding the Dangers of Cost Orientation

Shifting cost models can throw you offFocus on the high level modelAvoid over-tuning to a particular price pointEncapsulate highly-optimized areasBe agile

Avoid unnatural acts in the name of cost reductionDon’t create overly complex architectures in the name of costDon’t create un-maintainable code in the name of cost

Follow the general rules regarding architecting for the cloudThey will ultimately lead you down the right path

Not accounting for the cost implications of your architecture design, and implementation will

result in lower cost-efficiency

Summary

Cost Orientation: Maximizing the value of your investmentA Quality Attribute, not a Constraint

CO touches every aspect of the app lifecycleCost Oriented RequirementsCost Oriented Architecture & DesignCost Oriented ImplementationCost Oriented TestingCost Oriented Operations

Integrate CO into every phase of your project!

Complete an evaluation on CommNet and enter to win!

Scan the Tag to evaluate this session now on myTech•Ed Mobile

© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to

be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS

PRESENTATION.