What is the difference between an API and Microservice? - api

I create my API rest with Django, but I don't understand how convert an API to micro services, I don't understand the real difference between these.
I see an API like a micro service, but I don't know convert an entire API in micro service, I need create micro web servers?
Please, I can't understand a micro services, and I need understand this.

A microservice exposes it's interface, what it can do, by means of an API. The API is the list of all endpoints that a microservice respond when it receives a command/query. The microservice contains the API and other internal+hidden things that it uses to respond to client's requests.
An API is all that the clients see when they look at the microservice, although the microservice is bigger than that. A microservice hides its internal structure, it's technology stack, it's database type (sql, nosql - it could be anything); a microservice could move from sql to nosql, from python to php, but keep it's API unchanged.

API - It a way of exposing functionality over web. Imagine you have developed some functionality in .Net but not you are developing some software in a different language. Would you develop the same functionality again? No. So, just expose it via web service.Web services are not tied to any one operating system or programming language. For example, an application developed in Java can communicate with the one developed in C#, Android, etc., and vice versa.
Microservice - They are used to break a complex software into small pieces of individually deployable, testable, loosely coupled sub-modules. Micro Services are designed to cope with failure and breakdowns of large applications. Since multiple unique services are communicating together, it may happen that a particular service fails, but the overall larger applications remain unaffected by the failure of a single module.
API Vs Microservice - Now that we have broken our complex software into loosely couple sub-modules. These sub-modules communicate with each other via an API. Therefore, Microservices and an API solve different problems but works together!
More Details:
The Difference between Web Services and Micro Services
RESTful API vs Microservice

a microservice is an autonomous RESTful service. It means, there is just one service on each server. In Spring Boot when you bootstrap your RESTful service, it will get an instance of tomcat(it's embedded tomcat) and run your service on it. So, if you have more than one service on a server, it is not a microservice, because these services are not autonomous.

Related

Event Driven Architecture - backend services with two interfaces (interface types)

Several articles about Event Driven Architectures recommend an event broker (for example Kafka via topics) to integrate backend services and in addition RESTful interfaces for these backend services (here an example from Guido Schmutz: Building event-driven (Micro)Services with Apache Kafka, 2019, p. 19).
The RESTful interfaces provide access for GUI and external services. These GUI and external services access the RESTful services via an API Gateway. So each backend service has two interface types: a RESTful interface and a channel interface (event broker).
My question is: what are the advantages of providing RESTful API in addition / in parallel to the integration of backend services via an event broker? The reason for this question is that the event broker could provide the same capabilities (synchronous request response).
You're correct, the event broker could provide the same capability: one of the purposes of an API Gateway is to perform 'protocol translation'.
The advantage of using a RESTful API for your 'frontline' microservices depends significantly on your specific situation. Interestingly, there is nothing stopping you from providing a RESTful API via an event broker (REST is explicitly protocol agnostic). However, if by RESTful you mean over HTTP, then there may be benefits to using this protocol. As an example, if you intend for your microservices to be consumed by 'other' clients, then (despite the rise in event-driven architecture) HTTP is still objectively the most ubiquitous protocol in existence.
This is very subjective, but 'request-response' is an afterthought for event-based frameworks. If you want to follow that model, you might be best served using frameworks and technologies that are designed for it.
As you mentioned, you can of course provide a RESTful API in parallel. If this is appropriate really depends on your use-cases.
My two cents: use whatever architecture is easiest and makes the most sense for you behind your API Gateway. The Gateway provides abstraction, so if the approach you take doesn't work out, you can change with little impact.

What do I have here? API or Web Service

I have a project for Master's Degree: design and implementation of web services for an elearning platform.
Now, I know that there are two main architectures for web services: SOAP, and REST
Now, I wanted to use REST architecture, so normally I would have something called "RESTful web services", so I started development with Django and Django Rest Framework
Now, this is the part where I get confused, Is this an API or Web Services
If it is an API, then how can I develop RESTful Web Services?
If it is both, please explain more if you could.
I'm very confused about this, and each time I try to understand, I get more confused, Please can someone clarify this to me?
An application programming interface (API) allows you to interact with a component, system, or resource. It's a very broad concept. To understand it, the emphasis should be placed on the word interface:
In computing, an interface is a shared boundary across which two or more separate components of a computer system exchange information. The exchange can be between software, computer hardware, peripheral devices, humans, and combinations of these.
When you need something from a component or you want it to do something for you, you don't just go in it and do it yourself, you "ask it" for that something or for that action by interfacing with it. The interface of the component says what it can do for you or what you can invoke from the component.
In regards to web services, you have to understand that a web service is in fact an API, because it's an interface with some component (in this case whatever is behind the web service itself: it can be a database, an application, a system, etc).
Like I said, an API is a very broad term. When you say web service, you are adding some restrictions to that term. For example, a web service is invoked over the network. Not all APIs are like this. Some API's can be exposed as libraries, or frameworks that you call directly from your code as methods or functions. So all web services are APIs, but not all APIs are web services.
If you want to build a web service, you can implement it with REST or with SOAP. There is a difference between the two (REST is an architectural style, while SOAP is a protocol), but as concepts they work the same: they provide an interface with which to interact over the network, i.e. an API. But since you are using Django, thus Python, I suggest you go the REST way, not SOAP (support for SOAP in Python isn't all that great).

Using RabbitMQ for communication in a Microservice architecture but should I create a API Gateway on top?

I basically have a smaller software that is using the Microservice architecture. I am currently using RabbitMQ to do the communication between UI and services and that works great.
However I am thinking about creating a new microservice, a API Gateway, that basically takes the RabbitMQ logic from the UI and encapsulate into a service, which would become the entry point to all the other services.
The benefit is that I would encapsulate the logic that give access to the services and also being able to add authentication in the API Gateway.
However I would need to use HTTP request to interact with the API as I am moving the messaging logic from the UI. Could there be any major drawbacks in this approach?
I have being able to find examples about RabbitMQ and examples about API Gateways but never those two together, I might just be overthinking it a bit.

Multi-client architecture advice for RavenDB

When catering for multiple .NET Client Applications - say - Web, Desktop and then throw in an Android app (Java), placing the business logic behind some WCF REST API services can make it easier and quicker to build applications, as there is no business logic to implement client side for each technology.
(I know that there will be a point of changing the UI to cater for new business logic, but the idea is the core of the system sits behind an API, not in the client application.)
Although RavenDB serves as the Storage Mechanism...
What is the general architectural advice of using RavenDB behind SOA services? Is it just your standard IDocumentStore/IDocumentSession behind the WCF instance and go from there?
Yes, you can just use it like that.
Note that RavenDB comes with clients for both .NET and Java.

Understanding WCF from a layman's point of view

I am relatively new to WCF. I am developing Web application.
I am trying to understanding "Why WCF" and read many articles .
But in many places it has been mentioned "to developed service oriented architecture ,to asynchronously send data" without any detailed explanation / any basic example.
Can somebody please let me know one simple example in layman's term ,"Why WCF" so that I can appreciate its existence.
I have had conversations with many people but none of them were able to answer this basic question.
I am also aware that ,many hundreds of applications have gone live before WCF was there...
Suppose, you do have a task to make a procedure of recieving of the coordinate point (lat,lon) and and returning the picture of the surrounding area. Or to make a language translator from voise input to text output. These jobs could uses several servers with a lot of data and could makes some huge mathimatic calculations. But you procedure should me quick, platform independend, secured, protocol-independent, consumed by different technologies (Web, Mobile, Applications). And at the same time it should be easy to consume by the end users, which do know nothing about you. As the main aim of ASP to handle web requests and generate the html responses, so the aim of WCF is to supply the end user with some useful functionality, developed by another user, remotly.
The developer creates a service (WCF) where he specifies its adress, binding and contract. Knowing these parameters other developers can consume this service. They can consume it by ASP, SilverLight, WPF, WinForms or any other technology (even none-microsoft), using SOAP protocol.
From Wikipedia:
The Windows Communication Foundation (or WCF) is an application
programming interface (API) in the .NET Framework for building
connected, service-oriented applications.
WCF is meant for designing and deploying distributed applications
under service-oriented architecture (SOA) implementation. **
Architechture
** WCF is designed using service oriented architecture principles to support distributed computing where services have remote consumers.
Clients can consume multiple services; services can be consumed by
multiple clients. Services are loosely coupled to each other. Services
typically have a WSDL interface (Web Services Description Language)
that any WCF client can use to consume the service, regardless of
which platform the service is hosted on. WCF implements many advanced
Web services (WS) standards such as WS-Addressing,
WS-ReliableMessaging and WS-Security. With the release of .NET
Framework 4.0, WCF also provides RSS Syndication Services,
WS-Discovery, routing and better support for REST services. Endpoint A
WCF client connects to a WCF service via an Endpoint. Each service
exposes its contract via one or more endpoints. An endpoint has an
address (which is a URL specifying where the endpoint can be accessed)
and binding properties that specify how the data will be transferred.
http://en.wikipedia.org/wiki/Windows_Communication_Foundation
Useful resources:
http://msdn.microsoft.com/sv-se/library/dd943056%28en-us%29.aspx
http://www.wcftutorial.net/
http://blah.winsmarts.com/2008-4-Writing_the_WCF_Hello_World_App.aspx
http://blah.winsmarts.com/2008-4-Writing_your_first_WCF_client.aspx