JUST THE RIGHT AMOUNT
Lagom- [lah-gome], a swedish word meaning ‘Sufficient’ or ‘Just the right amount’.
The meaning of the name ‘Microservice’ is misunderstood by a majority of people. Taking it litrelly Micro = very small i.e. very small service is not the underlying meaning or agenda of creating Microservices. The real theme here does not revolves around the ‘size’ criteria. What really matters here is the ‘architecture‘. Lagom is created to help clear this misunderstanding and it provides the structure applications need to embrace asynchronous messaging, distributed persistence, and eventual consistency. This is all wrapped up in a productive development environment that makes it easy to launch your services and data stores, with automatic reloading when the code in one of your services changes.
According to Lightbend the focus should not be on how small the services are, but instead they should be just the right size, “Lagom” size services.
Lagom is an open source framework built with the shifting from monoliths to microservices-driven application architecture in mind. It abstracts the complexity of building, running and monitoring microservices driven applications.
UNDER THE HOOD
Behind the scenes, Lagom framework uses the Play Framework, an Akka message-driven runtime, Kafka for decoupling services, Event Sourcing, and CQRS patterns, and ConductR support for monitoring and scaling microservices in the container environment.
Lagom gives you an opiniated view on how to build Microservices that adhere to reactive stack. Lagom is built with Akka and play to make it fully asynchronous and unblocking at its core. To make it easier with this pattern to build systems that are truely reactive, it is advised to use Event Sourcing and CQRS.
There are three main principles on which Lagom is designed:
- Message-Driven and Asynchronous: By default it is asynchronous as it uses asynchronous IO capabilities of Akka Streams for asynchronous streaming and the JDK8 API for asynchronous computation.
- Distributed persistence: Lagom favours distributed persistence patterns using Event Sourcing with Command Query Responsibility Segregation (CQRS).
- Developer productivity: Starting all microservices with a single command, code hot reloading and expressive service interface declarations are some examples of Lagom’s high emphasis on developer productivity.
Lagom consists of these core technologies and frameworks:
- Play Framework
- Akka and Akka Persistence
It works as an abstraction layer over these so the developer does not need to know Play Framework and Akka in deep in order to successfully use Lagom. Sbt has been chosen as the build tool because it also acts as a development environment and it offers many handy features to Lagom such as fast incremental recompilation, hot code reloading, starting and stopping services in parallel and automatic injection of configuration defaults.. Lagom relies heavily on the following sbt features:
- Fine-grained tasks
- Each task may return a value
- The value returned by a task may be consumed by other tasks
Lagom offers four main features:
- Service API: declaring and implementing service interfaces
- Persistence API: provides event-sourced persistent entities for services storing data
- Development Environment: to run all your services with one command
We will see in these in detail in upcoming blogs
Hope it helped.