Lagom Framework
for Reactive Microservices
김명주
bansuk78@naver.com
- 인터넷쇼핑몰 상품도메인 서버 개발자
- 아내 & 늦둥이 아들(21개월)과 성북구 거주 중
저는 오늘 꽤 괜찮은 곰 하나를 소개하러 나왔습니다.
L.A.Gom?
https://www.fws.gov/lafayette/images/ESD_NO_Zoo_LA_Bear.jpg
Lagom : ‘just enough’
(라곰: 적당한 조화와 균형을 나타내는 스웨덴어)
http://momo96841.tistory.com/38
InforWorld Feb 23, 2016
Java finally gets microservices tools
(Java가 마침내 마이크로서비스 툴을 얻다)
Lightbend's Lagom framework helps java developers
create and manage microservices architectures. - By
Paul Krill
- Microservices-based architectures
- Built on the Scala functional language
- Lagom would compete with the Spring
Boot application platform in some areas
What is Lagom?
• Microservices architecture
• CQRS
• Event Sourcing
Lagom Architecture
Microservices Architecture
https://martinfowler.com/articles/microservices.html
https://docs.microsoft.com/en-us/azure/architecture/patterns/cqrs
CQRS – Command Query Responsibility Segregations
https://docs.microsoft.com/en-us/azure/architecture/patterns/event-sourcing
Event Sourcing
about Lagom
• Microservices framework for a system of microservices
• Based on the Reactive Manifesto
• A fully integrated development environment
• Asynchronous & non blocking (default)
• Distributed persistence (Event Sourcing & CQRS)
Language
• Core of framework written in Scala
• Developments are in Java, Scala(since v1.3.1)
Components
• Java8(& Scala)
• Immutables
• SBT
• Jackson
• Cassandra
• Play framework
• Guice
• Akka
• SLF4J & Logback
Features
• Service API
• Persistence API
• Developments Environment
• Production Environment
Service API
• Interface as descriptor
• Defined API of exposed service
Persistence API
• Event-sourced Entities
• CQRS ReadSide
• Entry point for events handlers
Developments Environment
• One command to start all > sbt runAll
• Hot reload code
• IDE Integration
Production Environment
• ConductR
• Scaling
• Deployment
• Monitoring
Service Flow
shop-api
shop-impl
Command
Event
State
ReadSideProcessor Read data
store
Request
Write data
store
Message Queue
PersistentEntity
Project Structure
Demo
개발하면서 느낀 점
• 성능이 좋다는데 아직 측정은 못해봤음 (당연한 얘기지만 Cluster를 늘
리면 늘릴수록 성능이 좋아진다는 자료가 있음)
• 람다식 공부하기에 이보다 좋은 건 없을 듯
• 비동기식 코드에 동기식 코드를 넣지말라
(CompletableFuture<U>.get())
• 디버깅이 어렵다 (로그를 최대한 많이 남겨라 – Thread 번호로 확인)
• Scala를 알아야…(‘printStackTrace()’ 를 따라가다 보면 어김 없이 만나게
되는 Scala 코드)
• NoSQL은 역시나 비정규화로 인한 엄청난 중복 데이터가 발생 (관리의
어려움)
이런 분들께 권합니다.
- 호기심이 많아 새로운 것을 보면 그냥
지나치지 못하시는 분들
- 극한?의 람다식을 경험하고
Reactive(Asynchronous & non blocking),
ES & CQRS에 자연스레 익숙해 지고
싶으신 분들
- 대용량 처리가 필요한 Microservices를
개발하시려는 분들
선택은 개발자의 몫
감사합니다.
References
• https://www.lagomframework.com
• http://www.infoworld.com/article/3036518/application-
development/java-finally-gets-microservices-tools.htm
• https://martinfowler.com/articles/microservices.html
• https://docs.microsoft.com/en-
us/azure/architecture/patterns/cqrs
• https://docs.microsoft.com/en-
us/azure/architecture/patterns/event-sourcing

Lagom framework