API-driven and microservice-based: What do they mean?
There are many jargons in today’s world of business and technology. Cloud, AI, and machine learning are some of them. Here, we will look at API (application-programming interface) and microservices.
Let me try demystifying these terms.
What does it mean for a solution to be API-driven? It means that there is an easy way to access the solution’s features or functionalities from an external system without having to deal with the database complexities.
In simple terms, API-driven development is the practice of designing and building APIs first before creating the rest of an application around them. This makes API-driven development different from traditional development strategies, where API design and implementation are usually just one step in the development process, but not the first one in application production.
Typically, APIs allow a programmer to orchestrate a series of steps that result in a business functionality. For example, the data and functions of a CRM system can be accessed by an external system via an API. A simple API call with an identifier (e.g., email address, phone number) can be used to understand the status of a lead. APIs are designed to perform specific tasks with a given set of data points and return other data points or execute an action.
So, what are the benefits of an API-driven architecture?
- Simple access to data and functionality of different systems with relevant, built-in security
- Ability to extend functions and allow orchestration by calling multiple APIs in a workflow
- No need to understand the external system which provides the API in totality, unlike traditional systems
- Multiple systems can call or consume the API to create different business use cases (e.g. query customer information to perform an action)
- Requires only simple maintenance and if implemented properly, provides a standard interface
- Ease to move to cloud and become cloud-agnostic
However, all these benefits do not make API-driven architecture a magic bullet. It does have its drawbacks:
- Security: Like other software objects, an API has to be designed with sufficient security in terms of access, usage, and scope. If the security is compromised, the API can become a potential source of information leakage.
- Consistency and compatibility: A laser-like focus is required when defining an API framework and API data contracts (or calling parameters). Any change to these can potentially disrupt the orchestration by other systems.
- Management: APIs have their own overheads. If not properly sized and managed, they can result in unreliability. For instance, if you have implemented a payment API but your system has limited resources (e.g., CPU power, memory), the gap can lead to error states when the resources available cannot accommodate the number of requests. The good news is that there are now some very efficient API management tools that can address challenges such as this.
- Performance issues: The problem with the synchronous approach is that you have to wait for a response, which makes the services dependent on each other. If one service is running slower or doesn’t respond, it means the service that call it will slow down or fail altogether.
Microservices architecture refers to a technique that enables modern developers to design highly scalable, flexible applications by decomposing the application into discrete services that implement specific business functions.
These services, often described as “loosely coupled,” can then be built, deployed, and scaled independently. Microservices patterns combined with event-driven system will help “loosely couple” instead of doing a hard call. (An API is not required to be called all the time but only when a specific event happens.) This is very similar to having a calling bell. One does not keep going to the gate to see whether there is a visitor. However, once a bell rings, you can let them in.
Microservices architecture has risen in popularity because of its modular nature, which provides flexibility and scalability all while requiring less development effort. Its deployment flexibility as well as the rise of cloud-native, serverless, and function-as-a-service deployment options (e.g., AWS Lambda and Microsoft Azure Cloud Functions), has created the perfect environment for microservices to flourish in today’s IT landscape. These cloud platforms enable microservices and functions to be scaled from inactivity to high volume and back again while customers pay only for the compute capacity they use.
Developers that adopt a microservices approach realize that true scalability is made possible by loose coupling and event-driven architecture. A service can be asynchronous, performing an action, broadcasting a message, and continuing on with its primary function without having to wait for a response from another service. Netflix has done some tremendous work on this.
The following are the key advantages of microservices architecture:
- Supports programming language-agnostic application components
- Supports continuous integration and deployment to improve the agility with which new functionalities are brought in
- Extremely scalable and can support auto-scaling
- Ability to accommodate cloud-native function-as-a-service deployment options
- Lower operational costs (if designed well)
- Isolation and loose coupling enable compartmentalized upgrades and enhancements, thus eliminating the downtime in the traditional model
Again, if not designed properly, it could result in less than ideal business outcomes such as:
- Complexity in handling communication between services: Since everything is now an independent service, one has to carefully handle requests traveling between their modules, which can lead to latency.
- Resource-intensive: It can require painstaking efforts to handle multiple databases and transaction management. Keeping it simple will be key.
- Complex testing and debugging: With microservices, each dependent service needs to be confirmed before testing can occur across all the business apps. Each service has its own set of logs to go through. Log, logs, and more logs.
So, what are the main differences between APIs and microservices:
- An API is a contract that provides guidance for a consumer to use the underlying service.
- A microservice is an architectural design that separates portions of a (usually monolithic) application into small, self-containing services.
If you struggle with integration and want to streamline, an API-driven architecture can help. If you are trying to break down silos and scale beyond traditional API management, microservices-based development with event-driven architecture will push you in the right direction.