Best Practices for CouchDB Developers on Windows Azure Brian Benz, Sr. Technical Evangelist Microsoft Open Technologies, Inc.
[email protected] bbenz@Microso ft.com
Agenda •
•
•
•
•
•
App Demo Windows Azure CouchDB Windows Azure Virtual Machines Windows Azure Web Sites ptions for wor!ing wor !ing with Azure VMs and Web Sites
•
"nder the hood of the app# $ode%&s –
–
•
'runt
()A
Demo Conference Scheduling Conference App
Windows Azure* Virtual Machines* Web Sites*
CouchDB* node%&s* grunt
Demo +in! http#,,a-&amepi-conf-couchdb-twitter%azurewebsites%net,. home,schedule
https#,,github%com,a/emclion,conference
Conference Scheduler •
•
Attendees can trac! sessions* vote sessions up and down 0ine Capabilities –
•
•
1nde/edDB
CouchDB VM for Data Storage Web site hosting the application –
–
$ode%&s 'runt
Demo Architecture WAWS Windows Azure Virtual Machine Node.js app: •
• •
Store and 2etrieve Schedule 3ilter b4 criteria Store in CouchDB
CORS-SERV
CouchDB
Browser app $ode%&s 'runt
Windows Azure in 56 Seconds A brief high-level overview for those who are new to Windows Azure
Cloud Computing Pac!aged Software
1nfrastructu re 8as a Service9
Applicatio ns Data 2untime e g a n a
Middlewar e ,S
m u o 7 Virtualizatio
Applicatio ns Data e g a n a 2untime m u o 7 Middlewar
n Servers Storage
Storage
$etwor!in g
$etwor!in g
Software
8as a Service9
8as a Service9
e g a Applicatio n a ns m Data u o 7
Applications Data
2untime Middleware
e ,S Virtualizatio n Servers
Platform
,S M a n a g e d b 4 v e n d o r
Virtualizatio n Servers Storage $etwor!ing
2untime M a n a g e d b 4 v e n d o r
Middleware ,S Virtualizatio n Servers Storage $etwor!ing
M a n a g e d b 4 v e n d o r
Azure## What 1t 1s Windows Azure Win·dows·Az·ure :win-dohz-azher; Noun: A comprehensive set of services that enable 4ou to <uic!l4 build* deplo4 and manage applications across a global networ! of Microsoft-managed Microsof t-managed datacenters% ==%=>? Monthl4 Monthl 4 S+A S+ A datacenters% Pa4 onl4 onl4 for for what 4ou use
Azure## What 1t 1s Windows Azure
3le/ible
pen
Solid
Azure## What 1t 1s Windows Azure
'lobal 3ootprint
Azure## What 1t 1s Windows Azure
Virtual Machines
Cloud Services
Web Sites
Azure## What 1t 1s Windows Azure
Flexible
Azure## What 1t 1s Windows Azure
@ost
1aaS
Build
Consu me
Paa
Saa
S
S
'etting Started Sign up for a free trial
http#,,www%windowsazure%com,en-us,pricing,free-trial,
+earn about the latest features
http#,, http#,,channel=%msdn%com, channel=%msdn%com,vents,Win vents,WindowsAzur dowsAzureConf,6,76 eConf,6,76
+ CouchDB on Windows Azure provides all the beneEts customers have come to e/pect from cloud computing# elasticit4* on-demand capacit4* faster time to mar!et* and p pa4-for a4-for-what-4ou-use pricing% •
•
CouchDB oFers built-in support for horizontal scaling Windows Azure oFers built-in support for responsive auto-scaling
Clusters# @igh Availabilit4 7ourr 7ou Application
Cluster Driver Primar4 Secondar 4 Secondar 4 Clustered nodes hosted on Windows Azure wor!er roles or virtual machines
Virtual Ma!ines Deplo4ing CouchDB on Windows Windo ws Azure virtual machines
Windows Azure Virtual Machines "buntu %6H CentS 5% penS"S % S"S +inu/ nterprise Server SP Windows Server 66G 2 Windows Server 6
Virtual Machine Sizes VM Size
CP" Cores
/tra Small
Shared J5G MB
Small
%J> 'B 66
Medium
K%> 'B
66
H
+arge /tra +arge
H
J 'B
H66
G
G
H 'B
G66
5
Memor4
Bandwidth . Data 8Mbps9 Dis!s >
ach Persistent Persistent Data Dis! Can be up to IB
Deplo4ing to Virtual Machines –
–
–
–
–
–
–
Compared to wor!er role 8PaaS9* VM-based clusters oFer more control* control* as well as more responsibility Create new Virtual Machine L Windows 6 Start or install a Browser Download CouchDB 2un the 1nstaller and +aunch Start 3uton to verif4 install Also available# 1nstall Scripts Windows Azure 66G 1mages# •
http #,,ossonazure%interoperabi #,,ossonazur e%interoperabilit4bridges%com,a lit4bridges%com,articles,couchdb rticles,couchdb
-installer-for-windows-azure
VM Depot http#,,vmdepot%msopentech%com Call to ation: Developers can use VM Depot to reach new audiences
–
Windows Azure Developer Center •
pen-source SDs for popular programming languages* to get 4ou up and running <uic!l4
CouchDB drivers#
%$I driver $ode%&s driver Nava Na va dr drive iverr P@P driver
•
•
Choice of popular 1Ds such as Visual Studio
P4thon driver
and clipse
page
Driver download
Consistent 2SI protocols and AP1s across Windows Azure services
http#,,www%windowsazure%com,en-us,develop,over
view,
Command +ine S4nta/ verview prompt>
azure
topic
verb
account account location account affinity-
download import list
group vm vm disk vm endpoint vm image service service cert site config
show delete start restart shutdown capture create attach detach browse set
options
username password dns-prefix vm-name lb-port target-imagename source-path disk-image-name size-in-gb thumbprint value -v -vv
/ample# Provisioning a Cluster azure vm create couchsd "OpenLogic__OpenLogic-CentOS-!"OpenLogic__OpenLogic-CentOS-!!#!$%#-en-us-%&'(vhd" username password -l ")est *S" -e -l azure vm create couchsd "OpenLogic__OpenLogic-CentOS-!"OpenLogic__OpenLogic-CentOS-!!#!$%#-en-us-%&'(vhd" username password -l ")est *S" -e -l !% -c "OpenLogic__OpenLogic-CentOS-!azure vm create couchsd "OpenLogic__OpenLogic-CentOS-!!#!$%#-en-us-%&'(vhd" username password -l ")est *S" -e -l !+ -c a,ure vm endpoint create couchsd !# !# a,ure vm endpoint create couchsd-! !#. !#. a,ure vm endpoint create couchsd-% !#/ !#/
VM Mana"e#ent and Auto#ation Active Director4 'roup Polic4 Windows 2emote Management 8Win2M9 SCM 6 Support for Managing Virtual Machines 3ull 2SI AP1 for Programmatic Automation and Management Windows Azure PowerShell Cmdlets Cross Platform Scripting 8+inu/* Mac and Windows9 Windows Azure Monitoring Service 8n 2oadmap9
Sriptin" Capa$ilities Automation Support • •
Windows Azure PowerShell Cmdlets Cross Platform Scripting Built on node%&s
Capabilities • • • • • •
•
Provisioning* 2emoval 2eboot* Start 1mport VMand settings for /port Windows +inu/ VMs Supportand Provision sion for Windows Domain Noin at Provi 3ull4 Customize VM with Data Dis!s and ndpoint ConEguration
Automate Virtual $etwor! Settings
%aaS and SaaS Deplo4ing CouchDB as Cloud Services and Software-As-A-Service
Deplo4ing CouchDB as a Cloud Service –
–
–
–
–
–
Windows Azure cloud services run on a full4 automated* highl4 scalable cloud platform ngoing management of the S and infrastructure is handled b4 Windows Azure 1nEnitel4 scalable* on demand App and CouchDB in same cloud service provides securit4 PaaS approach is the easiest way to deploy CouchDB on Windows Azure 3or <uic! and simple deplo4ment* use the CouchDB on Azure Wor!er 2ole 1nstall# http#,,ossonazure%interoperabilit4bridges%com, http#,,ossonazure%interope rabilit4bridges%com,ar ar
ticles,couchdb-installer-for-windows-azure.hSec
•
•
3ounded Ma4 66G Database-as-a-service 8DBaaS9 –
–
–
•
•
Managed* hosted for! of CouchDB 1ncremental Map2educe engine @orizontal scaling ) built-in +ucene search
G Cloudants are committers to Apache CouchDB K*666O users
KK
Cloudants Commitment to Apache CouchDB •
•
>? of Apache CouchDB pro&ect committers wor! at Cloudant Apache CouchDB roadmap –
&i"Cou!# @orizontal scaling &i"Cou!# framewor! based on Amazon D4namo paper folding into the ne/t Apache release 'au(ton## 3uton replacement 'au(ton modular CouchDB Web dashboard live NS$ editor with •
•
–
•
•
NavaScript hinting
KH
@4brid Approaches Combining hosted services* cloud applications* and onpremises applications
7our our App 7
7our our Data 7
)aaS Virtual Machines
)aaS Virtual Machines
%aaS Cloud Services
%aaS Cloud Services
%aaS Web Sites
SaaS 'it Deplo4ments
ther sites* local apps* etc%
Self-hosted
Which approach is best for Deplo4m ent Comple/i t4
youQ you Q perational 2esponsibili 3le/ibilit t4 4
S
Securit 4
)aaS
Some
@igh
@igh
+inu/ or Windo ws
%aa S Saa S
Some
+ow
@igh
Windo Built-in ws onl4
+imited
$,A
+ow,none
$one
Custom
Built-in
We$ Sites Deplo4ing Web Sites on Windows
Windows Azure 7 7our our Datacenter
Virtual Machines
Cloud Services
Web Sites
Applications
Applications
Applications
Applications
Data
Data
Data
Data
3irewall
3irewall 2ules
3irewall 2ules
$etwor!
Virtual $etwor!
Virtual $etwor!
,S
,S
Virtualization @ardware
3ocus on the Application
Windows Azure Web Sites powerful web sites in seconds
start simple
code smart
go live
start free* scale up and out as 4ou go* friction-free and without the headaches
with classic asp* asp%net* php or node%&s* develop on Windows* SR or +inu/
deplo4 live in seconds* easil4 monitor performance* performance* rapidl4 diagnose and E/ issues
shared web sites
reserved
shared S*ARE )NS,ANCES
#-9
web sitesshared
shared S*ARE )NS,ANCES
#-9 #-9
reserved
web sitesshared
6
reserve d S*ARE )NS,ANCES
RESERVE )NS,ANCE
#-9 #-9
reserved
#-9
shared web sites
reserved
reserve d RESERVE R ESERVE )NS,ANCE
#-9
web sitesshared
reserved
reserve d
RESERVE )NS,ANCE RESERVE )NS,ANCE
#-9
#-9
#-9
#-9
#-9
#-9
#-9
#-9
Supported Web 3ramewor!s
Bring 4our own runtime
Supported Publishing Methods
',%:
,'S
WE&E% O/
s r e n t r a p
Windows Azure Web Sites
start simple
code smart
go live
Start Simple 'et started with 01 2ree web sites Create new sites in seconds asil4 manage and scale 4our sites Automatic load balancing and shared storage across instances Scale out or up to reservedand instances for improved performance scale
Code Smart "se ASP%$I* ASP* P@P* $ode%&s or Custom S(+ Azure or M4S(+ databases Start with open source apps Develop with VS and WebMatri/ Supports an4 Web development tool on an4 platform 8Windows* SR* +inu/9
'o +ive 2apid deplo4ment for <uic! iteration 1ntegrated source control with Ieam 3oundation Server 8I3S9 and 'it Built-in monitoring of perf and usage data (uic! access to re<uest logs* failed re<uests diagnostics and diagnostics
Node.js and 3runt Deplo4ing Web Sites on Windows Azure Web Sites
What is $ode%&sQ •
A NavaScript runtime environment Server-side NavaScript Server-side Compiled for speed Command line NavaScript AP1 for networ! and Ele s4stem access acc ess
–
–
–
–
•
Designed for high concurr concurrenc4 enc4 –
•
•
vents* not threads or processes
$ever bloc!s* not even for 1, "ses CommonNS framewor! s4nta/ –
Close to real
W!4 5se Node.js 6 •
•
NavaScript on server-side server-side and client-side vent loop with a stac! –
–
•
$ode%NS serves re<uests re<uests in an event loop +arge number of simultaneous re<uests%
Avoids Conte/t Switching –
Waiting for 1, or S4nchronization operation to complete%
•
$ode attaches NS callbac!s to 1, re<uests Ihe Tevent drivenU drivenU part When the original 1 is completed* a callbac!
–
–
to the server completes the re<ues re<uest% t%
Speed4 1, With vents Threads
Events
Threads lock apps / threads
One thread
Listens fo for in incoming rre equests
Process from q qu ueue
Multiple threads dependent on multiple processes
State saved for each event
Depends on context switching
ot dependent on !/O or S"nchroni#ation
$ode%&s with 'runt •
$ode%&s - Scalable* vent-Driven @IIP server NavaScript and simple AP1
–
•
'runt on $ode%&s –
Deplo4mentt and Ias! Managemen Deplo4men Managementt
Application Scenarios We$ Sites
Cloud Ser7ies
Virtual Ma!ines
Modern web apps
Multi-tier applications
nterprise server applications
Perfect 4our app consists ofside client side mar!upifand scripting* server scripting and a database% Powerful capabilit4 to scale out and up as needed%
Cloud-based applications that tiers separate application logic into multiple 8i%e% caching middle tier* as4nchronous bac!ground processes li!e order processing9 using both Web and Wor!er 2oles
2un 4our e/isting applications the cloud* such asenterprise S(+ Server* SharePointin Server or Active Director4% Director4%
Continuous development
Apps that re<uire advanced administration
Porting e/isting line of business apps
Cloud-based applications that re<uire admin access* remote des!top access or elevated permissions
Choose an image from the librar4 or upload 4our own V@D%
Apps that re<uire advanced networ!ing
Windows or +inu/ operating s4stem
Cloud-based applications that re<uire networ! isolation for use with Windows Azure Connect or Windows Azure Virtual $etwor!
Support for Windows Server* along with communit4 and commercial versions of +inu/% Connect virtual machines with cloud services to ta!e full advantage of PaaS services%
Deplo4 directl4 from 4our source code repositor4* using 'it or Ieam 3oundation Service%
Popular open source apps +aunch a professional loo!ing site with a few clic!s using apps li!e WordPress* Noomla Noo mla* * Dru Drupal pal** Dot$ Dot$et$ et$u! u!e e and and "mbraco
ther 2esources •
•
•
•
•
•
•
•
•
•
•
•
•
•
Microsoft pen Iechnologies Blog# http#,,blogs%msdn%com,b,interoperabilit4 VM Depot# http#,,vmdepot%msopentech%com Windows Azure development# www%WindowsAzure%com www%WindowsAzure%com SDs and Command +ine Iools# http#,,www%windowsazure%com,en-us,downloads, Windows Azure Iraining it# http#,,windowsazure-training!it%github%com, #,,windowsazure-training!it%github%com, http Microsoft Web Platform 1nstaller# http#,,www%microsoft%com,web,downloads,platform%asp/ Web Matri/ http#,,www%microsoft%com,web,webmatri/, Pro&ect udu https#,,github%com,pro&ect https#,,github%com,pro&ect!udu, !udu,!udu !udu Ihe application 1 showed toda4 https#,,github%com,a https#,,github%com,a/em /emclion,confere clion,conference nce
89 A