© 2012 autodesk moving code to the cloud – it’s easier than you think! kean walmsley software...

Download © 2012 Autodesk Moving code to the cloud – it’s easier than you think! Kean Walmsley Software Architect, Autodesk

Post on 15-Jan-2016




0 download

Embed Size (px)


Moving code to the cloud its easier than you think!Kean WalmsleySoftware Architect, Autodesk 2012 Autodesk 1About the PresenterKean joined Autodesk in August 1995, and has since worked in a number of different positions and countries (UK, USA, India and Switzerland). He recently moved from the Autodesk Developer Team into the AutoCAD Engineering organisation, where he now works as a Software Architect.

Since July 2006 Kean has maintained a development-related blog at: blogs.autodesk.com/through-the-interface

Kean holds a Licence dInformatique from lUniversit de Paris-Sud and a Masters in Computer Science from the University of Kent at Canterbury. 2012 Autodesk 2Class SummaryDiscusses the benefits of the cloud for software developers and looks at a concrete example of moving desktop functionality to the cloud.

We will look at issues related to architecture of software destined for the cloud.

We will compare commercial cloud offerings such as Amazon Web Services and Windows Azure, and will take an look a several client-side environments for consuming this data, such as AutoCAD, Unity3D, Android, iOS and HTML5. 2012 Autodesk 3Learning ObjectivesAt the end of this class, you will be able to:Apply best practices for architecture of cloud-based software componentsSelect an appropriate cloud-hosting providerCreate a simple web-service and deploy it to the cloudConsume a cloud-based web-service from a variety of client environments 2012 Autodesk 4First, a word from Scott Adamshttp://dilbert.com/strips/comic/2012-10-21

2012 Autodesk Why all this talk of the cloud? 2012 Autodesk 6

The Latest Technological ShiftWe used to depend on centralized computing resourcesThe mainframe era gave way to personal computingMoores Law led to huge performance gains over decadesAutodesk rode this wave

The next shift is to the cloudCentralized infrastructure is becoming more dependableThe benefits of infinite computing are compellingIn terms of scalability and costMobile computing driving the need for low-powered devicesThe world is really becoming heterogeneous, device-wise

2012 Autodesk Moving Code To The Cloud Can Make SensePerformanceAccess to greater compute resources

ScalabilityAs your requirements scale, so does your resource consumption and cost

ReliabilityDespite mediatized outages, cloud providers are pretty reliable and improving

Low costIts much cheaper to rent CPUs in the cloud than purchase/manage servers 2012 Autodesk When Would You Choose To Do So?Computation-intensiveNumber-crunching that needs a lot of compute power

CollaborationImplementing social or connected features would be very hard otherwise

Frequent changeUpdating a cloud app is simpler, although comes with greater responsibility

Large data setsHaving access to cloud-hosted data can be very important 2012 Autodesk Additional BenefitsCustomer intimacyYou have much better information about who is using your service

Technology abstractionCan broaden access to arcane implementations: FORTRAN 77 on iOS?

Device supportAs mentioned earlier, moving to the cloud broadens application reach 2012 Autodesk Todays ExampleTodays example will show moving a core algorithm to the cloudApollonian gasket (2D) and Apollonian packing (3D)Generates a list of contained circles or spheresWritten in F#

2012 Autodesk Choosing a cloud hosting provider 2012 Autodesk 12A lot depends on what youre afterAutodesk is a heavy user of Amazon Web ServicesLonger-term AWS may provide the best choice for Autodesk users/partnersCo-location with data, etc.

AWSs early popularity was largely due to its focus on IaaSInfrastructure-as-a-Service: you rent machines in the cloudShifting from local servers to the cloud was very easy

Microsoft is aggressively targeting SMBs with Windows AzureStarted with PaaS (Platform-as-a-Service), but more recently IaaS, tooAmazon is competing with more PaaS offeringsCode is hosted on machine instances, but abstracted behind roles 2012 Autodesk For this example were using AzureGreat integration with Visual Studio, free with MSDN subscriptionThats not to say its better for everyone

ADN has various guides covering AWS, etc.Check out their Cloud & Mobile DevBlog

Also worth looking at Google App EngineEven greater abstraction that Azure: good for highly granular, scalable tasksRecommended class tomorrow at 8amCP2568 PaaSt the Desktop: Implementing Cloud-Based Productivity Solutions with the AutoCAD ObjectARX API 2012 Autodesk Architecting for the cloud 2012 Autodesk 15Decisions, DecisionsWhat is your core business logic?Algorithms that are application- and device-independentMoving these out increases flexibility and platform independence

What kind of data needs to be transferred?Consider how best to optimize the transferWork with data already in the cloud or just transfer whats neededAre you calculating/generating data or can you use a DB/caching?

Do you need to support offline working?Some kind of local cache or processing capability may be needed 2012 Autodesk Decisions, DecisionsHow do you want to expose your services?SOAP gradually being phased out in favor of RESTful web servicesMostly this means HTTP and JSON (more on this later)If authentication needed, consider OAuth compatibility (e.g. via DotNetOpenAuth)

Which technology stack do you want to go with?Microsoft gives you a rich experienceLinux can be bring considerable efficiencies (cost and performance)

If using Microsoft, the main choices are WCF and ASP.NET Web APIWell go with ASP.NET Web API for todays exampleCheck the ADN DevBlog for more info on WCF 2012 Autodesk Considering Cloud CostsCosts can vary considerably depending on what you provisionThe cloud brings scalability, but this also applies to costsInvesting in tools to monitor and up-/down-scale instances can be beneficial

Cost scales quickly with instance sizeConsider opportunities to reduce by instance size by caching resultsData storage is relatively cheap: consider using a database

Online calculators can help (but be sure to monitor actual costs)Azure: http://www.windowsazure.com/pricingAWS: http://aws.amazon.com/calculator

2012 Autodesk The ProblemOur business logicAutoCAD-resident F# code generates Apollonian Gaskets & PackingsOriginally C++ version (for 3D) provided by a math professor in Zurich

We want to put it behind a simple, unsecured RESTful web-serviceCan be used to query 2D Apollonian Gasketshttp://apollonian.cloudapp.net/api/circles/2/2 Returns circle definitions via JSONCan be used to query 3D Apollonian Packingshttp://apollonian.cloudapp.net/api/spheres/2/2Returns sphere definitions via JSON

2012 Autodesk But First, Lets See it in ActionThe existing AutoCAD application

2012 Autodesk Building a simple web-service 2012 Autodesk 21Our Technology StackASP.NET MVC 4The latest Microsoft technology for defining and hosting web-sites/-servicesMVC Model-View-ControllerCommon architectural pattern for separating core data from UI and interactionsNot especially relevant for us: were using it for its Web API

Built against .NET 4.0 (Azure does now support 4.5)Using project template in Visual Studio 2012

Hosted on Windows Server 2008 (I think!) 2012 Autodesk

Getting StartedMake sure you haveVisual Studio 2012Windows Azure SDKASP.NET MVC 4

Most installed viahttp://asp.net/downloadsWeb Platform InstallerInstalls VS Express, too

2012 Autodesk Visual Studio 2012 Project TemplateOnline templateSearch for F# C# MVC 4Requires downloadAnd installation

Then it can be usedSelecting WebApi projectTo create the skeletonNeeds modest changes

2012 Autodesk Steps for demo:

Create project using the template (choose WebApi Project and unselect Create Tests Project)Build and run locally. Show the web-page and the service (choosing /api/values), opening the results (.json should be associated with Notepad)Change both projects in the solution to target .NET 4 (rather than 4.5)Copy content across from To Copy folderNeed to add some of the new items to the respective projects (.fs files in *WebAppApi and images in *WebApi)

24Testing the Web-Service LocallyWeb-site launched via debuggerAppend service parameters to URL/api/circles/2/2/api/spheres/2/2

Should be ready to post

2012 Autodesk Preparing to Publish to AzureFirstly we need to add a deployment project

Creates a new project in our solution

A few parameters to configure

Then ready to Publish

2012 Autodesk Publishing SettingsProject context menuSelect PublishSign in to subscriptionDownload credentials

Modify settingsAnd advanced settings

2012 Autodesk The Publish ProcessFinally hit the Publish button

Ready to test at http://apollonian2.cloudapp.net

2012 Autodesk

Windows Azure Management ConsoleTo check the web-services statushttp://windows.azure.comAlso provides cost/billing info

2012 Autodesk Calling our web-service from anywhere** AutoCAD, Android, iOS, WinRT, HTML5 & Unity 3D 2012 Autodesk 30

Calling the Web-Service From AutoCADNow that we have our web-service, we can rip out the F# codeCould also choose to leave a local capability for offline use

Otherwise the behaviour is the same 2012 Autodesk Supporting Multiple PlatformsWe could talk all day about the options for multiple platform supportNative apps on each platformCross-platform toolkitsHTML5

If youre interested in the topic, come along to the round-tableRight after this session, 3:30-5pmCP4342-R Cloud and mobile developer round-table)

Right now well see native apps on Android, iOS & WinRTAs well as one cross-platform toolkit (Unity3D) and HTML5 (via WebGL)Focus on 3D data, as its pre


View more >