NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
-
Upload
stephane-escandell -
Category
Technology
-
view
2.369 -
download
0
description
Transcript of NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
![Page 1: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/1.jpg)
NODEJS ON MICROSOFT AZUREMake your application highly available
Developer Week 2014 | #dwx142014 July, 14th-16th
![Page 2: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/2.jpg)
2
WHO’S THAT…
• STÉPHANE ESCANDELL– Technical Project Manager – Brainsonic– [email protected]
@BrainsonicParis
@sescandell
github.com/sescandell
github.com/Brainsonic
(France - Paris / Lyon)
![Page 3: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/3.jpg)
3
Microsoft Azure
![Page 4: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/4.jpg)
4
MICROSOFT AZURE HOSTING SOLUTIONS 1/3
Microsoft Azure Web Sites
Modern Web AppsFit perfectly for client and server-side project with database requirements.
High scalabitlity
Continuous developmentDeploy immediatly from your GIT repository or your TFS or via FTP (you don’t do that, isn’t it?)
Open source appsThanks to the integrated Gallery, start easily your professionnal websites via WordPress, Joomla!, Drupal, DotNetNuke or Umbraco…
![Page 5: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/5.jpg)
5
MICROSOFT AZURE HOSTING SOLUTIONS 2/3
Microsoft Azure Cloud Services (WebRole & WorkerRole)
Multi-tier applicationsFor cloud applications where you need to seperate different layers or make asynchronous processes using WebRole and WorkerRoles
Admin requirementsProvide a root access to instances with RDP connection activated.
Specific network capacitiesFor applications with specific network requirements or based on Windows Azure Connect or Windows Azure Virtual Network.
![Page 6: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/6.jpg)
6
MICROSOFT AZURE HOSTING SOLUTIONS 3/3
IAAS Microsoft Azure Virtual Machines
For existing applicationsMake your application immediately running on the Cloud with no change. Takes benefits from first Cloud Services available (SQLServer, SharePoint Server, Database, Active Directory, …)
Use Virtual disk to initiate your VMSelect one VHD from the Microsoft Azure Gallery, or use your own (Puppet capacities available)
Windows & LinuxProviding Windows Server, and Linux distributions. Connect IAAS platform to Cloud Services and get a first step in the Cloud with no changes
![Page 7: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/7.jpg)
7
HOSTING… AND SERVICES
Load balancer / endpoints LB Microsoft Azure Storage
SQL database Table storage Blob storage
Microsoft Azure Cache …
![Page 8: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/8.jpg)
8
Move NodeJS & Socket.IO on MAWS
![Page 9: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/9.jpg)
9
WHY WEB SITES?
Easy to create Open
.Net PHP JAVA NodeJS …
Easy to deploy (git push) Customizable (hook on git push)
![Page 10: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/10.jpg)
10
WEB SITES INFRASTRUCTURES
Windows Server IIS Web server « Auto-scalling » capacities
No root No RDP (only CLI available on « one » instance… but which one…, no one
knows…)
![Page 11: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/11.jpg)
11
WICH APP?
• SIMPLE CHAT APPLICATION Be able to join a room Instant notifications Gravatar integration
• SOFTWARE STACK NodeJS… of course SocketIO
![Page 12: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/12.jpg)
12
NODEJS
• NODE For those in the know
• OPEN SOURCE PROJECT Created in 2009 Built on top of V8 (Chrome’s Javascript Runtime)
• NODE IS A C SOFTWARE Running as a dameon for today sample Event-driven (did you see the presentation this morning?) Non-blocking I/O
![Page 13: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/13.jpg)
13
SOCKET.IO
JAVASCRIPTREALTIME
WEB
APP
BI-
DIR
EC
TIO
NN
AL
WEBSOCKETS
UNIFIED API
NO
DEJS
FALLBACK
EVENT DRIVENASYNCHRONOUS
OPEN SOURCEBROADCASTING
CLIE
NT
SER
VER
WR
APPE
R
DATA
AJA
X
CROSS PLATFORM
MULTI-CLIENTBi-directionnal communication
Emit message
Broadcasting
![Page 14: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/14.jpg)
14
HOW IS THE APP WORKING?
connect()
connect
load
peopleInChat
login
imgparticipantJoined
msgreceive
Login process
Notify users
Chat
loop
Notify users
![Page 15: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/15.jpg)
15
Let’s see it…
![Page 16: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/16.jpg)
16
MOVE ON AZURE WEB SITES
# http://azure.microsoft.com/en-us/documentation/articles/xplat-cli/$> npm install azure-cli –g$> azure account download$> azure account import <file.publishsettings>
• PREPARE YOUR ENVIRONMENT Executed once Secure access to your portal
• USE IT AS YOU PREFERE Portal: http://manage.windowsazure.com (preview: http://portal.azure.com ) Rest API Cross Platform CLI (based on Rest API integrated via NodeJs)
![Page 17: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/17.jpg)
17
MOVE ON AZURE WEB SITES
• GET THE SERVERS DevOps friendly!!!
# And deploy$> git push azure master
![Page 18: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/18.jpg)
18
MOVE ON AZURE WEB SITES
• ACTIVATE WEB SOCKETS Because of SocketIO
# CLI version$> azure site set –w dwx2014demo
![Page 19: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/19.jpg)
19
Be scalable and highly available
![Page 20: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/20.jpg)
20
WHAT’S WRONG?
Messages are not broadcasted to other « socket.io instances »
Participants storage is not shared (informations missing)
1
1 1? ?
2
2 2 2
![Page 21: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/21.jpg)
21
TARGETED SOLUTION
Participants storage uses Azure Table Storage service(a Key-Value storage based)
Sockets connectoruses Azure Service Bus service(an AMQP compliant messagebroadcaster)
App endpoint via Azure Web SitesActs as a Load Balancer
One instance
![Page 22: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/22.jpg)
22
Great, let’s do it
![Page 23: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/23.jpg)
23
AZURE SERVICE BUS & NODEJS… LET’S ENTER REDIS
• INTEGRATION BROKEN WITH NODEJS Because of NodeJS / dependencies updates Issue created on Github:
https://github.com/Azure/azure-sdk-for-node/issues/1255
Deploying fix… socket.io-adapter for Service Bus coming soon:
https://github.com/brainsonic/socket.io-azureservicebus
• NEED A « PLAN B » Redis as a Service Fully integrated into Azure Master / Slave Preview… but free! Using https://github.com/automattic/socket.io-redis
![Page 24: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/24.jpg)
24
OUR NEW ARCHITECTURE
Participants storage uses Azure Table Storage service(a Key-Value storage based)
Sockets connectoruses Azure Redis Cache service(and pub/sub capacities)
App endpoint via Azure Web SitesActs as a Load Balancer
One instance
![Page 25: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/25.jpg)
25
You’d better have the right
recipe to make the
right magic potion
![Page 26: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/26.jpg)
26
I/O ABSTRACTION
Should be required
Create common interfaces (Javascript doesn’t natively support Interface, so define team rules or create specific tests)
Dependency Injection Data storage File system / storage Event manager … all your I/Os
![Page 27: NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014](https://reader035.fdocuments.in/reader035/viewer/2022062405/55860a3ed8b42a3d6b8b4ba3/html5/thumbnails/27.jpg)
27
YOU HAVE QUESTIONS…
… I can try to answer them…