One of the challenges of developing and scaling microservice-based applications in large teams is that services are often developed by multiple teams with different frameworks. Let’s take a look at how we can introduce data API gateway, to simplify microservices in your application. We explore the features of a data API gateway, why you should implement it, and how to apply it to your architecture.
Traditional data service pattern
A most common pattern is a layer of data services that perform “CRUD” (create, read, update, delete) operations. This microservices architecture includes a layer of data services which manage specific data types of your application, and a layer of business services which implement specific processes such as payments processing. The business services provide a primary interface to web and mobile applications and delegate the storage and retrieval of data to the data services. These data services are responsible for performing CRUD operations on an underlying database.
While there are many ways of integrating and orchestrating interactions between these services, the basic pattern of separating services responsible for data and business logic has been around since the early days of service-oriented architecture (SOA).
Identifying, designing, and implementing data services
The typical approach to developing these microservices has included steps like the following:
- Identifying services to manage specific data types in the domain using a technique such as domain-driven design.
- Designing services includes APIs and schema to manage assigned data types. Each individual service manages a specific data type and is responsible for data storage, retrieval, and potential messaging or streaming.
- Implementing services using frameworks like Spring Boot to build services with an embedded HTTP server, that are then packaged into VMs or containers.
Data services and polyglot persistence:
As product teams made a move toward large-scale microservices architectures; one consequence was that individual data services were free to select their own databases, a pattern known as polyglot persistence.
Replacing data services with data API gateway:
In creating multiple data services, development teams often find that the implementations are highly similar, almost boilerplate code, due to their focused responsibility of executing simple CRUD operations on top of a database backend. Recognizing this duplication of effort, many organizations have begun to adopt data API gateways as an alternative to maintaining a layer of containerized data services.
A data API gateway is a piece of software infrastructure that provides access to data via APIs of various styles including REST, gRPC, and others. The gateway abstracts the details of storing and retrieving data using one or more persistent stores. This allows application developers to focus on writing business services that access data via easy-to-use APIs instead of having to learn the intricacies of a database query language.
The data API gateway takes on the responsibility of managing data persistence for hotels, rates, inventory, and other data types, eliminating the need for an entire layer of data services.
Data types can be added to the gateway by providing a schema or data model. Alternatively, document-style endpoints can provide a “schema-less” experience in which any valid JSON document can be stored, such as a hotel description, the structure of which could change frequently.
For this reason, adopting a data API gateway is quite similar to implementing the data services pattern. The design consists of identifying key data types and creating schema or JSON formats to describe them. These data types are then made available via APIs provided by the gateway.
Comparing API Styles
Data API gateways provide developers the freedom to access data types through the API that makes the most sense for their client services and applications.
API styles like gRPC provide more structured data representations which can lead to more optimal performance. GraphQL and REST APIs provide more flexibility in how data is represented at the cost of additional latency. The maximum flexibility is provided by document-style APIs which can store and search JSON in whatever format the client chooses, at the cost of potentially lower performance for more complex queries.
Conclusion:
The data API gateway is a new type of data infrastructure which can help eliminate layers of CRUD-style microservices that you have to develop and maintain. While there are multiple styles of gateway, they have a common set of features that benefit both developers and operators. Data API gateways enable developer productivity by providing a variety of API styles over a single supporting database. Adopting a data API gateway is a great way to reduce development and maintenance cost for microservices architectures.
If you are looking for experts to help you scale and monetize API, our software specialists can work with your CTOs and product teams to build the right solutions to overcome your business challenges.