37
Migrating applications to Microsoft Azure: lessons learned from the field Ido Flatow, Sela Group Senior Architect, MRD, MVP @IdoFlatow Join the conversation on Twitter: @DevWeek #DW2015

Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

Embed Size (px)

Citation preview

Page 1: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

Migrating applications to Microsoft Azure: lessons learned from the field

Ido Flatow, Sela Group

Senior Architect, MRD, MVP

@IdoFlatow

Join the conversation on Twitter: @DevWeek #DW2015

Page 2: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

About Me

Senior Architect, Sela Group

Microsoft acronyms: RD, ASP.NET/IIS MVP, Azure TSS, MCT

Co-author of courses and books

Focus on server, web, and cloud

Manager of the Israeli Web Developers User Group

Page 3: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Azure From the Field

Azure Costs and Billing

Know Your Azure Stuff

Architecture Lessons Learned

Azure Preview Features

Tools of the Trade

Page 4: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Azure Costs and Billing

Page 5: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Azure Costs – the Obvious

Pay for the services you use

Instances, storage, SQL Database, Service Bus, …

Pay only for outgoing bandwidth

Pay-as-you-go

Don’t remember the prices? Check online

http://azure.microsoft.com/en-us/pricing

Don’t forget discounts

Page 6: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

The Costs You Didn’t Account For

Small change

VM disks, bandwidth, storage transactions, VPN gateway

The must-have

VM Backups, SQL Database backups (exceeding 200%)

The nice-to-have

monitoring data, diagnostics data

Egress for monitoring data

Don’t go to production without it

Technical support

Page 7: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Reducing Azure Costs

Turn off dev/test VMs off-hoursTurning off 22:00-7:00 and on weekends to reduce costs by 50%

Monitor your instances to optimize their usagehttp://blogs.technet.com/b/cbernier/archive/2014/08/05/microsoft-azure-iaas-cost-estimator-tool.aspx

Which storage type are you using? (prices in $/GB/month)

LRS (0.024) / ZRS (0.03) / GRS (0.048) / RA-GRS (0.061)

Keep track of instances

Delete unused VM disks

Use basic tiers for dev/test

Delete staging deployments

Regularly inspect your bill !

Page 8: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

How Stuff Works

Page 9: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Learning How Azure Works

None of us knows how Azure works

Except maybe this guy

Learning how stuff works is a process

Start with the basics of what each Azure service does

Get to know each service’s limitations and performance

Look for best-practices, advanced topics, etc.

Here are some examples of the learning curve

Page 10: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

How Stuff Works

Lessons Learned

Load Balancer

Azure LB is round robin, not!

Is LB the same for all hosting offerings?

Traffic Manager

What’s DNS load balancing?

TTL is a recommendation

Azure Compute

Persistent/Temporary disk

Does size only dictate CPU & Memory? (short answer, NO!)

Incoming/outgoing IP

Page 11: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Where to Learn Azure Services

Get updated

Azure blog (http://azure.microsoft.com/blog)

Team blogs (Azure Storage, Active Directory, ScottGu)

Service update (http://azure.microsoft.com/en-us/updates)

Know your limits

Service limits and quotas (http://bit.ly/1mNOSlp)

Storage scalability (http://bit.ly/1aPZNt4)

Check the documentation

Walkthroughs (http://azure.microsoft.com/en-us/documentation)

REST Management APIs (http://bit.ly/1wLDD5e)

Cloud design patterns (http://bit.ly/1CGJSsL)

Virtual/Classroom training, Azure user groups (http://www.meetup.com/UKAzureUserGroup)

Page 12: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+Lessons Learned –

Architecting for the Cloud

Page 13: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Azure Scenarios

Lift&Shift

Dev/Test

PaaS

Hosting

*-as-a-Service

Big Compute / Big Data

Page 14: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Cloud Architecture Best Practices

Scale Up / Scale Out

Disaster Recovery (DR)

Store session in cache

Leverage Azure PaaS Services

Decouple components with async

queues

There was a session on these

topics on Tuesday

Page 15: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Lessons Learned

Why Can’t I Access my Service?

Complaints

Traffic Manager marks services as degraded (failed)

Azure Load Balancer “ignores” instances

External monitoring with Pingdom fails due to timeouts

Troubleshooting

Checked Azure operation logs, but did not find anything substantial

Requested Azure Support to provide logs for TM / LB , but they didn’t have detailed logs for all services

Azure Support requested IIS logs, but we didn’t have any (deployment already deleted/updated)

Time spent so far – about 4 days!

Page 16: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Lessons Learned

Why Can’t I Access my Service?

After enabling logs we realized that:

TM monitoring got blocked by VM Endpoint ACL

Endpoints failed when probed due to an internal error – HTTP 500 in IIS Logs

Endpoints hanged (>1 minute) when probed because site was overloaded

Conclusions

Keep in mind that ACL Endpoints also blocks Azure IPs

Don’t assume Azure monitors everything for you

Don’t rely solely on Azure Metrics for diagnostics

Use the PaaS/IaaS Diagnostics Plugin

Collect application, server, and IIS logs

Move logs periodically to Azure Storage

http://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-diagnostics

http://azure.microsoft.com/blog/2015/03/09/simplifying-virtual-machine-troubleshooting-using-azure-log-collector

Page 17: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Lessons Learned

Making Developers Happy

Complaints

Deploying to cloud services takes forever

Deployment sometimes hangs, and we need to

delete it and re-do

Why is that?

Deployment means uploading huge packages to

storage

Provisioning new instances takes time

Complex worker roles are slow to stop / start

Page 18: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Lessons Learned

Making Developers Happy

So what can we do?

Use compute emulator when possible

https://msdn.microsoft.com/en-

us/library/azure/hh403990.aspx

For slow Internet – deploy from an Azure VM

Enable Web Deploy for single-instance Web Roles

https://msdn.microsoft.com/en-

us/library/azure/ff683672.aspx

Don’t be afraid to RDP and replace .dll files (dev/test)

http://blogs.msdn.com/b/kwill/archive/2013/09/05/ho

w-to-modify-a-running-azure-service.aspx

Replace in-role cache with cache-as-a-service

Page 19: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Lessons Learned

Data Synchronization and DR

We know how to deploy frontends and backends for DR:

Deploy multiple sets of Web and Worker apps to multiple sites

Use configuration to manage database and storage addresses

Create Traffic Manager endpoints with failover

We don’t know how to properly:

Replicate the database between the sites

Replicate Azure Storage (blobs, tables, files) between the sites

Page 20: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Lessons Learned

Data Synchronization and DR

Database Synchronization

(IaaS) SQL Server 2014 – AlwaysOn supports HA and DR with

multiple datacenters

http://blogs.msdn.com/b/igorpag/archive/2014/12/22/sql-2014-

high-availability-and-multi-datacenter-disaster-recovery-with-

multiple-azure-ilbs.aspx

(IaaS) MySQL – Use Master-Master and Multi-Master replications

http://top-performance.blogspot.co.il/2013/09/mysql-multi-

master-replication.html

(PaaS) SQL Database – Geo-Replication in Standard and Premium

http://azure.microsoft.com/blog/2014/09/03/azure-sql-database-

standard-geo-replication

Page 21: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Lessons Learned

Data Synchronization and DR

Azure Tables - Transactional Data Patterns

Write transactions to a queue, not directly to the DB

Workers dequeue transactions, and write to the DB

For DR, duplicate the transaction to a remote queue

Applies to both database and Table storage

https://msdn.microsoft.com/en-us/library/azure/dn251004.aspx

Blob / File synchronization

Azure doesn’t support storage synchronization - DIY

Azure WebJobs SDK provides blob listeners

http://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-webjobs-sdk-storage-blobs-how-to

Beware of huge containers

Page 22: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Lessons Learned

Azure Services are not Bulletproof

Complaints

Azure Storage sometimes timeout when reading/writing

SQL Database connections sometimes timeout or dropped

SBQ suddenly isn’t available for several seconds

What is happening?

Some Azure services use shared

computing, networking, and storage

Network congestion and high CPU

can cripple a single service node

Potentially, such interruptions should

not take more than a few seconds

Page 23: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Lessons Learned

Azure Services are not Bulletproof

Resolving with retries

Use fault detection and retry logic

Most Azure SDKs support retries (Service Bus, Storage)http://azure.microsoft.com/blog/2014/05/22/azure-storage-client-library-retry-policy-recommendationshttps://msdn.microsoft.com/en-us/library/azure/dn275924.aspx

For other cases – use the Transient Fault Handling Application Blockhttps://msdn.microsoft.com/en-us/library/hh680934(v=pandp.50).aspx

Resolving with failovers/backups

Service Bus secondary namespacehttps://msdn.microsoft.com/en-us/library/azure/jj554355.aspx

Read-only GRS for Azure Storagehttps://msdn.microsoft.com/en-us/library/azure/dn727290.aspx

Page 24: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Lessons Learned

Making it Faster

Complaints

Upload to Azure Storage is slow

It takes a long time to send 10k messages to Service Bus Queues

Listener in Worker Role only utilizing 25% CPU

Azure services are complex, don’t expect <1ms latency

What can we do?

Do basic tests to get a baseline, make sure it is reasonable

Read performance guidance articles – many services have them

Investigate, investigate, investigate!!!

Page 25: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Lessons Learned

Making it Faster - Examples

Azure Storage

Disable Expect-100 and Nagle

For large files, use parallel block uploads

http://azure.microsoft.com/en-

us/documentation/articles/storage-performance-checklist

Service Bus

Reuse clients and factories

Batch messages when sending and receiving

Client-side batching and server-side prefetching

https://msdn.microsoft.com/en-us/library/azure/hh528527.aspx

Page 26: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Lessons Learned

Making it Faster - Examples

Database

Improve SQL on IaaS by using temporary SSD and disk striping

https://msdn.microsoft.com/en-us/library/azure/dn133149.aspx

Improve SQL Database by using Active Geo-Replication for load-

balancing

http://azure.microsoft.com/blog/2014/07/12/spotlight-on-sql-

database-active-geo-replication

Page 27: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+Azure Preview Features –

Fight or Flight?

Page 28: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

#1 Rule of Preview Features

NEVER USE PREVIEW FEATURES IN

PRODUCTION !!!

Page 29: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Preview Features – Why Not?

Bugs

Unimplemented/limited feature set

Minimal documentation

Restricted availability

No warranty or SLA

Possibility of breaking changes

Uncertainty of release date

Not covered by Azure Support

Page 30: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Preview Features – Why Use?

Provide feedback to shape the product to your needs

http://feedback.azure.com

Replace DIY/VMs with platform services

Stay ahead of the curve

Take the time to evaluate the new service

Free of charge / “preview” discount

Page 31: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Preview Features - Getting Started

Check the list

http://azure.microsoft.com/en-us/services/preview/

Use the forums

https://social.msdn.microsoft.com/forums/azure/en-

US/home?category=windowsazureplatform

Don’t forget to look for “hidden” features via the REST API

Hook up with an Azure Insider / MVP for private previews

Page 32: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Tools of the TradeEverything but Visual Studio

Page 33: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Azure Management Tools

Azure Management Studio

http://www.cerebrata.com/products/azure-management-

studio

IaaS Management Studio

http://iaas.ao-is.com

Service Bus Explorer

https://github.com/paolosalvatori/ServiceBusExplorer

Page 34: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Azure Storage Tools

CloudBerry Explorerhttp://www.cloudberrylab.com/free-microsoft-azure-explorer.aspx

CloudXplorerhttp://clumsyleaf.com/products/cloudxplorer

Azure Storage Explorerhttps://azurestorageexplorer.codeplex.com

Zudio (online storage management)https://zudio.co

Cyebrduck (blob storage for MacOS)https://cyberduck.io

Page 35: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Command Line and SDKs

Command-line

PowerShell cmdlets

https://github.com/Azure/azure-powershell

Azure CLI

https://github.com/Azure/azure-xplat-cli

Service Management API

Linq2Azure

http://linq2azure.com

Azure SDK for .NET

https://github.com/Azure/azure-sdk-for-net

Page 36: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

To Conclude

Having a cloud mindset is important

Architecting for the cloud is how we do it properly

Don’t say “I though it worked differently” – read, learn, try!

With time and experience, new best practices are published

Keep up with the technology pace

Page 37: Migrating applications to Microsoft Azure: lessons learned ...files.meetup.com/3118992/AzureLessons.pdf · Migrating applications to Microsoft Azure: lessons learned from the field

+

Join the conversation on Twitter: @DevWeek #DW2015

Resources

You had them throughout the slide deck

Download the slides from:

http://1drv.ms/1BNRinI