Want to expose an API? Reactive Options

Table of contents
Reading Time: 3 minutes

In the modern digital world, a system which cannot talk to other systems or does not allow other systems to talk to itself is bound to fail. A lot of organizations that we work with be it large banks, healthcare institutions, travel booking and predictions, industrial analysers, would like to expose their ecosystem through an API so that it is available as a platform for other companies and products to consume and innovate on.

In the reactive world, we have a few easily available options based on the need. As you would expect these are powered by Akka the amazing technology which drives games like Fortnite 😉

Let us look at an executive summary of the options that we have

Screenshot from 2019-02-05 20-31-53
The reactive API ecosystem
  1. Play – Use this if you are building a new REST API and are coming from Spring MVC or you your system does involve web UI
  2. Akka HTTP – If you would like to wrap an existing application/system with API endpoints. It is simple and flexible.
  3. Lagom – If you need a full powered microservices system which comes bundled with the goodies like ES/CQRS, best practices like DDD etc

Of course, you can use Akka, Akka Streams, Alpakka, Akka gRPC etc with any of these.

Now let us look at each one of them in a little more detail

Play

  • Built on top of Akka and Akka HTTP
  • Supports building HTML based user interfaces
  • Based on the MVC model
  • Used to build CRUD style applications, API gateways, Web UI
  • Key features like authentication, authorization, integration with other databases provided

Akka HTTP

  • Based on Akka to provide asynchronous and non-blocking HTTP servers
  • Supports streaming APIs with Akka streams and reactive streams
  • Client-side API provides the same level of asynchronous, non-blocking and streaming support
  • Provides high level and low-level routing
  • Used primarily to add lightweight REST/HTTP endpoints to an application or build rich HTTP servers

Lagom

  • Built on top of Akka cluster and Play
  • RPC style communication between microservices
  • Integration with queueing mechanisms like Kafka
  • Entities based on the model of Domain Driven Design
  • ES/CQRS built-in
  • Abstraction for service location to enable integration with Kubernetes, DNS, Zookeeper etc
  • The primary use case is to build microservices based systems based on the RPC style

As you would notice in all of the above, the powerhouse is Akka. Let us quickly talk about Akka as well

Akka

  • Toolkit based on actor model to simplify concurrency and improve resource usage
  • Akka cluster includes sharding, CRDT, cluster wider singletons, routers etc
  • Akka streams provide streaming endpoints and are optimised to work with streaming data, based on the Reactive Streams
  • Alpakka provides endpoints to integrate with a large number of external technologies

If you are still unsure about why to use Akka and not stay with Spring, refer to this post.

Summary

Systems today need to be built as platforms. They would need to interact with other systems and expose endpoints which other systems would be able to consume and innovate on. They would need to support key features like asynchronous communication, non-blocking calls, optimal utilization of resources so as to stay resilient in a webscale world. Do not build systems today which would not follow the motivations of the reactive manifesto. Talk to Knoldus.

Written by 

Vikas is the CEO and Co-Founder of Knoldus Inc. Knoldus does niche Reactive and Big Data product development on Scala, Spark, and Functional Java. Knoldus has a strong focus on software craftsmanship which ensures high-quality software development. It partners with the best in the industry like Lightbend (Scala Ecosystem), Databricks (Spark Ecosystem), Confluent (Kafka) and Datastax (Cassandra). Vikas has been working in the cutting edge tech industry for 20+ years. He was an ardent fan of Java with multiple high load enterprise systems to boast of till he met Scala. His current passions include utilizing the power of Scala, Akka and Play to make Reactive and Big Data systems for niche startups and enterprises who would like to change the way software is developed. To know more, send a mail to hello@knoldus.com or visit www.knoldus.com

1 thought on “Want to expose an API? Reactive Options3 min read

Comments are closed.

Discover more from Knoldus Blogs

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

Continue reading