KEMBAR78
Cache in API Gateway | PPTX
Gilwon Oh
2015.04.17 v1.0
 책임
 Full Stack 개발자 지향
 https://medium.com/@kobi97
 kobi97@gmail.com
 Guess? (For Fun)
 Cache
 API Gateway
 Cache In API Gateway
 Conclusion & Useful Links
 Guess? (For Fun)
 Cache
 API Gateway
 Cache In API Gateway
 Conclusion & Useful Links
서울~부산(뉴욕) 까지 걸어서
몇 시간 걸릴까요?
서울 에서 뉴욕 PC의 사진을
1,000장 다운로드 하는데
얼마나 걸릴까요?
AWS EC2 JP Tokyo에 설치를
하면 미국 West, East
어느 Zone에 설치하는 것이
더 빠를까요?
AWS EC2의 JP <-> JP,
JP <-> Singapore, JP <-> US
각각의 경우에 Delay는 얼마
정도 생길까요?
우리 나라에서 해외로 연결된
해저 광 케이블 망이 있는 곳
은?
나의 Local Disk에서 데이터를
읽는 것과 vs 내 PC에서 일본 PC
Memory 안에 있는 데이터를
읽으면 대략 속도 차이가
얼마 정도 날까요?
도로원표: 도시간의 거리를 측정할 때는 사용
천문단위(AU): 지구에서 태양까지의 거리 (약 150,000,000 Km)
지구 한 바퀴: 약 40,000 km (반지름: 6,400km)
지구에서 달: 약 384,400 km
광속 : 진공 상태에서 빛이 나아가는 속도 (약 300,000 km/s)
음속: 시속 1,224km 음속이 초당 340미터(섭씨 15도)
마하: 소리의 속도에 비해서 얼마나 빠른지
http://study.zum.com/book/13481
http://www.cablemap.info http://ora24.cafe24.com/Science/E_Signal.htm
전기 전달되는 속도 = 빛의 속도
태안
거제
부산
http://www.turnkeylinux.org/blog/aws-datacenters
https://twitter.com/rzezeski/status/398306728263315456
(*1 ms: 10−3 1 μs: 10−6 1 ns: 10⁻⁹
Millennia(Millennium): 1000 years )
 Guess? (For Fun)
 Cache
 API Gateway
 Cache In API Gateway
 Conclusion & Useful Links
DBWASClient WEB
HTTP Cache
. Browser caches
. Proxy caches
. Gateway caches(reverse proxy cache)
DNS Cache
…
CPU Cache
Page Cache
Disk Cache
...
DB Internal Cache
Focus on
WebService Cache
Especially API Gateway
*Java Cache 표준 (Jboss inifinispan 주도)
JSR 107 : JCACHE - Java Temporary Caching API
JSR 347 : Data Grids for the Java platform (2015.1 withdrawal OTL)
Replication
Cache
Invalidation
Cache
Distribution
+L1 Cache
Distribution
Cache
Local
Cache
http://www.slideshare.net/opennaru/in-memory-data-grid-infinispanjboss-data-grid
Focus on
Distribution +
Local Cache 유지
Local Cache+
데이터 변경시 다른
서버 동일키 삭제
Cache 공유 X 모든 Cache 동일 복제
Cache 1/n으로 분산,
Cache 없으면 다른 Node에 물어봄
General Hash
(ex: Elasticsearch shards)
vs Consistent Hashing
(ex: infinspan, memcache)
Cache Aside Pattern
Client가 R/W Storage
책임
Storage
Client
Cache
Write-behind Pattern
비동기적으로 Storage
Write (보통 delay 세팅
시간 후)
Storage
Client
Cache
Read Through/
Write Through
Cache가 R/W
Storage 책임
Storage
Client
Cache
Refresh-Ahead Pattern
주기적으로 최근에 접근
한 cache Data를 Reload
Storage
Client
Cache
http://www.slideshare.net/tmatyashovsky/from-cache-to-in-memory-data-grid-introduction-to-hazelcast
http://docs.oracle.com/cd/E15357_01/coh.360/e15723/cache_rtwtwbra.htm#COHDG5181
 Guess? (For Fun)
 Cache
 API Gateway
 Cache In API Gateway
 Conclusion & Useful Links
API-G #1
API-G #2
4. Check
Throttling &
API Burst
1. API Call 2. API Validation
3. 2 Auth.
5. Mediation
Service #1
Service #2
Service #3
……
6. Target Service Call
Storage
#1
Storage
#2
Interface
WAS #1
API-G
WAS #1
API-G
WAS #2
Interface
WAS #2
Use Remote Cache
4. Check
Throttling &
API Burst
1. API Call 2. API Validation
3. 2 Auth.
5. Mediation
Service #1
Service #2
Service #3
……
6. Target Service Call
Management
Center #1,2
Internal Interface
API Use Flow
CRUD: API Infra Data
How To use cache?
DB DB
Storage
#1
Storage
#2
 Guess? (For Fun)
 Cache
 API Gateway
 Cache In API Gateway
 Conclusion & Useful Links
Interface
WAS #1
Cache
Interface
WAS #2
Cache
Cache Replication
Use Remote Cache
Management
Center #1,2
Internal Interface
API Use Flow
CRUD: API Infra Data
DB DB
API-G
WAS #1
Cache
API-G
WAS #2
Cache
Redis
(Slave)
Redis
(Master)
4. Check
Throttling &
API Burst
1. API Call 2. API Validation
3. 2 Auth.
5. Mediation
Service #1
Service #2
Service #3
……
6. Target Service Call
Use Ehcache-RMI P2P
Use Redis-Sentinel
JPN USA
Use Replication Cache?
Infinispan vs Hazlecast vs Ehcache-jGroups
Gossip
Router #1
Gossip
Router #2
JPN USA
Use Ehcache-JGroups
Ehcache-JGroups
Maybe almost same as
Infinispan library mode
Cache in API Gateway
|- Infra Data(Replication Cache)
|- Ehcache-RMI
|- Ehcache-JGroups (*Infinspan)
|- API Burst & Throttling
|- Redis, Redis-Sentinel(*Redis-Cluster)
|- Http Cache (SKIP)
https://tedwon.atlassian.net/wiki/display/SE/Ehcache+Replicated+Cache
http://www.slideshare.net/HyeonSeokChoi/overview-of-the-ehcache
http://www.nextree.co.kr/p3151/ (아키텍처 설계: 분산캐시-EhCache+TerracottaServer Array)
http://www.slideshare.net/alexmiller/scaling-your-cache
http://ehcache.org/documentation/2.8/get-started/getting-started
 http://www.slideshare.net/charsyam2/webservice-cache-strategy
http://www.slideshare.net/charsyam2/cache-governancepub
http://www.slideshare.net/charsyam2/redis-edu-1
http://www.slideshare.net/charsyam2/redis-edu-2
http://www.slideshare.net/charsyam2/redis-edu-3
http://www.slideshare.net/charsyam2/redis-edu-4
http://www.slideshare.net/charsyam2/redis-edu-5
 http://www.slideshare.net/krisjeong/this-is-redis-kor-slideshare
http://www.slideshare.net/krisjeong/redis-data-design-by
 http://www.joinc.co.kr/modules/moniwiki/wiki.php/man/12/REDIS/DataModeling
http://www.slideshare.net/Byungwook/redis-data-modeling-examples
 http://www.mimul.com/pebble/default/2012/09/28/1348812530141.html
 http://www.slideshare.net/opennaru/in-memory-data-grid-infinispanjboss-data-grid
http://bcho.tistory.com/m/post/883
 http://www.slideshare.net/jaehongc/jco-2014?related=1 (인피니스팬데이터그리드
따라잡기 (@JCO 2014) )
 이제 필요한 것은 In Memory Data Grid
http://helloworld.naver.com/helloworld/106824
 in memory computing
http://blog.lgcns.com/176
 https://labs.consol.de/java-caches (Ehcache vs Hazelcast vs Infinispan)
 http://www.slideshare.net/tmatyashovsky/from-cache-to-in-memory-data-grid-
introduction-to-hazelcast
 http://www.slideshare.net/tmatyashovsky/distributed-applications-using-
hazelcast?from_m_app=android
 http://blog.ragozin.info/2009/04/caches-are-everywhere.html
 http://cutajar.weebly.com/not-a-blog/caching-techniques
 확장성 있는 웹 아키텍처와 분산 시스템
http://helloworld.naver.com/helloworld/textyle/206816
 확장 가능한 분산 인 메모리 캐시를 제공하는 ElastiCache
http://pyrasis.com/book/TheArtOfAmazonWebServices/Chapter15
 분산 메모리기반 플랫폼 Plandas # Cache Cloud http://readme.skplanet.com/?p=8884
 http://knowledgecloud.tistory.com/entry/EC2-에서-클러스터링-시-유연한-설정-가져가기
한글자료가 거의 없어요
(Y.Y)(T.T)
네트웍 기초가
튼튼해야함
-맛보기로 살짝 소개-
GROUP
(within the same LAN, or across a WAN)
Process
Process
Process
message
Process
join
leave or crash
message
It consists of 3 parts:
(1) Channel
used by application programmers to build
reliable group communication applications
(2) Building blocks
layered on top of the channel and
provide a higher abstraction level
(3) Protocol stack
protocols implements the properties specified
for a given channel.
Application
Building blocks
JChannel
GMS
MERGE
FRAG
UDP/TCP
Network
Figure 1.1 the architecture of JGroups
Application
Building blocks
JChannel
GMS
MERGE
FRAG
UDP/TCP
Network
Figure 1.1 the architecture of JGroups
send()
Message delivery
receive() callback
Network listen
Transport
protocol
Topmost
protocol
connect
/disconn.
start
/stop
close
destory
(release)
Message delivery
Protocol List
Transport UDP, TCP, Tunnnel
Initial membership
discovery
PING, TCPPING, TCPGOSSIP, MPING, FILE_PING, JDBC_PING, BPING, RACKSPACE_PING, S3_PING,
SWIFT_PING, AWS_PING, PDC(Persistent Discovery Cache)
Merging after a network
partition
MERGE2, MERGE3
Failure Detection FD, FD_ALL, FD_SOCK, FD_PING, VERIFY_SUSPECT
Reliable Message
Transmission
Pbcast.NAKACK, NAKACK2, UNICAST, UNICAST2, UNICAST3, RSVP
Message stability STABLE
Group Membership Pbcast.GMS
Flow control FC, MFC, UFC
Fragmentation FRAG, FRAG2
Ordering SEQUENCE, Total Order Anycast(TOA)
State Transfer Pbcast.STATE_TRANSFER, StreamingStateTransfer, pbcast.STATE, STATE_SOCK, BARRIER
Pbcast.FLUSH
Misc Statistics, Security, COMPRESS, SCOPE, RELAY, RELAY2, STOMP, DAISYCHAIN, RATE_LIMITER, Locking
protocols, CENTRAL_EXECUTOR, COUNTER, SUPERVISOR
GROUP View
api-g1-9235(coordinator)
api-g2-32349
api-g3-23412
Channel
(api-g1-29235)
Channel
(api-g2-32349)
Channel
(api-g3-23412)
FD_SOCK
FD
VERIFY_SUSPECT
GMS
GMS
VERIFY_SUSPECT
FD
FD_SOCK
FD_SOCK
FD
VERIFY_SUSPECT
GMS
FD HeartBeat
FD HeartBeat FD HeartBeat
FD Sock Connection
FD Sock Connection FailFD Sock Connection
SUSPECT
ping
1
2
3
4 view changing
Thank You!

Cache in API Gateway