full stack-development with node js
DESCRIPTION
Recall: n-Layer Code Structure & Org Structure What’s NodeJS Who are applying NodeJS Why considering NodeJS for Ctrip Risks & Issues Demo & QATRANSCRIPT
Full-Stack-Development with NodeJS
携程 Mobile/Online 应用场景分析
Agenda
• Recall: n-Layer Code Structure & Org Structure
• What’s NodeJS
• Who are applying NodeJS
• Why considering NodeJS for Ctrip
• Risks & Issues
• Demo & QA
n-Layer Distilled – Tech Stack
Technology Center
e-Commerce System (frontend + backend)
Controllers, Svc Proxies
Presentation Layer
Application Layer
Domain Layer
Infrastructure Layer
Aspx/ServletHTML/JS
Ascx/Taglib/JSF
DAL Fx/Svc, Data Access Layer, etc.
ADO.NET, JDBC, ORM, etc.
Framework, Utils, etc.
JobWS Svc Proxies
FrontEnd BackEnd
SOA/Asmx/WCF/Servlet/RESTful SvcUtils
OOD & DDD
WinSvc
Code Arch to Org Arch – Ctrip Samples
• Ctrip Flight Dev Team– Frontend Presentation + Application– Backend API (SOA) + Domain + Data
• Ctrip Hotel Dev Team– Data Dev Team DB/SQL/Repl/DAL
• Ctrip Fx Dev Team– Frontend Presentation + Application– Backend API (RESTful) + Domain + Data
Code Arch to Org Arch – Int’l Flight Team
GDSConnectors
GDS Amadeus Sabre Galileo 中航信
Every App分销Online Offline无线
APPSNS航空公司
资源共享平台 API
预订订单搜索 出票查询 配送 其它
Presentation Layer (View)
Application Layer (Controller)
Domain Layer (API)
Infrastructure Layer (internal)
Infrastructure Layer (external)
Frontend Dev Team
Backend Dev Team
Agenda
• Recall: n-Layer Code Structure & Org Structure
• What’s NodeJS
• Who are applying NodeJS
• Why considering NodeJS for Ctrip
• Risks & Issues
• Demo
What’s NodeJS
• 2009.5 Ryan Dahl 发布于 GitHub ,总排名 #3
• 基于 Google V8 引擎的 Web & Socket Server
• 使用 Javascript 编写服务端代码,前后通吃
• Single Thread, Event Driven, Non-blocking IO
• Light-weight, Scale-out, Cluster-enabled
• 接近 70,000 NPM (Node Packaged Modules)• 成熟的社区,热情贡献者, Full-Stack 呼声
Who are applying NodeJS ( 国外 )
• LinkedIn– 2012.10 将所有移动应用服务从 Ruby on Rails 迁到 NodeJS
• Groupon– 2013.10 将所有应用从 Ruby on Rails 迁到 NodeJS
• eBay– 2012.3 在 GitHub 发布 ql.io 框架,可认为是 Service Aggregator– 2013.5 发布第一个线上 NodeJS 项目
• PayPal– 2012.4 使用 NodeJS 在 6 周内完成支付系统重写– 2013.1 在 GitHub 发布 Kraken 框架,两年内将大规模使用
• Walmart 2014 年底电商平台全上 NodeJS
• Google, Yahoo, Netflix, AWS, Azure, etc.
Who are applying NodeJS ( 国内 )
• 淘宝– 淘宝指数、数据魔方、时光机– CNodeJS 社区
• 网易– 2012.11 在 GitHub 发布 pomelo 框架– 移动推送、 Web 推送采用 pomelo 框架构建
• 腾讯推送、百度推送、搜狐推送、新浪微博 DB Proxy
• 去哪儿、点点、花瓣、雪球、小米手机销售、 etc.
• 携程 DVF RESTful API 、 Real-Time Crawler (Open House)
携程最新进展:
1 、框架已构建 Ctrip NPM Repository
2 、 Clog via edge, SOA via Node native
3 、门票 v5.8 H5/Hybrid 接入 NodeJS
Agenda
• Recall: n-Layer Code Structure & Org Structure
• What’s NodeJS
• Who are applying NodeJS
• Why considering NodeJS for Ctrip
• Risks & Issues & Countermeasure
• Demo
Why considering NodeJS for Ctrip• 高性能,可减少服务器 (non-blocking IO, IOCP on Windows)
• 开发效率高,减少集成 (Same Javascript + Less Integration)
• 易于修改和维护 ( 由管道连接小模块构成 )
• DRY Principle : View & Controller 共用一套验证逻辑
• Frontend == View + Controller , Controller 是短板
• Controller == Model (SOA 1.0/2.0) Composing & Tailoring
• 适合 IO-intensive 场景,不适合 CPU-intensive 场景
• 机票、酒店已做前后端分离,可在前端团队尝试
• 强烈建议看这篇文章:淘宝基于 NodeJS 全栈开发
Frontend & Backend – Tech Stack
Risk & Issue & Countermeasure
• 思想理念的转变 Controller from C# to JS
• 团队分工的转变 Frontend Full-Stack-Engineer and Full-Stack-Development
• 同步开发模式 异步开发模式 + 严格异常处理
• 框架支持 Clog 、 SOA 已验证没问题,可稳定运行 (demo) , Cfx 需扩展,但不动核心, CI 原生支持
• 运维支持 NodeJS module for Zabbix
• 其它 SOA 支持 NodeJS module for SOAP/REST
• NodeJS & NPM 框架 & 系统研发 (C/C++/Driver 支持 )
Demo #1 – ql.io for service composing & tailoring
Demo #2 – Send log via Clog .NET client
Demo #3 – Send log via SOA 2.0 client
Demo #4 – Visit .NET Service via SOAP
Demo #5 – One rule set via nools run @ both node-side and browser-side
Demo #6 – One js via browserify run @ both node-side and browser-side
Q & A