SlideShare a Scribd company logo
1 of 44
Download to read offline
Java/Spring과 Node.js의 공존
Java/Spring 전성시대에 Node.js가 살아남는 법
Dongsu Jang <iolothebard at gmail dot com>
TOC
• BEGIN
• AS-IS
• TO-BE
• VS
• CODE
• END
BEGIN
JUST FOR FUN
개발자여,
불가능한 꿈을 꾸어라
• java8, tomcat8, spring-boot,
spring-cloud, jpa…
• mongodb, cassandra, couchbase,
elasticsearch…
• python, ruby, scala, rust, clojure,
julia…
• docker, kubernetes, mesos,
microservices…
• nginx, redis, play framework, akka,
spark, node.js, django, flask…
• angular, react, EcmaScript6…
• IE8 없는 세상…
그러나,
리얼리스트가 되라
• 현실은 자바 천국…
• 스프링 전성 시대…
• 봄날은 생각보다 오래 가더라…
• “관리가능”한 아키텍쳐의 무거움
• 배포할 줄 아는 마지막 개발자가 퇴사
했어요 OTL
• 지금 서비스 하는 버전이 svn 에 있는
거 보다 더 최신인데요 -_-;
• 롤백할께요 ㅠ,.ㅠ
• 서버 늘려야겠죠? 구매 요청할께요 ^^;
• IE8 테스트할 PC가 없어요? XP요~
그래도…
재밌는 거 해보고 싶어요!
AS-IS
AS GOOD AS IT GETS
AS-IS
• Java 5.x/6.x/7.x… with Tomcat
5.x/6.x/7.x…
• Apache Web Server with mod_jk/
jk2/webapp…
• Spring Framework with Spring-
WebMVC/Struts…
• Template Engine: JSP/Velocity/
Freemark…
• DAO: MyBatis/Hibernate/JDBC…
• Cache: EHCache/OSCache/Map…
• RDBMS: Oracle/MySQL…
AS-IS
tomcatapache
webapp
(war)
MySQL
tomcat
…
mod_jk
apache
…
webapp
(war)
mod_jk MySQL
AJPHTTP
AS-IS
Spring Framework
with Spring-WebMvc/Struts…
JVM
Template Engine
JSP/Velocity/Freemarker…
DAO
JDBC/MyBatis/Hibernate…
Cache
EHCache/OSCache/Map…
Tomcat Servlet Container
Model View Controller
TO-BE
STAY HUNGRY STAY FOOLISH
TO-BE
• Node.js
• Express
• Thrift
• Redis
• React
• 원래 있던 거…
TO-BE
tomcatapache
webapp
(war) MySQL
tomcat
…
mod_jk
apache
…
webapp
(war)mod_jk MySQL
node.js
API
server
+ @
redis
pm2
nginx
React
Server
React
Client
node.js
…
thrift
AJPHTTP
+ @
+ @
TO-BE
java
Thrift Server
(thrift/swift/nifty)
Thrift Client
(node-thrift)
node.js
RESTful API Server
Isomorphic
Rendering Server
원래 있던 거…
(war)
Single Page
Webapp
browser
express
react
browerify,
babel,
…
react
VS
I WANT TO BELIEVE
tomcat-spring-webmvc
100 concurrent user표 1
Label # Samples Average Min Max Std. Dev. Error % Throughput KB/sec Avg. Bytes
forum_list 1000 4 0 757 41.15 0% 35.9 32.95 939
login_post 1000 13 1 120 30.97 0% 36.9 30.72 852
post_list 1000 12 2 116 12.68 0% 36.9 667.9 18510.5
post_view 1000 7 2 117 8.32 0% 37 335.97 9301.4
post_save 1000 27 4 145 32.91 0% 37 716.45 19836.4
comment_save 1000 21 3 133 31.21 0% 37 364.2 10083.9
TOTAL 6000 14 0 757 29.78 0% 204 1975.94 9920.5
tomcat-spring-webmvc
100 concurrent user
nodejs-express-thrift
100 concurrent user표 1
Label # Samples Average Min Max Std. Dev. Error % Throughput KB/sec Avg. Bytes
forum_list 1000 3 0 420 20.68 0% 37 17.03 471.6
login_post 1000 16 1 248 34.76 0% 37.5 10.16 277
post_list 1000 2 0 113 5.2 0% 37.8 308.3 8361.9
post_view 1000 1 0 107 3.55 0% 37.8 12.61 342
post_save 1000 7 1 109 15.51 0% 37.8 8.93 242
comment_save 1000 8 1 105 17.43 0% 37.8 8.93 242
TOTAL 6000 6 0 420 19.82 0% 209.9 339.39 1656.1
nodejs-express-thrift
100 concurrent user
애고…
의미없다~
tomcat-spring-webmvc
500 concurrent user표 1
Label # Samples Average Min Max Std. Dev. Error % ThroughputKB/sec Avg. Bytes
forum_list 5000 782 1 7142 849.82 0% 25.6 23.49 939
login_post 5000 1453 1 10011 1361.53 0% 25.7 21.38 852
post_list 5000 2539 2 13975 2293.41 0% 25.7 2229.89 88919.8
post_view 5000 1678 2 11447 1617.18 0% 25.7 1067.33 42560.5
post_save 5000 3512 5 14182 2853.35 0% 25.7 2384.92 95178.4
comment_save 5000 2726 4 15547 2247.67 0% 25.7 1154.3 46070.7
TOTAL 30000 2115 1 15547 2181.63 0% 152 6793.39 45753.4
tomcat-spring-webmvc
500 concurrent user
nodejs-express-thrift
500 concurrent user표 1
Label # Samples Average Min Max Std. Dev. Error % ThroughputKB/sec Avg. Bytes
forum_list 5000 17 0 407 36.84 0% 145.3 66.91 471.6
login_post 5000 58 1 937 79.5 0% 146.5 39.63 277
post_list 5000 38 0 976 89.75 0% 147.5 6517.04 45252.7
post_view 5000 15 0 724 39.26 0% 147.4 49.23 342
post_save 5000 39 1 722 60.66 0% 147.4 34.83 242
comment_save 5000 44 1 969 72.13 0% 147.5 34.85 242
TOTAL 30000 35 0 976 67.72 0% 831 6333.24 7804.5
nodejs-express-thrift
500 concurrent user
CODE
SHOW ME THE CODE
springboard
forums
comments
posts users
게시판!
ㅋㅋㅋ
springboard
/forum_list
/signup
/post_list /post_view
/login
/post_form /comment_save/post_save
원래 있던거…├── src
│   ├── main
│   │   ├── jaja
│   │   │   └── kr
│   │   │   └── iolo
│   │   │   └── springboard
│   │   │   ├── Comment.java
│   │   │   ├── Forum.java
│   │   │   ├── Post.java
│   │   │   ├── Springboard.java
│   │   │   ├── SpringboardImpl.java
│   │   │   ├── User.java
│   │   │   ├── controller
│   │   │   │   ├── CommentSaveController.java
│   │   │   │   ├── ForumListController.java
│   │   │   │   ├── LoginController.java
│   │   │   │   ├── PostFormController.java
│   │   │   │   ├── PostListController.java
│   │   │   │   ├── PostSaveController.java
│   │   │   │   ├── PostViewController.java
│   │   │   │   └── SignupController.java
│   │   └── resources
│   │   └── templates
│   │   ├── forum_list.html
│   │   ├── login.html
│   │   ├── post_form.html
│   │   ├── post_list.html
│   │   ├── post_view.html
│   │   └── signup.html
안봐도
비디오~
Thrift Server
<dependency>

<groupId>org.apache.thrift</groupId>

<artifactId>libthrift</artifactId>

<version>0.9.3</version>

</dependency>

<dependency>

<groupId>com.facebook.swift</groupId>

<artifactId>swift-annotations</artifactId>

<version>0.15.1</version>

</dependency>

<dependency>

<groupId>com.facebook.swift</groupId>

<artifactId>swift-codec</artifactId>

<version>0.15.1</version>

</dependency>

<dependency>

<groupId>com.facebook.swift</groupId>

<artifactId>swift-service</artifactId>

<version>0.15.1</version>

</dependency>

<dependency>

<groupId>com.facebook.nifty</groupId>

<artifactId>nifty-core</artifactId>

<version>0.15.1</version>

</dependency>
IDL 작성하기 귀찮으니
facebook-swift!!
Thrift Server
├── src
│   ├── main
│   │   ├── java
│   │   │   └── kr
│   │   │   └── iolo
│   │   │   └── springboard
│   │   │   ├── ...
│   │   │   ├── SpringboardApplication.java
│   │   │   ├── cache
│   │   │   │   ├── CacheService.java
│   │   │   │   ├── DummyCacheService.java
│   │   │   │   └── RedisCacheService.java
│   │   │   └── thrift
│   │   │   ├── TComment.java
│   │   │   ├── TForum.java
│   │   │   ├── TPost.java
│   │   │   ├── TSpringboard.java
│   │   │   ├── TSpringboardImpl.java
│   │   │   └── TUser.java
│   │   └── resources
│   │   ├── config
│   │   │   └── application.properties
│   │   ├── logback.xml
│   │   ├── static
│   │   │   └── index.html
설정하기 귀찮아서
spring-boot
성능테스트를 위해
redis
Node.js 와의 통
신을 위해
thrift!!!
Thrift Server
import com.facebook.swift.service.ThriftMethod;

import com.facebook.swift.service.ThriftService;



import java.util.List;



@ThriftService("Springboard")

public interface TSpringboard {



@ThriftMethod("getUsers")

List<TUser> getUsers();



@ThriftMethod("getUserByUsernameAndPassword")

TUser getUserByUsernameAndPassword(String username, String password);



@ThriftMethod("getUser")

TUser getUser(int userId);



/* . . . */



@ThriftMethod("createComment")

int createComment(TComment post);



@ThriftMethod("updateComment")

boolean updateComment(TComment post);



@ThriftMethod("deleteComment")

boolean deleteComment(int commentId);



}
IDL 작성하기 귀찮으니
facebook-swift!!
Thrift Server
import com.facebook.swift.codec.ThriftField;

import com.facebook.swift.codec.ThriftStruct;



@ThriftStruct("Comment")

public final class TComment {



private int id;

private int userId;

private int postId;

private String content;

private String createdAt;



@ThriftField(1)

public int getId() { return id; }



@ThriftField(2)

public int getUserId() { return userId; }



/* . . . */



@ThriftField

public void setId(int id) { this.id = id; }



@ThriftField

public void setUserId(int userId) { this.userId = userId; }



/* . . . */



}
IDL 작성하기 귀찮으니
facebook-swift!!
Thrift Serverimport com.facebook.nifty.processor.NiftyProcessor;

import com.facebook.swift.codec.ThriftCodecManager;

import com.facebook.swift.service.ThriftServer;

import com.facebook.swift.service.ThriftServerConfig;

import com.facebook.swift.service.ThriftServiceProcessor;

import kr.iolo.springboard.thrift.TSpringboard;



@SpringBootApplication

public class SpringboardApplication {



@Autowired TSpringboard springboard;



public static void main(String[] args) {

final ApplicationContext ctx =
SpringApplication.run(
SpringboardApplication.class, args);



NiftyProcessor niftyProcessor =
new ThriftServiceProcessor(
new ThriftCodecManager(), new ArrayList<>(),
springboard);

ThriftServerConfig thriftServerConfig =
new ThriftServerConfig().setPort(9876);

ThriftServer server = new ThriftServer(
niftyProcessor, thriftServerConfig);

server.start();

Runtime.getRuntime().addShutdownHook(new Thread() {

@Override

public void run() { server.close(); }

});
}


}
IDL 작성하기 귀찮으니
facebook-swift!!
Thrift Client
$ mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get 
-DremoteRepositories=central::default::http://
repo1.maven.apache.org/maven2 
-Dartifact=com.facebook.swift:swift2thrift-generator-
cli:RELEASE:jar:standalone 
-Ddest=/tmp/
$ java -cp target/classes:/tmp/swift2thrift-generator-
cli-0.15.1-standalone.jar 
com.facebook.swift.generator.swift2thrift.Main 
-v 
-out src/main/thrift/springboard.thrift 
-namespace java kr.iolo.springboard.thrift 
-package kr.iolo.springboard.thrift 
TSpringboard TUser TForum TPost TComment
$ cat src/main/thrift/springboot.thrift
. . .
$ thrift -v -r 
-o src/main/node 
—gen js:node src/main/thrift/springboard.thrift
Thrift Client
var thrift = require('thrift');



var conn = thrift.createConnection('localhost', 9876, {debug:
true, max_attempts: 5});



conn.on('error', function (err) {

console.error('*** THRIFT CONNECTION ERROR:', err);

});



process.on('exit', function () {

console.log('*** BYE ***');

conn.end();

});
var Springboard = require('./gen-nodejs/springboard');

var Types = require(‘./gen-nodejs/springboard_types');


var springboard = thrift.createClient(
Springboard, conn);
RESTful API Server
var express = require('express');



var app = express();



app.set('json replacer', function (key, value) {

if (value instanceof thrift.Int64) {

return value.toNumber(true);

}

return value;

});



app.use(require('cors')());

app.use(require('body-parser').json());



app.get('/posts/:postId', function (req, res, next) {

var postId = req.params.postId;


springboard.getPost(postId, function (err, data) {

if (err) {

return next(err);

}

res.json(data);

});

});
Single Page Webapp
with React
…
Isomorphic Rendering
Server with React
…
소스코드
https://github.com/iolo/
playnode-springboard-demo
END
SIMON SAYS
­ John Doe
“Do not reinvent the wheel,
but make it perfect!”
­ John Doe
“Reinvent the wheel,
knowing when and how.”
–	孔子
“溫故而知新	可以爲師矣”
References
• Spring Framework: http://projects.spring.io/spring-framework/
• Node.js: https://nodejs.org
• Apache Thrift: https://thrift.apache.org
• Facebook Swift: https://github.com/facebook/swift/
• Facebook React: https://facebook.github.io/react/
• Microservices by Martin Fowler: http://martinfowler.com/articles/microservices.html
• Building Microservices with Spring Boot and Apache Thrift
• Part 1: https://dzone.com/articles/building-microservices-spring
• Part 2: http://bsideup.blogspot.kr/2015/04/spring-boot-thrift-part2.html
• Part 3: http://bsideup.blogspot.kr/2015/04/spring-boot-thrift-part3.html
• Isomorphic JavaScript: The Future of Web Apps: http://nerds.airbnb.com/isomorphic-javascript-future-web-apps/
• How to Implement Node + React Isomorphic JavaScript & Why it Matters
• https://strongloop.com/strongblog/node-js-react-isomorphic-javascript-why-it-matters/
• From AngularJS to React: The Isomorphic Way
• https://blog.risingstack.com/from-angularjs-to-react-the-isomorphic-way/
• Going Isomorphic with React
• https://bensmithett.github.io/going-isomorphic-with-react/
• and Google Search https://google.com, StackOverflow http://stackoverflow.com, GitHub https://github.com …
Q&A
MAY THE SOURCE BE WITH YOU
Thanks
THAT’S ALL FOLKS

More Related Content

What's hot

232 deview2013 oss를활용한분산아키텍처구현
232 deview2013 oss를활용한분산아키텍처구현232 deview2013 oss를활용한분산아키텍처구현
232 deview2013 oss를활용한분산아키텍처구현
NAVER D2
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
Node js presentation
Node js presentationNode js presentation
Node js presentation
martincabrera
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
Tom Croucher
 
Testing nodejs apps
Testing nodejs appsTesting nodejs apps
Testing nodejs apps
felipefsilva
 

What's hot (20)

JUDCon 2010 Boston : BoxGrinder
JUDCon 2010 Boston : BoxGrinderJUDCon 2010 Boston : BoxGrinder
JUDCon 2010 Boston : BoxGrinder
 
201904 websocket
201904 websocket201904 websocket
201904 websocket
 
Building your first Node app with Connect & Express
Building your first Node app with Connect & ExpressBuilding your first Node app with Connect & Express
Building your first Node app with Connect & Express
 
232 deview2013 oss를활용한분산아키텍처구현
232 deview2013 oss를활용한분산아키텍처구현232 deview2013 oss를활용한분산아키텍처구현
232 deview2013 oss를활용한분산아키텍처구현
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node js
 
Node.js Event Loop & EventEmitter
Node.js Event Loop & EventEmitterNode.js Event Loop & EventEmitter
Node.js Event Loop & EventEmitter
 
Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Scala Frustrations
Scala FrustrationsScala Frustrations
Scala Frustrations
 
Dmp hadoop getting_start
Dmp hadoop getting_startDmp hadoop getting_start
Dmp hadoop getting_start
 
All aboard the NodeJS Express
All aboard the NodeJS ExpressAll aboard the NodeJS Express
All aboard the NodeJS Express
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with Examples
 
Node js presentation
Node js presentationNode js presentation
Node js presentation
 
Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBox
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
 
Express node js
Express node jsExpress node js
Express node js
 
Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)
 
Testing nodejs apps
Testing nodejs appsTesting nodejs apps
Testing nodejs apps
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.js
 

Viewers also liked

Vert.x&amp;Socket.IO 이해 및 활용 | Devon 2012
Vert.x&amp;Socket.IO 이해 및 활용 | Devon 2012Vert.x&amp;Socket.IO 이해 및 활용 | Devon 2012
Vert.x&amp;Socket.IO 이해 및 활용 | Devon 2012
Daum DNA
 

Viewers also liked (20)

시간당 수백만 요청을 처리하는 node.js 서버 운영기 - Playnode 2015
시간당 수백만 요청을 처리하는 node.js 서버 운영기 - Playnode 2015시간당 수백만 요청을 처리하는 node.js 서버 운영기 - Playnode 2015
시간당 수백만 요청을 처리하는 node.js 서버 운영기 - Playnode 2015
 
Vert.x&amp;Socket.IO 이해 및 활용 | Devon 2012
Vert.x&amp;Socket.IO 이해 및 활용 | Devon 2012Vert.x&amp;Socket.IO 이해 및 활용 | Devon 2012
Vert.x&amp;Socket.IO 이해 및 활용 | Devon 2012
 
Play node conference
Play node conferencePlay node conference
Play node conference
 
Node.js in Flitto
Node.js in FlittoNode.js in Flitto
Node.js in Flitto
 
[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스
[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스
[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스
 
Alluxio Keynote at Strata+Hadoop World Beijing 2016
Alluxio Keynote at Strata+Hadoop World Beijing 2016Alluxio Keynote at Strata+Hadoop World Beijing 2016
Alluxio Keynote at Strata+Hadoop World Beijing 2016
 
Getting Started with Alluxio + Spark + S3
Getting Started with Alluxio + Spark + S3Getting Started with Alluxio + Spark + S3
Getting Started with Alluxio + Spark + S3
 
Alluxio Presentation at Strata San Jose 2016
Alluxio Presentation at Strata San Jose 2016Alluxio Presentation at Strata San Jose 2016
Alluxio Presentation at Strata San Jose 2016
 
NODE.JS 글로벌 기업 적용 사례 그리고, real-time 어플리케이션 개발하기
NODE.JS 글로벌 기업 적용 사례  그리고, real-time 어플리케이션 개발하기NODE.JS 글로벌 기업 적용 사례  그리고, real-time 어플리케이션 개발하기
NODE.JS 글로벌 기업 적용 사례 그리고, real-time 어플리케이션 개발하기
 
[HCI2010]UI패턴기반 UI설계/개발자동화사례발표
[HCI2010]UI패턴기반 UI설계/개발자동화사례발표[HCI2010]UI패턴기반 UI설계/개발자동화사례발표
[HCI2010]UI패턴기반 UI설계/개발자동화사례발표
 
Design Pattern Libraries
Design Pattern LibrariesDesign Pattern Libraries
Design Pattern Libraries
 
예제로 보는 Pattern 연상법
예제로 보는 Pattern 연상법예제로 보는 Pattern 연상법
예제로 보는 Pattern 연상법
 
Generate a Living Style Guide from CSS - CSSDevConf 2016
Generate a Living Style Guide from CSS - CSSDevConf 2016Generate a Living Style Guide from CSS - CSSDevConf 2016
Generate a Living Style Guide from CSS - CSSDevConf 2016
 
JavaSript Template Engine
JavaSript Template EngineJavaSript Template Engine
JavaSript Template Engine
 
Slack trello notification guide
Slack trello notification guideSlack trello notification guide
Slack trello notification guide
 
[HCI2011]모바일웹 UI패턴 및 UI플랫폼_김창겸,문승현_배포용
[HCI2011]모바일웹 UI패턴 및 UI플랫폼_김창겸,문승현_배포용[HCI2011]모바일웹 UI패턴 및 UI플랫폼_김창겸,문승현_배포용
[HCI2011]모바일웹 UI패턴 및 UI플랫폼_김창겸,문승현_배포용
 
Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907
 
Front end 웹사이트 성능 측정 및 개선
Front end 웹사이트 성능 측정 및 개선Front end 웹사이트 성능 측정 및 개선
Front end 웹사이트 성능 측정 및 개선
 
XECon+PHPFest2014 발표자료 - 효율적인 css 개발방법 - 최대영
XECon+PHPFest2014 발표자료 - 효율적인 css 개발방법 - 최대영XECon+PHPFest2014 발표자료 - 효율적인 css 개발방법 - 최대영
XECon+PHPFest2014 발표자료 - 효율적인 css 개발방법 - 최대영
 
[115]14일만에 깃헙 스타 1,000개 받은 차트 오픈소스 개발기
[115]14일만에 깃헙 스타 1,000개 받은 차트 오픈소스 개발기[115]14일만에 깃헙 스타 1,000개 받은 차트 오픈소스 개발기
[115]14일만에 깃헙 스타 1,000개 받은 차트 오픈소스 개발기
 

Similar to Java/Spring과 Node.js의공존

Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming
Cloudflare
 

Similar to Java/Spring과 Node.js의공존 (20)

Performance Tuning EC2 Instances
Performance Tuning EC2 InstancesPerformance Tuning EC2 Instances
Performance Tuning EC2 Instances
 
The Cloud-natives are RESTless @ JavaOne
The Cloud-natives are RESTless @ JavaOneThe Cloud-natives are RESTless @ JavaOne
The Cloud-natives are RESTless @ JavaOne
 
String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
 
Logstash for SEO: come monitorare i Log del Web Server in realtime
Logstash for SEO: come monitorare i Log del Web Server in realtimeLogstash for SEO: come monitorare i Log del Web Server in realtime
Logstash for SEO: come monitorare i Log del Web Server in realtime
 
Deep Dive on Amazon EC2
Deep Dive on Amazon EC2Deep Dive on Amazon EC2
Deep Dive on Amazon EC2
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Lint, coverage, doc, autocompletion, transpilation, minification... powered b...
Lint, coverage, doc, autocompletion, transpilation, minification... powered b...Lint, coverage, doc, autocompletion, transpilation, minification... powered b...
Lint, coverage, doc, autocompletion, transpilation, minification... powered b...
 
Getting started with developing Nodejs
Getting started with developing NodejsGetting started with developing Nodejs
Getting started with developing Nodejs
 
State of Akka 2017 - The best is yet to come
State of Akka 2017 - The best is yet to comeState of Akka 2017 - The best is yet to come
State of Akka 2017 - The best is yet to come
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
 
Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming
 
Docker Logging and analysing with Elastic Stack - Jakub Hajek
Docker Logging and analysing with Elastic Stack - Jakub Hajek Docker Logging and analysing with Elastic Stack - Jakub Hajek
Docker Logging and analysing with Elastic Stack - Jakub Hajek
 
Docker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic StackDocker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic Stack
 
YOW2020 Linux Systems Performance
YOW2020 Linux Systems PerformanceYOW2020 Linux Systems Performance
YOW2020 Linux Systems Performance
 
CMP301_Deep Dive on Amazon EC2 Instances
CMP301_Deep Dive on Amazon EC2 InstancesCMP301_Deep Dive on Amazon EC2 Instances
CMP301_Deep Dive on Amazon EC2 Instances
 
"今" 使えるJavaScriptのトレンド
"今" 使えるJavaScriptのトレンド"今" 使えるJavaScriptのトレンド
"今" 使えるJavaScriptのトレンド
 
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
 
4 Node.js Gotchas: What your ops team needs to know
4 Node.js Gotchas: What your ops team needs to know4 Node.js Gotchas: What your ops team needs to know
4 Node.js Gotchas: What your ops team needs to know
 

More from 동수 장

웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다
웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다
웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다
동수 장
 
개발자와 협업하기 위한 API의 이해 - API를 준비하는 금성인을 위한 안내서
개발자와 협업하기 위한 API의 이해 - API를 준비하는 금성인을 위한 안내서개발자와 협업하기 위한 API의 이해 - API를 준비하는 금성인을 위한 안내서
개발자와 협업하기 위한 API의 이해 - API를 준비하는 금성인을 위한 안내서
동수 장
 
모바일/클라우드 시대를 준비하는 개발자들을 위한 안내서
모바일/클라우드 시대를 준비하는 개발자들을 위한 안내서모바일/클라우드 시대를 준비하는 개발자들을 위한 안내서
모바일/클라우드 시대를 준비하는 개발자들을 위한 안내서
동수 장
 
하이브리드앱 개발 전략과 이슈
하이브리드앱 개발 전략과 이슈하이브리드앱 개발 전략과 이슈
하이브리드앱 개발 전략과 이슈
동수 장
 
Hybrid Mobile Application Framework
Hybrid Mobile Application FrameworkHybrid Mobile Application Framework
Hybrid Mobile Application Framework
동수 장
 
Gnome Architecture
Gnome ArchitectureGnome Architecture
Gnome Architecture
동수 장
 

More from 동수 장 (12)

(면접에서 자주 나오는) HTTP : 브라우저에서 서버까지.pdf
(면접에서 자주 나오는) HTTP : 브라우저에서 서버까지.pdf(면접에서 자주 나오는) HTTP : 브라우저에서 서버까지.pdf
(면접에서 자주 나오는) HTTP : 브라우저에서 서버까지.pdf
 
백세코딩
백세코딩백세코딩
백세코딩
 
프론트엔드 웹앱 프레임웍 - Bootstrap, Backbone 그리고 AngularJS
프론트엔드 웹앱 프레임웍 - Bootstrap, Backbone 그리고 AngularJS프론트엔드 웹앱 프레임웍 - Bootstrap, Backbone 그리고 AngularJS
프론트엔드 웹앱 프레임웍 - Bootstrap, Backbone 그리고 AngularJS
 
웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다
웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다
웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다
 
개발자와 협업하기 위한 API의 이해 - API를 준비하는 금성인을 위한 안내서
개발자와 협업하기 위한 API의 이해 - API를 준비하는 금성인을 위한 안내서개발자와 협업하기 위한 API의 이해 - API를 준비하는 금성인을 위한 안내서
개발자와 협업하기 위한 API의 이해 - API를 준비하는 금성인을 위한 안내서
 
모바일/클라우드 시대를 준비하는 개발자들을 위한 안내서
모바일/클라우드 시대를 준비하는 개발자들을 위한 안내서모바일/클라우드 시대를 준비하는 개발자들을 위한 안내서
모바일/클라우드 시대를 준비하는 개발자들을 위한 안내서
 
하이브리드앱 개발 전략과 이슈
하이브리드앱 개발 전략과 이슈하이브리드앱 개발 전략과 이슈
하이브리드앱 개발 전략과 이슈
 
하이브리드앱 아키텍쳐 및 개발 사례
하이브리드앱 아키텍쳐 및 개발 사례하이브리드앱 아키텍쳐 및 개발 사례
하이브리드앱 아키텍쳐 및 개발 사례
 
단일 페이지 인터페이스 웹/앱 개발
단일 페이지 인터페이스 웹/앱 개발단일 페이지 인터페이스 웹/앱 개발
단일 페이지 인터페이스 웹/앱 개발
 
Hybrid Mobile Application Framework
Hybrid Mobile Application FrameworkHybrid Mobile Application Framework
Hybrid Mobile Application Framework
 
Javascript Common Mistakes
Javascript Common MistakesJavascript Common Mistakes
Javascript Common Mistakes
 
Gnome Architecture
Gnome ArchitectureGnome Architecture
Gnome Architecture
 

Recently uploaded

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 

Java/Spring과 Node.js의공존

  • 1. Java/Spring과 Node.js의 공존 Java/Spring 전성시대에 Node.js가 살아남는 법 Dongsu Jang <iolothebard at gmail dot com>
  • 2. TOC • BEGIN • AS-IS • TO-BE • VS • CODE • END
  • 4. 개발자여, 불가능한 꿈을 꾸어라 • java8, tomcat8, spring-boot, spring-cloud, jpa… • mongodb, cassandra, couchbase, elasticsearch… • python, ruby, scala, rust, clojure, julia… • docker, kubernetes, mesos, microservices… • nginx, redis, play framework, akka, spark, node.js, django, flask… • angular, react, EcmaScript6… • IE8 없는 세상…
  • 5. 그러나, 리얼리스트가 되라 • 현실은 자바 천국… • 스프링 전성 시대… • 봄날은 생각보다 오래 가더라… • “관리가능”한 아키텍쳐의 무거움 • 배포할 줄 아는 마지막 개발자가 퇴사 했어요 OTL • 지금 서비스 하는 버전이 svn 에 있는 거 보다 더 최신인데요 -_-; • 롤백할께요 ㅠ,.ㅠ • 서버 늘려야겠죠? 구매 요청할께요 ^^; • IE8 테스트할 PC가 없어요? XP요~ 그래도… 재밌는 거 해보고 싶어요!
  • 7. AS-IS • Java 5.x/6.x/7.x… with Tomcat 5.x/6.x/7.x… • Apache Web Server with mod_jk/ jk2/webapp… • Spring Framework with Spring- WebMVC/Struts… • Template Engine: JSP/Velocity/ Freemark… • DAO: MyBatis/Hibernate/JDBC… • Cache: EHCache/OSCache/Map… • RDBMS: Oracle/MySQL…
  • 9. AS-IS Spring Framework with Spring-WebMvc/Struts… JVM Template Engine JSP/Velocity/Freemarker… DAO JDBC/MyBatis/Hibernate… Cache EHCache/OSCache/Map… Tomcat Servlet Container Model View Controller
  • 11. TO-BE • Node.js • Express • Thrift • Redis • React • 원래 있던 거…
  • 12. TO-BE tomcatapache webapp (war) MySQL tomcat … mod_jk apache … webapp (war)mod_jk MySQL node.js API server + @ redis pm2 nginx React Server React Client node.js … thrift AJPHTTP + @ + @
  • 13. TO-BE java Thrift Server (thrift/swift/nifty) Thrift Client (node-thrift) node.js RESTful API Server Isomorphic Rendering Server 원래 있던 거… (war) Single Page Webapp browser express react browerify, babel, … react
  • 14. VS I WANT TO BELIEVE
  • 15. tomcat-spring-webmvc 100 concurrent user표 1 Label # Samples Average Min Max Std. Dev. Error % Throughput KB/sec Avg. Bytes forum_list 1000 4 0 757 41.15 0% 35.9 32.95 939 login_post 1000 13 1 120 30.97 0% 36.9 30.72 852 post_list 1000 12 2 116 12.68 0% 36.9 667.9 18510.5 post_view 1000 7 2 117 8.32 0% 37 335.97 9301.4 post_save 1000 27 4 145 32.91 0% 37 716.45 19836.4 comment_save 1000 21 3 133 31.21 0% 37 364.2 10083.9 TOTAL 6000 14 0 757 29.78 0% 204 1975.94 9920.5
  • 17. nodejs-express-thrift 100 concurrent user표 1 Label # Samples Average Min Max Std. Dev. Error % Throughput KB/sec Avg. Bytes forum_list 1000 3 0 420 20.68 0% 37 17.03 471.6 login_post 1000 16 1 248 34.76 0% 37.5 10.16 277 post_list 1000 2 0 113 5.2 0% 37.8 308.3 8361.9 post_view 1000 1 0 107 3.55 0% 37.8 12.61 342 post_save 1000 7 1 109 15.51 0% 37.8 8.93 242 comment_save 1000 8 1 105 17.43 0% 37.8 8.93 242 TOTAL 6000 6 0 420 19.82 0% 209.9 339.39 1656.1
  • 19. tomcat-spring-webmvc 500 concurrent user표 1 Label # Samples Average Min Max Std. Dev. Error % ThroughputKB/sec Avg. Bytes forum_list 5000 782 1 7142 849.82 0% 25.6 23.49 939 login_post 5000 1453 1 10011 1361.53 0% 25.7 21.38 852 post_list 5000 2539 2 13975 2293.41 0% 25.7 2229.89 88919.8 post_view 5000 1678 2 11447 1617.18 0% 25.7 1067.33 42560.5 post_save 5000 3512 5 14182 2853.35 0% 25.7 2384.92 95178.4 comment_save 5000 2726 4 15547 2247.67 0% 25.7 1154.3 46070.7 TOTAL 30000 2115 1 15547 2181.63 0% 152 6793.39 45753.4
  • 21. nodejs-express-thrift 500 concurrent user표 1 Label # Samples Average Min Max Std. Dev. Error % ThroughputKB/sec Avg. Bytes forum_list 5000 17 0 407 36.84 0% 145.3 66.91 471.6 login_post 5000 58 1 937 79.5 0% 146.5 39.63 277 post_list 5000 38 0 976 89.75 0% 147.5 6517.04 45252.7 post_view 5000 15 0 724 39.26 0% 147.4 49.23 342 post_save 5000 39 1 722 60.66 0% 147.4 34.83 242 comment_save 5000 44 1 969 72.13 0% 147.5 34.85 242 TOTAL 30000 35 0 976 67.72 0% 831 6333.24 7804.5
  • 26. 원래 있던거…├── src │   ├── main │   │   ├── jaja │   │   │   └── kr │   │   │   └── iolo │   │   │   └── springboard │   │   │   ├── Comment.java │   │   │   ├── Forum.java │   │   │   ├── Post.java │   │   │   ├── Springboard.java │   │   │   ├── SpringboardImpl.java │   │   │   ├── User.java │   │   │   ├── controller │   │   │   │   ├── CommentSaveController.java │   │   │   │   ├── ForumListController.java │   │   │   │   ├── LoginController.java │   │   │   │   ├── PostFormController.java │   │   │   │   ├── PostListController.java │   │   │   │   ├── PostSaveController.java │   │   │   │   ├── PostViewController.java │   │   │   │   └── SignupController.java │   │   └── resources │   │   └── templates │   │   ├── forum_list.html │   │   ├── login.html │   │   ├── post_form.html │   │   ├── post_list.html │   │   ├── post_view.html │   │   └── signup.html 안봐도 비디오~
  • 28. Thrift Server ├── src │   ├── main │   │   ├── java │   │   │   └── kr │   │   │   └── iolo │   │   │   └── springboard │   │   │   ├── ... │   │   │   ├── SpringboardApplication.java │   │   │   ├── cache │   │   │   │   ├── CacheService.java │   │   │   │   ├── DummyCacheService.java │   │   │   │   └── RedisCacheService.java │   │   │   └── thrift │   │   │   ├── TComment.java │   │   │   ├── TForum.java │   │   │   ├── TPost.java │   │   │   ├── TSpringboard.java │   │   │   ├── TSpringboardImpl.java │   │   │   └── TUser.java │   │   └── resources │   │   ├── config │   │   │   └── application.properties │   │   ├── logback.xml │   │   ├── static │   │   │   └── index.html 설정하기 귀찮아서 spring-boot 성능테스트를 위해 redis Node.js 와의 통 신을 위해 thrift!!!
  • 29. Thrift Server import com.facebook.swift.service.ThriftMethod;
 import com.facebook.swift.service.ThriftService;
 
 import java.util.List;
 
 @ThriftService("Springboard")
 public interface TSpringboard {
 
 @ThriftMethod("getUsers")
 List<TUser> getUsers();
 
 @ThriftMethod("getUserByUsernameAndPassword")
 TUser getUserByUsernameAndPassword(String username, String password);
 
 @ThriftMethod("getUser")
 TUser getUser(int userId);
 
 /* . . . */
 
 @ThriftMethod("createComment")
 int createComment(TComment post);
 
 @ThriftMethod("updateComment")
 boolean updateComment(TComment post);
 
 @ThriftMethod("deleteComment")
 boolean deleteComment(int commentId);
 
 } IDL 작성하기 귀찮으니 facebook-swift!!
  • 30. Thrift Server import com.facebook.swift.codec.ThriftField;
 import com.facebook.swift.codec.ThriftStruct;
 
 @ThriftStruct("Comment")
 public final class TComment {
 
 private int id;
 private int userId;
 private int postId;
 private String content;
 private String createdAt;
 
 @ThriftField(1)
 public int getId() { return id; }
 
 @ThriftField(2)
 public int getUserId() { return userId; }
 
 /* . . . */
 
 @ThriftField
 public void setId(int id) { this.id = id; }
 
 @ThriftField
 public void setUserId(int userId) { this.userId = userId; }
 
 /* . . . */
 
 } IDL 작성하기 귀찮으니 facebook-swift!!
  • 31. Thrift Serverimport com.facebook.nifty.processor.NiftyProcessor;
 import com.facebook.swift.codec.ThriftCodecManager;
 import com.facebook.swift.service.ThriftServer;
 import com.facebook.swift.service.ThriftServerConfig;
 import com.facebook.swift.service.ThriftServiceProcessor;
 import kr.iolo.springboard.thrift.TSpringboard;
 
 @SpringBootApplication
 public class SpringboardApplication {
 
 @Autowired TSpringboard springboard;
 
 public static void main(String[] args) {
 final ApplicationContext ctx = SpringApplication.run( SpringboardApplication.class, args);
 
 NiftyProcessor niftyProcessor = new ThriftServiceProcessor( new ThriftCodecManager(), new ArrayList<>(), springboard);
 ThriftServerConfig thriftServerConfig = new ThriftServerConfig().setPort(9876);
 ThriftServer server = new ThriftServer( niftyProcessor, thriftServerConfig);
 server.start();
 Runtime.getRuntime().addShutdownHook(new Thread() {
 @Override
 public void run() { server.close(); }
 }); } 
 } IDL 작성하기 귀찮으니 facebook-swift!!
  • 32. Thrift Client $ mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -DremoteRepositories=central::default::http:// repo1.maven.apache.org/maven2 -Dartifact=com.facebook.swift:swift2thrift-generator- cli:RELEASE:jar:standalone -Ddest=/tmp/ $ java -cp target/classes:/tmp/swift2thrift-generator- cli-0.15.1-standalone.jar com.facebook.swift.generator.swift2thrift.Main -v -out src/main/thrift/springboard.thrift -namespace java kr.iolo.springboard.thrift -package kr.iolo.springboard.thrift TSpringboard TUser TForum TPost TComment $ cat src/main/thrift/springboot.thrift . . . $ thrift -v -r -o src/main/node —gen js:node src/main/thrift/springboard.thrift
  • 33. Thrift Client var thrift = require('thrift');
 
 var conn = thrift.createConnection('localhost', 9876, {debug: true, max_attempts: 5});
 
 conn.on('error', function (err) {
 console.error('*** THRIFT CONNECTION ERROR:', err);
 });
 
 process.on('exit', function () {
 console.log('*** BYE ***');
 conn.end();
 }); var Springboard = require('./gen-nodejs/springboard');
 var Types = require(‘./gen-nodejs/springboard_types'); 
 var springboard = thrift.createClient( Springboard, conn);
  • 34. RESTful API Server var express = require('express');
 
 var app = express();
 
 app.set('json replacer', function (key, value) {
 if (value instanceof thrift.Int64) {
 return value.toNumber(true);
 }
 return value;
 });
 
 app.use(require('cors')());
 app.use(require('body-parser').json());
 
 app.get('/posts/:postId', function (req, res, next) {
 var postId = req.params.postId; 
 springboard.getPost(postId, function (err, data) {
 if (err) {
 return next(err);
 }
 res.json(data);
 });
 });
  • 39. ­ John Doe “Do not reinvent the wheel, but make it perfect!”
  • 40. ­ John Doe “Reinvent the wheel, knowing when and how.”
  • 42. References • Spring Framework: http://projects.spring.io/spring-framework/ • Node.js: https://nodejs.org • Apache Thrift: https://thrift.apache.org • Facebook Swift: https://github.com/facebook/swift/ • Facebook React: https://facebook.github.io/react/ • Microservices by Martin Fowler: http://martinfowler.com/articles/microservices.html • Building Microservices with Spring Boot and Apache Thrift • Part 1: https://dzone.com/articles/building-microservices-spring • Part 2: http://bsideup.blogspot.kr/2015/04/spring-boot-thrift-part2.html • Part 3: http://bsideup.blogspot.kr/2015/04/spring-boot-thrift-part3.html • Isomorphic JavaScript: The Future of Web Apps: http://nerds.airbnb.com/isomorphic-javascript-future-web-apps/ • How to Implement Node + React Isomorphic JavaScript & Why it Matters • https://strongloop.com/strongblog/node-js-react-isomorphic-javascript-why-it-matters/ • From AngularJS to React: The Isomorphic Way • https://blog.risingstack.com/from-angularjs-to-react-the-isomorphic-way/ • Going Isomorphic with React • https://bensmithett.github.io/going-isomorphic-with-react/ • and Google Search https://google.com, StackOverflow http://stackoverflow.com, GitHub https://github.com …
  • 43. Q&A MAY THE SOURCE BE WITH YOU