vert.x를 활용한

!

대용량 트래픽 처리를 위한!
분산 서버 개발하기!
!

(vert.x & scalable architecture)

김요한

yohany@gmail.com
1. 개발 패러다임의 변화!
!
!

- 비동기 Event Looping 서버의 특징!
- JVM 기반 vert.x 특징!

!

2. 분산 서버 설계 하기!
!

- 대용량 트래픽 처리 / 체팅 서비스 서버 개발 사례!

!

3. 분산 서버 설계시 알아야 할 것들!
!

- Consistent Hashing, Sharding, Proxy, MessageQueue ..!
1. 개발 패러다임의 변화!
!
!

- 비동기 Event Looping 서버의 특징!
- JVM 기반 vert.x 특징
1. 개발 패러다임의 변화

Question
원하는 만큼 확장할 수 있나요 ?!
대용량 트래픽을 처리 할 수 있나요 ?!
기능 추가를 얼마나 빨리 할 수 있나요 ?!
쉽고 빨리 개발할 수 있나요 ?
1. 개발 패러다임의 변화

Answer
background on the C10K problem!
Event Looping!
None Blocking I/O!
Fault Tolerant!
Scalability (Scala-Out)!
......
비동기 서버의 특징

Shifting from !

Threading to Asynchronous
비동기 서버의 특징
비동기 서버의 특징

Apache HTTP Server v2.4 ideally suited for Cloud environments. They include:!
!
•
•
•
•
•
•
•

Improved performance (lower resource utilization and better concurrency)!
Reduced memory usage!
Asyncronous I/O support!
Dynamic reverse proxy configuration!

Asynchronous I/O support

Performance on par, or better, than pure event-driven Web servers!
More granular timeout and rate/resource limiting capability!
More finely-tuned caching support, tailored for high traffic servers and proxies.

http://blogs.apache.org/foundation/entry/the_apache_software_foundation_celebrates
비동기 서버의 특징
Java IO

Stream oriented Blocking IO
Reading data from a blocking stream.
비동기 서버의 특징
Java NIO

Buffer oriented Non blocking IO Selectors
Reading data from a channel until all needed data is in buffer.
http://tutorials.jenkov.com/java-nio/nio-vs-io.html
비동기 서버의 특징

many modularity paradigms
비동기 서버의 특징
비동기 서버의 특징

-

Main.class!
library1.jar!
library2.jar!
library3.jar

JAR Library
ClassLoader
비동기 서버의 특징
EventBus (vert.x)

Module 1

Module 2

Module 3

- Module1.class!
- library1.jar!
- library2.jar

- Module2.class!
- library1.jar!
- library2.jar

- Module2.class!
- library1.jar!
- library2.jar

ClassLoader

ClassLoader

ClassLoader
비동기 서버의 특징

Polyglot or Multilingual
비동기 서버의 특징

“ Components + Scripts = Applications ”	

see John Ousterhout, IEEE Computer, March ’98	

http://www.stanford.edu/~ouster/cgi-bin/papers/scripting.pdf
비동기 서버의 특징

“ Shift from Apache to Node.js ”
JVM 기반 VERT.X 특징

based

JVM
JVM 기반 VERT.X 특징
	
	
	

import org.vertx.java.core.Handler;


import org.vertx.java.core.http.HttpServerRequest;
import org.vertx.java.platform.Verticle;
	

	

public class Server extends Verticle {

	

JAVA 7



	

public void start() {	
vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() {
public void handle(HttpServerRequest req) {
	
String file = req.path().equals("/") ? "index.html" : req.path();
req.response().sendFile("webroot/" + file);
	

	

}


}).listen(8080);	
}
}

	
	

> vertx run Server.java



JVM 기반 VERT.X 특징
	
	
	

import org.vertx.java.core.Handler;


import org.vertx.java.core.http.HttpServerRequest;
import org.vertx.java.platform.Verticle;
	

	

public class Server extends Verticle {

	

JAVA 7



	

public void start() {	

!

vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() {


public void handle(HttpServerRequest req) {
	
vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>()

public void= handle(HttpServerRequest req) {
String file
req.path().equals("/") ? "index.html" : req.path(); 	
	

req.response().sendFile("webroot/" + file);
}


}).listen(8080);	
}
}

	
	

> vertx run Server.java

	

{
JVM 기반 VERT.X 특징
	
	
	

import org.vertx.java.core.Handler;


import org.vertx.java.core.http.HttpServerRequest;
import org.vertx.java.platform.Verticle;
	

	

public class Server extends Verticle {

	

JAVA 8



	

public void start() {	

!

vertx.createHttpServer().requestHandler( (HttpServerRequest req) -> {

	
vertx.createHttpServer().requestHandler((HttpServerRequest

{	

String file = req.path().equals("/") ? "index.html" : req.path();
req.response().sendFile("webroot/" + file);
	

	



}).listen(8080);	
}
}

	
	

> vertx run Server.java

req) -> {

JVM 기반 VERT.X 특징
	
	
	

import org.vertx.java.core.Handler;


import org.vertx.java.core.http.HttpServerRequest;
import org.vertx.java.platform.Verticle;
	

	

public class Server extends Verticle {

	

JAVA 8



	

public void start() {	
vertx.createHttpServer().requestHandler( (HttpServerRequest req) -> {

	
String file = req.path().equals("/") ? "index.html" : req.path();
req.response().sendFile("webroot/" + file);
	

	



}).listen(8080);	
}
}

	
	

> vertx run Server.java
JVM 기반 VERT.X 특징

vert.x instance

Verticle

Verticle

Worker

Verticle

Worker

Verticle
JVM 기반 VERT.X 특징

vert.x instance

Verticle

Verticle

Worker

Verticle

EventBus

Worker

Verticle
JVM 기반 VERT.X 특징


EventBus eb = vertx.eventBus();

	

Handler<Message> myHandler = new Handler<Message>() {


public voidvert.x instance
handle(Message message) {


System.out.println("I received a message " + message.body);
} 

}; 


!

Worker


// EventBus 에 이벤트 등록

Verticle
Verticle
Verticle
eb.registerHandler("test.address", myHandler);





EventBus
// EventBus 로 이벤트 실행

eb.send("test.address", "hello world");


Worker

Verticle



EventBus

Worker

Verticle

Worker

Verticle

Verticle

vert.x instance

Verticle

Worker

Verticle

Worker

Verticle

Verticle

Verticle

JVM 기반 VERT.X 특징

vert.x instance
EventBus

Worker

Verticle

Worker

Verticle

Verticle

vert.x instance

Verticle

Worker

Verticle

Worker

Verticle

Verticle

Verticle

JVM 기반 VERT.X 특징

vert.x instance
JVM 기반 VERT.X 특징
http://vertx.io
JVM 기반 VERT.X 특징
http://vertx.io

Distributed Event Bus
JVM 기반 VERT.X 특징
http://vertx.io

WebSockets and SockJS!
support for real-time server-push applications.
JVM 기반 VERT.X 특징
http://vertx.io

embedded !
as a library in your existing Java applications
JVM 기반 VERT.X 특징
http://vertx.io

module system!
components into modules for encapsulation and reuse
JVM 기반 VERT.X 특징
http://vertx.io

Maven archetype

Gradle template

Auto-redeploy
JVM 기반 VERT.X 특징

34
http://www.techempower.com/benchmarks/
JVM 기반 VERT.X 특징

http://nodyn.io/
2. 분산 서버 설계 하기!
!

- 대용량 트래픽 처리 / 체팅 서비스 서버 개발 사례
- 분산 체팅서비스 구축하기 사례
http://stalk.io
<script src="http://www.stalk.io/stalk.js"></script>	
<script language="javascript">	
	 STALK.init();	
</script>
- 분산 체팅서비스 구축하기 사례

http://example.com/samplePage.html
체팅방 키
- 분산 체팅서비스 구축하기 사례
http://노량진수산시장 /개불.html

Chat Server

Chat Server

(vert.x sockJS)
Chat Server

(vert.x sockJS)
Chat Server

(vert.x sockJS)
(vert.x sockJS)
천승희

도문준
체팅방 KEY : 노량진수산시장/개불
- 분산 체팅서비스 구축하기 사례
http://노량진수산시장 /개불.html
Chat Server
Chat Server
Chat Server
천승희

Chat Server

. . .!

“Session 정보 공유하기” 문제 !

도문준
- 분산 체팅서비스 구축하기 사례
http://노량진수산시장 /개불.html
Restful Server
Publish

도문준

천승희
Subscribe

. . .!

Socket Server
김요한
- 분산 체팅서비스 구축하기 사례
http://노량진수산시장 /개불.html
Restful Server
Restful Server
Restful Server
Restful Server
Restful Server
Restful Server
HAProxy
천승희

Restful Server

도문준

Restful Server

. . .!

Socket Server
김요한
- 분산 체팅서비스 구축하기 사례
http://노량진수산시장 /개불.html
Restful Server
Restful Server
Restful Server
Restful Server
Subscribe
Publish
천승희

Socket Server
Socket Server

도문준

Socket Server

도문준

Socket Server
Restful Server
Restful Server
Restful Server
Socket Server

. . .!

김요한
김요한
- 분산 체팅서비스 구축하기 사례
http://노량진수산시장 /개불.html
Restful Server
Restful Server
Restful Server
Restful Server
Subscribe
Publish
천승희

Socket Server
Socket Server

도문준

Socket Server

도문준

Socket Server
Restful Server
Restful Server
Restful Server
Socket Server

. . .!

김요한
김요한
- 분산 체팅서비스 구축하기 사례

노량진수산시장/개불

Hash ( input )

192.168.219.1:8080

192.168.219.2:8080

192.168.219.3:8080

192.168.219.4:8080

192.168.219.3:8080
- 분산 체팅서비스 구축하기 사례
http://노량진수산시장 /개불.html
Restful Server
Restful Server
Restful Server
Restful Server

Hash()
Publish

Hash()
도문준

천승희
Subscribe
Restful Server
Restful Server
Socket Server
Restful Server
Socket Server
Socket Server
Socket Server

. . .!
Hash()
김요한
- 분산 체팅서비스 구축하기 사례
http://노량진수산시장 /개불.html
Restful Server
Restful Server
Restful Server
Restful Server

Hash()
Publish

도문준

천승희
Subscribe
Restful Server
Restful Server
Socket Server
Restful Server
Socket Server
Socket Server
Socket Server

. . .!
김요한
- 분산 체팅서비스 구축하기 사례
http://노량진수산시장 /개불.html
Restful Server
Restful Server
Restful Server
Restful Server

Hash()
Publish

도문준

천승희
Subscribe
Restful Server
Restful Server
Socket Server
Socket Server
Socket Server
Socket Server

. . .!
김요한
- 분산 체팅서비스 구축하기 사례

vert.x modules

Startup &
HTTP
configuration
Module
Module

Socket
Module

Distributed 
Node Manager
Module

Message Queue
Module

vert.x event bus
A instance in JVM

https://github.com/stalk-io
- 분산 체팅서비스 구축하기 사례

Restful Server

Startup &
HTTP
configuration
Module
Module

Socket
Module

Distributed 
Node Manager
Module

Message Queue
Module

vert.x event bus
A instance in JVM

https://github.com/stalk-io
- 분산 체팅서비스 구축하기 사례

Socket Server

Startup &
HTTP
configuration
Module
Module

Socket
Module

Distributed 
Node Manager
Module

Message Queue
Module

vert.x event bus
A instance in JVM

https://github.com/stalk-io
3. 분산 서버 설계시 알아야 할 것들!
!

- Consistent Hashing, Sharding, Proxy, MessageQueue ..
- Consistent Hashing
Service
 Server

A

D

Token
 Ring

C

value
 =
 HASH(key)

B
- Consistent Hashing
A

D

value
 =
 HASH(key)

B

C
A
 -
 C
 구간이
 넓어서
 C
 에
 부하가
 많을
 수
 있다

vert.x 를 활용한 분산서버 개발하기

  • 1.
    vert.x를 활용한 ! 대용량 트래픽처리를 위한! 분산 서버 개발하기! ! (vert.x & scalable architecture) 김요한 yohany@gmail.com
  • 2.
    1. 개발 패러다임의변화! ! ! - 비동기 Event Looping 서버의 특징! - JVM 기반 vert.x 특징! ! 2. 분산 서버 설계 하기! ! - 대용량 트래픽 처리 / 체팅 서비스 서버 개발 사례! ! 3. 분산 서버 설계시 알아야 할 것들! ! - Consistent Hashing, Sharding, Proxy, MessageQueue ..!
  • 3.
    1. 개발 패러다임의변화! ! ! - 비동기 Event Looping 서버의 특징! - JVM 기반 vert.x 특징
  • 4.
    1. 개발 패러다임의변화 Question 원하는 만큼 확장할 수 있나요 ?! 대용량 트래픽을 처리 할 수 있나요 ?! 기능 추가를 얼마나 빨리 할 수 있나요 ?! 쉽고 빨리 개발할 수 있나요 ?
  • 5.
    1. 개발 패러다임의변화 Answer background on the C10K problem! Event Looping! None Blocking I/O! Fault Tolerant! Scalability (Scala-Out)! ......
  • 6.
    비동기 서버의 특징 Shiftingfrom ! Threading to Asynchronous
  • 7.
  • 8.
    비동기 서버의 특징 ApacheHTTP Server v2.4 ideally suited for Cloud environments. They include:! ! • • • • • • • Improved performance (lower resource utilization and better concurrency)! Reduced memory usage! Asyncronous I/O support! Dynamic reverse proxy configuration! Asynchronous I/O support Performance on par, or better, than pure event-driven Web servers! More granular timeout and rate/resource limiting capability! More finely-tuned caching support, tailored for high traffic servers and proxies. http://blogs.apache.org/foundation/entry/the_apache_software_foundation_celebrates
  • 9.
    비동기 서버의 특징 JavaIO Stream oriented Blocking IO Reading data from a blocking stream.
  • 10.
    비동기 서버의 특징 JavaNIO Buffer oriented Non blocking IO Selectors Reading data from a channel until all needed data is in buffer. http://tutorials.jenkov.com/java-nio/nio-vs-io.html
  • 11.
    비동기 서버의 특징 manymodularity paradigms
  • 12.
  • 13.
  • 14.
    비동기 서버의 특징 EventBus(vert.x) Module 1 Module 2 Module 3 - Module1.class! - library1.jar! - library2.jar - Module2.class! - library1.jar! - library2.jar - Module2.class! - library1.jar! - library2.jar ClassLoader ClassLoader ClassLoader
  • 15.
  • 16.
    비동기 서버의 특징 “Components + Scripts = Applications ” see John Ousterhout, IEEE Computer, March ’98 http://www.stanford.edu/~ouster/cgi-bin/papers/scripting.pdf
  • 17.
    비동기 서버의 특징 “Shift from Apache to Node.js ”
  • 18.
    JVM 기반 VERT.X특징 based JVM
  • 19.
    JVM 기반 VERT.X특징 import org.vertx.java.core.Handler; 
 import org.vertx.java.core.http.HttpServerRequest; import org.vertx.java.platform.Verticle; public class Server extends Verticle { JAVA 7 
 public void start() { vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() { public void handle(HttpServerRequest req) { String file = req.path().equals("/") ? "index.html" : req.path(); req.response().sendFile("webroot/" + file); } 
 }).listen(8080); } } > vertx run Server.java 

  • 20.
    JVM 기반 VERT.X특징 import org.vertx.java.core.Handler; 
 import org.vertx.java.core.http.HttpServerRequest; import org.vertx.java.platform.Verticle; public class Server extends Verticle { JAVA 7 
 public void start() { ! vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() { 
 public void handle(HttpServerRequest req) { vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() public void= handle(HttpServerRequest req) { String file req.path().equals("/") ? "index.html" : req.path(); req.response().sendFile("webroot/" + file); } 
 }).listen(8080); } } > vertx run Server.java {
  • 21.
    JVM 기반 VERT.X특징 import org.vertx.java.core.Handler; 
 import org.vertx.java.core.http.HttpServerRequest; import org.vertx.java.platform.Verticle; public class Server extends Verticle { JAVA 8 
 public void start() { ! vertx.createHttpServer().requestHandler( (HttpServerRequest req) -> {
 vertx.createHttpServer().requestHandler((HttpServerRequest { String file = req.path().equals("/") ? "index.html" : req.path(); req.response().sendFile("webroot/" + file); 
 }).listen(8080); } } > vertx run Server.java req) -> {

  • 22.
    JVM 기반 VERT.X특징 import org.vertx.java.core.Handler; 
 import org.vertx.java.core.http.HttpServerRequest; import org.vertx.java.platform.Verticle; public class Server extends Verticle { JAVA 8 
 public void start() { vertx.createHttpServer().requestHandler( (HttpServerRequest req) -> {
 String file = req.path().equals("/") ? "index.html" : req.path(); req.response().sendFile("webroot/" + file); 
 }).listen(8080); } } > vertx run Server.java
  • 23.
    JVM 기반 VERT.X특징 vert.x instance Verticle Verticle Worker
 Verticle Worker
 Verticle
  • 24.
    JVM 기반 VERT.X특징 vert.x instance Verticle Verticle Worker
 Verticle EventBus Worker
 Verticle
  • 25.
    JVM 기반 VERT.X특징 
 EventBus eb = vertx.eventBus(); Handler<Message> myHandler = new Handler<Message>() { 
 public voidvert.x instance handle(Message message) { 
 System.out.println("I received a message " + message.body); } 
 }; 
 ! Worker
 // EventBus 에 이벤트 등록
 Verticle Verticle Verticle eb.registerHandler("test.address", myHandler);
 
 EventBus // EventBus 로 이벤트 실행
 eb.send("test.address", "hello world");
 Worker
 Verticle 

  • 26.
  • 27.
  • 28.
    JVM 기반 VERT.X특징 http://vertx.io
  • 29.
    JVM 기반 VERT.X특징 http://vertx.io Distributed Event Bus
  • 30.
    JVM 기반 VERT.X특징 http://vertx.io WebSockets and SockJS! support for real-time server-push applications.
  • 31.
    JVM 기반 VERT.X특징 http://vertx.io embedded ! as a library in your existing Java applications
  • 32.
    JVM 기반 VERT.X특징 http://vertx.io module system! components into modules for encapsulation and reuse
  • 33.
    JVM 기반 VERT.X특징 http://vertx.io Maven archetype
 Gradle template
 Auto-redeploy
  • 34.
    JVM 기반 VERT.X특징 34 http://www.techempower.com/benchmarks/
  • 35.
    JVM 기반 VERT.X특징 http://nodyn.io/
  • 36.
    2. 분산 서버설계 하기! ! - 대용량 트래픽 처리 / 체팅 서비스 서버 개발 사례
  • 37.
    - 분산 체팅서비스구축하기 사례 http://stalk.io <script src="http://www.stalk.io/stalk.js"></script> <script language="javascript"> STALK.init(); </script>
  • 38.
    - 분산 체팅서비스구축하기 사례 http://example.com/samplePage.html 체팅방 키
  • 39.
    - 분산 체팅서비스구축하기 사례 http://노량진수산시장 /개불.html Chat Server
 Chat Server
 (vert.x sockJS) Chat Server
 (vert.x sockJS) Chat Server
 (vert.x sockJS) (vert.x sockJS) 천승희 도문준 체팅방 KEY : 노량진수산시장/개불
  • 40.
    - 분산 체팅서비스구축하기 사례 http://노량진수산시장 /개불.html Chat Server Chat Server Chat Server 천승희 Chat Server . . .! “Session 정보 공유하기” 문제 ! 도문준
  • 41.
    - 분산 체팅서비스구축하기 사례 http://노량진수산시장 /개불.html Restful Server Publish 도문준 천승희 Subscribe . . .! Socket Server 김요한
  • 42.
    - 분산 체팅서비스구축하기 사례 http://노량진수산시장 /개불.html Restful Server Restful Server Restful Server Restful Server Restful Server Restful Server HAProxy 천승희 Restful Server 도문준 Restful Server . . .! Socket Server 김요한
  • 43.
    - 분산 체팅서비스구축하기 사례 http://노량진수산시장 /개불.html Restful Server Restful Server Restful Server Restful Server Subscribe Publish 천승희 Socket Server Socket Server 도문준 Socket Server 도문준 Socket Server Restful Server Restful Server Restful Server Socket Server . . .! 김요한 김요한
  • 44.
    - 분산 체팅서비스구축하기 사례 http://노량진수산시장 /개불.html Restful Server Restful Server Restful Server Restful Server Subscribe Publish 천승희 Socket Server Socket Server 도문준 Socket Server 도문준 Socket Server Restful Server Restful Server Restful Server Socket Server . . .! 김요한 김요한
  • 45.
    - 분산 체팅서비스구축하기 사례 노량진수산시장/개불 Hash ( input ) 192.168.219.1:8080
 192.168.219.2:8080
 192.168.219.3:8080
 192.168.219.4:8080 192.168.219.3:8080
  • 46.
    - 분산 체팅서비스구축하기 사례 http://노량진수산시장 /개불.html Restful Server Restful Server Restful Server Restful Server Hash() Publish Hash() 도문준 천승희 Subscribe Restful Server Restful Server Socket Server Restful Server Socket Server Socket Server Socket Server . . .! Hash() 김요한
  • 47.
    - 분산 체팅서비스구축하기 사례 http://노량진수산시장 /개불.html Restful Server Restful Server Restful Server Restful Server Hash() Publish 도문준 천승희 Subscribe Restful Server Restful Server Socket Server Restful Server Socket Server Socket Server Socket Server . . .! 김요한
  • 48.
    - 분산 체팅서비스구축하기 사례 http://노량진수산시장 /개불.html Restful Server Restful Server Restful Server Restful Server Hash() Publish 도문준 천승희 Subscribe Restful Server Restful Server Socket Server Socket Server Socket Server Socket Server . . .! 김요한
  • 49.
    - 분산 체팅서비스구축하기 사례 vert.x modules Startup & HTTP configuration Module Module Socket Module Distributed Node Manager Module Message Queue Module vert.x event bus A instance in JVM https://github.com/stalk-io
  • 50.
    - 분산 체팅서비스구축하기 사례 Restful Server Startup & HTTP configuration Module Module Socket Module Distributed Node Manager Module Message Queue Module vert.x event bus A instance in JVM https://github.com/stalk-io
  • 51.
    - 분산 체팅서비스구축하기 사례 Socket Server Startup & HTTP configuration Module Module Socket Module Distributed Node Manager Module Message Queue Module vert.x event bus A instance in JVM https://github.com/stalk-io
  • 52.
    3. 분산 서버설계시 알아야 할 것들! ! - Consistent Hashing, Sharding, Proxy, MessageQueue ..
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
    - Consistent Hashing A CD B D C B A D B C A D value
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
    - Consistent Hashing A CD B D C B A D B C A D value
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
    - Consistent Hashing public  class  ConsistentHashT{   ! ConsistentHash.add(‘nodeA’,...);     ! ! ConsistentHash.add(‘nodeB’,...); !   !   !   !   !     !   !   !   !   ! ConsistentHash.add(‘nodeC’,...); !   !   !   !   !   ConsistentHash.add(‘nodeD’,...); !   !   !   } private  final  HashFunction  hashFunction  =  Hashing.md5();   private  final  SortedMapLong,  T  circle  =  new  TreeMapLong,  T();   public  void  add(String  name,  T  node)  {           circle.put(hashFunction.hashString(name).asLong(),node);       }   public  void  remove(String  name)  {           circle.remove(hashFunction.hashString(name).asLong());       }   public  T  get(String  value)  {     long  hash  =  hashFunction.hashString(value).asLong();     if  (!circle.containsKey(hash))  {       SortedMapLong,  T  tailMap  =  circle.tailMap(hash);         }   hash  =  tailMap.isEmpty()?circle.firstKey():tailMap.firstKey();   }   return  circle.get(hash);  
  • 85.
    - Consistent Hashing public  class  ConsistentHashT{   !       private  final  HashFunction  hashFunction  =  Hashing.md5();   private  final  SortedMapLong,  T  circle  =  new  TreeMapLong,  T();   private  final  int  numberOfReplicas  =  100;                               public  void  add(String  name,  T  node)  {     for  (int  i  =  0;  i    numberOfReplicas;  i++)  {       circle.put(hashFunction.hashString(name  +  i).asLong(),node);     }   }   public  void  remove(String  name)  {     for  (int  i  =  0;  i    numberOfReplicas;  i++)  {       circle.remove(hashFunction.hashString(name  +  i).asLong());     }   }   public  T  get(String  value)  {     long  hash  =  hashFunction.hashString(value).asLong();     if  (!circle.containsKey(hash))  {       SortedMapLong,  T  tailMap  =  circle.tailMap(hash);           }       }   !   hash  =  tailMap.isEmpty()?circle.firstKey():tailMap.firstKey();   }   return  circle.get(hash);  
  • 86.
    - Consistent Hashing replics수에 따른 표준편차(standard deviation) 서버
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
    - Sharding Sharding, SharedNothing 데이터 분산 저장 Clients shard #1 shard #2 shard #3 A0392 E1112 J9918 A2331 G0031 K2218 C1212 G9287 O2290 ..... Replication Sharding
  • 104.
    - Sharding Sharding, SharedNothing 데이터 분산 저장 G9287 C1212 O2290 Clients shard #1 shard #2 shard #3 A0392 E1112 J9918 A2331 G0031 K2218 C1212 G9287 O2290 A- ~ D- E- ~ I- J- ~ .....
  • 105.
    - Sharding Sharding, SharedNothing 데이터 분산 저장 Clients Fn(key) shard #1 shard #2 shard #3 G0031 O2290 G9287 K2281 A0392 A2331 C1212 J9918 E1122 Consistent Hashing .....
  • 106.
    - Work Queueing MessageQueue, Workers Worker Verticle 은 별도의 프로세스로 비동기/분산 실행한다. Job
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
    - Caching Front-End Caching StaticContents 만 Cache 하고 Dynamic Contents 는 Cache 하지 않는다. varnish varnish HAProxy Application
 Server HAProxy HAProxy HAProxy HAProxy
  • 114.
  • 115.
  • 116.
  • 117.
    - epilogue Object Oriented
 에서 Programming Functional Programming 로 바뀌고 있는가 ? XML 말고, JSON 사용해야 하는가 ? Java 를 배우는가, Spring Framework 를 배우는가 ? VI 와 TMUX 를 사용하는가 ?
  • 118.
    - Speaker 김요한! • LGCNS SI 프로젝트 분석/ 설계/개발/아키텍트 등 다양한 경험! • 최근 오픈소스를 활용한 분산 아키텍처 설계/ 개발 진행중! • 오픈소스포럼, S/W아키텍처대회, DEVIEW, JCO 등 발표! • NIPA 오픈프론티어 1기! • xpush 프로젝트 - 2014 06 release !! yohany@gmail.com! https://www.facebook.com/JohnKim0331!
  • 119.