Microservices
Microservices
● What is Microservice
● Why should we use Microservice
● When should we use Microservice
● How to use Microservice
● Discussion
● Code Example
What is Microservice
Microservice architecture split Business Logic and Data Access Layer into several small part called Microservices.
Real business logic and Data access are implemented by invoking multiple different microservices distributed on different nodes.
Why should we use Microservice
Scalability —— Distribution
You don’t need to have one very powerful server to run your application. Instead you could use several relatively weaker servers and run different microservices on
each of them. The system will have better IO performance since the tasks are distributed and can be done simultaneously.
By combining microservice with edge computing, you can take advantage of IOT devices like raspberry pi or arduino to provide service locally for users.
Why should we use Microservice
Non-uniform Scaling
Portability
Microservice architecture has very good portability by using container technology like Docker
Why should we use Microservice
Elasticity
When there are not so many requests, the server load is low, and it can stop those unnecessary replicas of services and shutting down some servers to save power and reduce
the stress of cooling system. When the request increase, the server could automatically deploy new containers to provide service according to the metrics like response time.
When the request number increasing speed hit some threshold or if our machine learning model predicted that there will be a heavy load, the system could boot some servers
for more resource to deploy microservice. vice versa
Why should we use Microservice
Availability
When updating the application, we don’t have to shutdown the whole application and then deploy the new one.
by using microservice architecture, we just need a little bit of extra resource for the service we are going to update.
Why should we use Microservice
Robustness
If one server has hardware failure like hardware broken or power cut. other servers could still provide all the services.
When should we use Microservice
How to use Microservice
Programming language doesn’t matter
You can use any programming language you want as long as you can provide solid API documentation so other services can communicate with it and invoke
the service properly.
How to use Microservice
In this architecture, Microsoft uses rabbitMQ and AzureService Bus as the eventbus middleware for data/message sharing between all the microservices.
Using message queue can change the business logic from synchronized logic to asynchronized logic and result in a better io performance.
Discussion
Positive