Microservices came into picture because of the Monolithic applications wherein all the logical code is put into the same codebase. The parts in here are tightly coupled with each other, so deploying this means that either a part or the whole application is deployed. In this scenario we should be careful for the errors because a small error can also break our deployment and put our whole server down.
So because of this tightly coupled code base in monolithic application and the high chances of breakdown because of the errors which could be interdependent the concept of Micro services came into picture.
instead we could have different parts of our application which could connect with HTTP API interface the requirement. So if a change is made into our codebase, we are only changing a part of it and not the whole application.
So Micro services has some PROS and CONS as well which we can have a look-
1. Using Micro services, different teams can work on the services separately and each part of the application can be build separately as the microservices component are decoupled.
2. With Microservices we can scale horizontally and can scale only those services which are bottlenecks as they are decoupled.
1. One of the disadvantages of the microservices is its complexity. As the whole application is spitted into different microservices so it entitles more things to manage. It requires planning, a lot of effort. Resources and skills.
2. Consistency of the data becomes harder as every services has a separate database
3. As in microservices each service communicates externally with an API so it raises a security concern.
4. As we can use different programming languages on different separate services, but it make a overhead to deploy different languages and also its very harder for devs to switch between the development of each service.
Serverless architecture is based out of the cloud computing approach to build apps and services without the need of infrastructure.
Here the code execution is done by server, so a developer can deploy code and feel free about scaling and the stuffs like server maintenance its provision, database management etc.
So, a serverless architecture has 2 concepts –
1. Faas (Function as a Service) : Here we can upload our developed functionality and let them run independently. One of the examples of this is AWS Lamda, which runs on event and this event can be triggered by any device on whatsoever programming language we can use.
2. Baas (Backend as a Service) : So Here the backend related stuffs like Database Management, Cloud storage, user Authentication, push notification, hosting etc can be outsourced and the developers only have to work on front end part.
1. As we don’t have to worry about the infrastructure and the provisioning required, application can be deployed easily.
2. As the serverless architecture have accessible points on a global scale so its easier to manage users from any corner of the globe.
3. We can give more time to the UX of the application as don’t have to care about the infrastructure.
Integration testing of the Architecture that are serverless is tough. In Faas unit for testing are way smaller than with the other architectures. We may have to deploy a Faas artifact separately for each function in our application.
Out of the two architectures, it all depends on the requirements. If the application is simple and clean, then we can go for monolithic architecture.
So, if suppose there is a requirement of launching the product as soon as possible then we can opt for monolithic because there is no complexity which is there in distributed systems and the deployment time is least. But suppose if you add features to your product every now and then, then monolith is not a good choice. We may have to transfer our system to microservices to avoid hold up situations in performance. So, adding new features and deployment is not going to affect the entire application, and the application will still work.
However, the serverless architecture is more of deployment rather than development and it overcomes the overhead of scaling, maintenances and are managed by their own so it reduces the resource overhead cost too.