Lagom: Getting to Know

Reading Time: 2 minutes

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.

DESIGN PHILOSOPHY

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.

BUILDING BLOCKS

Lagom consists of these core technologies and frameworks:

  • Scala
  • Java
  • Play Framework
  • Akka and Akka Persistence
  • sbt
  • Cassandra
  • Guice
  • ConductR

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

MAIN FEATURES

Lagom offers four main features:

  1. Service API: declaring and implementing service interfaces
  2. Persistence API:  provides event-sourced persistent entities for services storing data
  3. Development Environment: to run all your services with one command

We will see in these in detail in upcoming blogs

Hope it helped.

References: https://www.lagomframework.com/documentation/


KNOLDUS-advt-sticker

Written by 

Anuj Saxena is a software consultant having 6+ years of experience. He is currently working with functional programming languages like Scala and functional Java with the tech stack of Big Data technologies( Spark, Kafka . . .) and Reactive technologies( Akka, Lagom, Cassandra . . .). He has also worked on DevOps tools like DC/OS and Mesos for Deployments. His hobbies include watching movies, anime and he also loves travelling a lot.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading