DEV Community

loading...

Basic Concepts to Understand API, Web Services & Microservices

priyanshi_sharma profile image Priyanshi Sharma ・6 min read

Alt Text

Developers have been using three major building blocks for the development of web apps, namely, APIs, Web Services, and Microservices. Some people are still unaware of the basic concept, usability and working of these app development blocks. So today’s article is entirely dedicated to the individuals who have heard about these terms but are confused about the purpose each has.

Typically, a web application operates with three major components: services, gateway, and controller.

Here, a gateway is a single entry point to the application. It is responsible for authentication, load balancing, monitoring, caching, static response handling and so on whenever a client-side wants to interact with the web application.

While a controller is like a manager that manages incoming requests, decides which worker should do the work, divides the work into smaller tasks, passes that work off, orchestrates the work and sends it back to the client.

The worker mentioned in the controller section is nonetheless the service that receives the request from the manager, figures out the algorithms or logic that will be used to complete the request, only responsible for the work allotted and returns the completed work to the manager.

Fundamental Notions to Know Before Understanding API, Web Services & Microservices

Before we move ahead to understand these three terms, it will be helpful to acknowledge the components web applications have and how they work.

Now let’s assume you are developing a web application for shopping and for that you will need to add a product description page that will not only display the information related to the given product but also display a lot of other information including order history, customer reviews & ratings, low inventory warning, number of items in the cart, shipping options, other products recommendations and alternatives to the current product.

While in the monolithic web app, a client would retrieve this data through a REST call to the application that will trigger a load balancer to route the request to the identical instances of the application that would query numerous databases and then return the response.

On the other hand, in the application using microservices architecture, the data displayed on the product page is owned by different microservices. Some of the microservices that own data of the project page are: Shopping Cart Service, Order Service, Catalog Service, Inventory Service, Shipping Service, Review Service, and Recommendation Service(s).

Now with a clear understanding of how an application works, it’s time to get into the details of APIs, web services and Microservices so that you can clearly know the meaning of these terms that will come ahead and relate to it.

API VS Web Services VS Microservices

What are APIs?

An API (Application Programming Interface) is a communication channel between services and applications. It can be used to call single or multiple services depending upon the architecture of the application. It is a secure way to request and share information, services, and functionalities within both internal and external users.

Simply put, an API is a messenger that takes a request and tells the system what the user wants to do and then returns the response. It is a method of communication between a requester and a host that is mostly accessible through an IP address. It can communicate multiple information to the user, like, data that needs to be shared and the function that needs to be provided.

An API enables the application to communicate with other services or applications without knowing their implementation. It simplifies the app development process while saving both time and money. APIs are a simplified manner to connect an application infrastructure via cloud-native development and also allows sharing of data with customers or other external users.

In short, it opens up access to the resources while maintaining control and security. API security is all about API management that includes the use of an API Gateway. They are of three types: private, public and partner. Private is only used internally in the organization. Public API enables third parties to build an app that interacts with the API of your application, and the partner API is shared with certain business partners to gain additional revenue streams without risking quality.

What are Web Services?

Web services are client & server applications that interact over the World Wide Web’s HyperText Transfer Protocol (HTTP). As outlined by the World Wide Web Consortium (W3C), web services give a standard means of interoperating between software applications operating on a variety of platforms and frameworks. Web services are portrayed by their great extensibility and interoperability, as well as their machine-processable descriptions, thanks to the use of XML. Web services can be combined in a loosely coupled method to perform complex operations.

A web service architecture consists of three distinct roles, that is, provider, requester, or broker. Here a provider informs the broker/service registry about the presence of the web service through the broker’s public interface that makes service accessible to clients and the requestor binds and invokes the services. It is a lightweight service-oriented architecture that supports interoperability.

Simply put, web services are XML-centered data exchange systems that utilize the internet for application-to-application communication and interfacing. A client can call a web service by sending a request via XML and the service then provides an XML response as well.
A web service comprises of these functions:

  • Availability over intranet and internet networks
  • Independence of programming languages and operating systems
  • Self-describing via XML
  • Identifiable via a simple location method
  • Supports communication between apps with HTML, SOAP, WSDL, and XML.

Here, XML tags data, SOAP transfers the message and WSDL describes the accessibility of service.

What are Microservices?

Microservices is an architectural style that structures an application as a collection of services that are loosely coupled, highly maintainable & testable, independently deployable, organized around business capabilities, and are owned by a small team of developers. It supports the frequent, agile, and reliable delivery of complex, large applications.

Where in the SOA architecture, if we had to create a search function, it has to be deployed on a single server where other functions are also residing. The failure of the search service due to any reason can take down the entire application. Whereas, in microservices, all the functions are split into the granular level and each service is deployed on a different server making the service independent of each other. That is, the failure of one or more functions will not affect other parts of the web application. Microservice also offers improved fault tolerance due to its small service constitution.

When a change is needed in a certain part of the application, only the related service is modified and deployed without disturbing the functionality of an entire application. It gives the developers the independence to develop and deploy services independently while using an ideal programming language for service and another language or framework for a different function. It is easier to scale and integrate with third-party services.

With a clear understanding of APIs, Web Services and Microservices, it can be said that there is nothing to compare among the three. While APIs and Webs Services are the communication interface for different architecture styles, microservices are a distinctive method to develop software systems with well-defined interfaces and operability.

And if you are a business owner who wants to develop an application that is based on either of these services and architecture, then you can hire developers who have relevant experience and expertise in the same field.

Source: Decipher

Discussion (7)

Collapse
cheetah100 profile image
Peter Harrison

Web Services are broader than just SOAP based web services. Today REST based web services are the norm, and employed by microservice architecture. The service in microservice is a web service. See here fore more

Collapse
priyanshi_sharma profile image
Priyanshi Sharma Author

Thanks for flagging, I will keep a note for the next one.

Collapse
dev_emmy profile image
nshimiye_emmy

great article

Collapse
priyanshi_sharma profile image
Collapse
priyanshi_sharma profile image
Priyanshi Sharma Author

I am glad that you find the blog helpful☺

Forem Open with the Forem app