What are microservices?
- Microservices are designed to overcome the disadvantages of traditional monolithic architectures. In this architecture all the functions or services are small, independent, and loosely coupled, so any of the service or function’s failure will not break the whole application.
- Each service communicates with them through APIs. That is why it is not required to know the full implementation details of the service while calling. Services can be called through APIs and can be authentication by various ways.
- More important in this architecture, that each services can use different technology stack or frameworks if required. Like one Azure function written in .Net can call another function written in Python.
- Each service can maintain their separate codebase and are managed by a small team of developers. As the services maintain their own codebase they can be deployed independently for any modification or new enhancement. There is no requirement to redeploy the entire application or other services.
- Simply stated, microservices are another architectural solution for designing big and complex – mostly web-based – applications.
- Fault isolation as already mentioned above services are loosely coupled, which means that if one service is not responding, it won’t disrupt the entire application, only if the other services handle the faults correctly. For example, service1 is calling service2 for calculating an equation, and service2 is down at that time, service1 will only break if it doesn’t have error handling mechanism properly. Service1 will display the message that service2 is unavailable. Other functionalities of Service1 will work as-is.
- Mix of technologies. Freedom to choose the technology – those best fits for the service. And Azure gives us that freedom. In a same application we can write different function app in different technology.
- Scalability. Another most important advantage of Microservices. Each Service can be scaled independently based on their usage and can deploy in different plans in Azure. For high availability services we can choose premium plan while others we can choose consumption plan. This saves a lot of money.
- Focused teams and faster development time Each service is dedicated to a small team or individual to build and test. This promotes greater agility. Communication between large teams tend be slower and less productive. Adding a new feature is much easier here, a small developer team can develop and test the feature and another service when ready they simple call the API of the new feature without going deep into the complexity. This allows the work of developers to be more creative and independent, which saves time and money.
Azure Functions are best examples of Microservices
Azure functions are one of the best examples of Microservices, they are the basic building block for microservices architecture. Azure Functions is scale-based and on-demand and pay only for the resources that are consumed. Based on the functionality and requirements functions are either be hosted on a Consumption plan or an Azure App Service plan.
Azure functions support variety of programming languages. Officially supported languages include:
Different function app can be written in different language and can be called from a single same application.
Azure Functions are triggered in multiple ways. Like it can be timer trigger or http trigger, or it can be triggered when a message arrives on a service bus and many other ways listed below.
- Blob storage
- Cosmos DB
- Event Gird
- Event Hubs
- HTTP & webhooks
- IoT Hub
- Microsoft Graph events
- Queue Storage
- Service Bus
When to Choose which ARCHITECTURE for your solution?
When to choose a monolithic architecture?
- When the application is simple and does not require much scalability or flexibility, go for monolithic approach
- Second, if the team is small and not has the expertise to handle microservices
- Third, if application need to be delivered quickly and at the same time not very complex.
When to choose a microservices architecture?
- For a complex and scalable application. The microservices architecture is best for scaling individual services and adding new capabilities into the application.
- When you have experts in your team. While designing the entire application with individual microservices requires experts’ knowledge in each area. Not only in technology Architect should know the business flow of the entire application also. Without proper skills and knowledge, building a microservice application is extremely risky.
- For a large team. Divide the team into small teams and delegate the responsibilities, this increases the speed of development.
Both the services have its own advantages and disadvantages. The microservices approach gives developers more flexibility, and it is more beneficial for complex and scalable applications. Whereas monolithic architecture only communicates to systems within its own boundaries.
Final thought on this topic is while taking the architecture decisions validate the requirements properly and check your team’s expertise.