Lightbend Podcast: When To Use Play, Lagom, Or Akka HTTP For Your Project
When To Choose Akka HTTP, Lagom Framework, Or Play Framework?Listen on Soundcloud
Hundreds of thousands of developers are building amazing systems with Lightbend technologies, but some specific tools are better for particular use cases. So how choose the right tool for the job? In this podcast with Wade Waldron, Microservices Practice Lead at Lightbend, we discuss why it’s important to consider your use case, your team, and your environment.
Some questions to ask yourself:
- Are you building a REST API?
- Are you building a GUI?
- Would you prefer to explicitly make HTTP calls between services? Or are you looking for something more like Remote Procedure Calls (RPC)?
- Are you planning to build using Command Query Responsibility Segregation (CQRS) or Event Sourcing (ES)?
- Does your team prefer to work at a low level, understanding all the details of what is happening? Or do they prefer the framework to handle those details transparently?
Depending on your answers to these questions, you can figure out whether Play Framework, Lagom Framework, or Akka HTTP is the right technology for your use case.
When should developers consider starting with Play Framework?
Play Framework is a web development framework that empowers developers to build highly scalable, lightning-fast applications with an ease unparalleled on the JVM. Play is built on top of Akka and Akka HTTP, and based on an MVC programming model that should be familiar to many Java and Scala developers.
Play focuses on enabling developers to build HTML-based user interfaces. It also offers tools to create fully-featured REST APIs as well as plugins to support important features such as authorization, integration with databases, etc.
With the above in mind, we often recommend our clients use Play Framework for the following use cases:
- Web-based user interfaces (GUIs)
- REST-based microservices
- API Gateways
- CRUD-style applications
When should developers consider starting with Lagom Framework?
Lagom Framework helps developers build microservices as systems — Reactive systems, to be precise — so that your microservices are elastic and resilient from within. Lagom is built on top of Play Framework and Akka Cluster, with a programming model based on an RPC style to simplify communication between microservices as well as a persistence layer based on the concept of Entities as described by Domain Driven Design.
Lagom is designed to support RPC-style communication between microservices, including Command Query Responsibility Segregation (CQRS) and Event Sourcing (ES). Lagom features integration with Apache Kafka and Apache Cassandra, plus abstractions for Service Location for integrating with DNS, Kubernetes, Zookeeper etc.
We often recommend that our clients adopt Lagom Framework if their use cases are specifically focused on:
- RPC-style, backend microservices
- CQRS/ES persistence strategies
When should developers consider starting with Akka HTTP?
Akka HTTP is a Reactive Streams compliant toolkit based on Akka Streams that implements a fully asynchronous and non-blocking server- and client-side HTTP stack. The programming model of Akka HTTP provides both a high level routing DSL, and a low level API. While it uses Akka Actors and the Actor model under the hood, it’s APIs hide this from the end user.
Akka HTTP is a suite of libraries, rather than a framework like Play and Lagom–interaction with a browser is in the scope, but it is not its primary focus. Akka HTTP is geared towards flexibility with integration layers, rather than application cores. It includes built-in support for streaming APIs with Akka Streams and Reactive Streams, with a client-side API providing the same asynchronous, non-blocking and streaming support.
We often recommend our clients work with Akka HTTP for the following use cases:
- Adding small, lightweight REST/HTTP endpoints to applications.
- Building rich HTTP servers where flexibility is more important than simplicity.
It seems like everything has Akka under the hood. So when should developers look at Akka specifically?
Akka is an actor-based, message-driven runtime for managing concurrency, elasticity and resilience on the JVM, featuring first-class support for Java and Scala. The programming model behind Akka is based on the Actor model, with Akka Streams based on Reactive Streams to provide a model that is optimized for working with streaming data.
Akka uses the Actor model to simplify concurrency and improve resource usage, providing cluster features including Sharding, Conflict-Free Replicated Data Types (CRDTs), gRPC, routers, and more. It also includes Akka Streams for supporting streaming data with non-blocking back-pressure, and Alpakka to provide Akka Streams endpoints integrating with a variety of external technologies.
- We recommend integrating Akka to clients that are already using other Lightbend technologies like Akka HTTP, Play, or Lagom for their applications and would like to achieve the following use cases:
- Optimizing resource usage in monolithic, or microservice applications.
- Implementing scalable systems that overcome the limitations of traditional applications.
- Providing integration with streaming data sources.
Whether you start with Akka, Lagom, or Play you can add these features later as needed. These are only guidelines that have worked for Lightend clients, and other factors may influence the decision.
We hope you enjoyed this interview and article. If you’d like to speak to someone at Lightbend about using these technologies in your enterprise systems, simply contact us!