Codestrong 2012 breakout session building your own custom cloud services

Preview:

Citation preview

Node.ACSAppcelerator Custom Cloud Services

Wei KongDirector of Engineering, Cloud Services

Appcelerator Inc.@baobeimm

wkong@appcelerator.com

Appcelerator Cloud Services (ACS) as Instant Mobile Backend

• Easy to use

• Cross Platform (REST Api based)

• Predefined object models

• Custom Objects and Fields

• No Server Code Needed

The Good

• Custom Code

• Web Hosting

• Support of Custom URLs

• Can have extra overhead with the network and battery consumption

What’s Missing

Introducing Custom Cloud Services (Node.ACS)

• Complete Solution to your Mobile Backend

• JavaScript for both Client and Server

• Fully Integrated with ACS

Node.js + ACS

JS

• Use JavaScript to write Web Servers

• Based on Google’s V8 Engine

• Event-driven/None-blocking IO

• Lightweight and efficient

• More at http://nodejs.org

Node.js in a Nutshell

• Performance and Scalability

• Easy to Integrate Network Components

• JavaScript

Why Node.js

Node.ACS Architecture

ACS Network Layer

ACS

Test Locally

Create a app

Publish to Node.ACS Cloud

Set Custom CnameEx. http://www.yourapp.com

The Development Flow

Unpublish

Multiple Versions

V1

V2

V3

Device (v1)

Device (v2)

Device (v3)

Latest

your app

Demo and Sample Code

Web Server

Sample web server to display your

app data stored in ACS

var user = { session:"",};api.login = function(req, res) {

if(user.session === ""){ ACS.Users.login({login: req.body.un,password: req.body.pw}, function(e) { if(e.success && e.success === true){

user.session = e.meta.session_id;}else{

res.redirect(version+'/index?msg='+e.message); } }, req, res); }else{ res.redirect(version+'/show'); }}

What’s wrong?

Websocket

A group chat app

based on websocket

websocket.message = function(data, socket) {socket.broadcast.emit('message', data);

};

Group Chat

// Received a message iosocket.on('message', function(message) {

// Display the message});

// User types a message$('#outgoingChatMessage').keypress(function(event) {

iosocket.emit('message', $('#outgoingChatMessage').val());}

Server Code

Client Code

Roadmap

• One free Node.js Worker/app

• 100M Free disk space/app

• Unlimited API calls

What’s in Preview

• Background job workers

• Node.js Monitoring

• More 3rd party services integrations

• Web Console

• Flexible free tier

• Auto sleep and reactivation

Coming Soon

Wei Kong@baobeimm

wkong@appcelerator.com

Recommended