What are Microservices? Microservices Examples
Developers use microservices to build scalable and functional applications piece by piece. Such architectures help deliver a more complex app structure without trying to create all at once.
Table of Contents
What are Microservices?
Microservices are the parts of an SOA (Service-Oriented Application). They are small service units that work independently. With the special approach in software engineering, developers break the app into separate sectors that have individual structure and even code language. Each accomplishes the single business goal, uses unique data storage methods and owns a different interface.
Microservices vs Monolithic Architecture
Image Source: AWS
A traditional monolithic application is the opposite of microservices architecture. It is a single software unit where all the components are interdependent. The database of this architecture serves for the whole stack. The development process is slow, yet simple. In comparison with microservices, monolithic architecture doesn’t require expert knowledge and allows to build the app from scratch.
However, if you aim to launch a complex application with a wide operational system, then microservices will do the work better. Here is why:
|Monolithic architecture||Microservices architecture|
|The whole structure works for all the goals||Each unit accomplishes ONE business goal|
|The disaster affects the whole app||If the fault happens, it only impacts a single unit which is easy to rebuild and redeploy|
|There is only one data model and technology for the structure||Federated data allows choosing the best-suited model for each app process|
|Slow development process||Due to small teams that lead each microservice, the development is quicker and more efficient|
|Unflexible resource allocation||Depending on which service customers use the most (for example, the product listing), developers understand which unit requires more resources|
As you are aware of the microservice benefits, let’s explore some of its drawbacks. Here are some of them:
- Since microservice runs as a complex system, you need to establish communication between all the units, which requires additional effort;
- It is hard to manage and test independently deployable structures;
- The maintenance of each unit requires money and good teamwork;
- Because of the different programming languages, there are more services to look after;
- The processing and storage of the unstructured data is a challenge because of the separate mechanisms.
Typical Microservice Architecture
There are several approaches to building communication between microservices and users. One of them is a direct connection.
Image Source: Microsoft
Such a plan suits small apps with minimum functionality. Since the client app is directly connected with each microservice, it’s better to cut the numbers of endpoint consumption for the sake of convenient UI, easy authorization and security.
The alternative to direct communication is the API gateway implementation. It is the better option for your app if it copes with many microservices.
API is sometimes called back-end for front-end. The gateway routes requests from users to microservices. If you establish a single gateway for all the microservices, it will work as a monolithic aggregator. There are some threats, as the gateway may become bigger and overloaded with tasks. So, it would be useful to split the API into different gateways, with individual facades for client needs.
Image Source: Microsoft
As you can see from the picture, the mobile app and the web app are separated. There are special facades for each of them due to different requirements for data compression and optimization.
What Are Microservices in AWS
AWS offers many services for developing successful microservice architecture. The typical case is shown on the scheme below.
Image Source: AWS
1. User Interface
AWS uses Amazon Simple Storage Service and CloudFront to deliver the static web content. You can benefit from reduced latency level due to the convenience of edge locations. Users are served from the nearest ones.
For further information, visit our blog: Simplifying Cloud Storage Costs: How AWS S3 Pricing Work
AWS pays attention to the API, especially RESTful web services API. Apart from the connection between client and server, it has additional features as traffic management, authentication, authorization.
3. Data Store
AWS offers the Amazon ElastiCache as a managed service for storing data which is needed for microservices. The service works as a cache, controls the load balancing and the latency level.
Dynamo DB is a document database with the opportunity to retrieve and store data. It can process 10 trillion requests per day.
Amazon Aurora is a relational database constructed for a cloud. It works 5 times faster than MySQL and saves costs, providing the same reliability. The service sends data copies to several regions to ensure security and fast disaster recovery.
Use Cases: Uber
Since the microservice architecture is a distributed system, where all the units are deployed independently, it is very useful for e-commerce. For instance, if you are running the online store, and the payment system requires the update then you can change only that part, without touching the rest of the system.
A few years ago, nobody even knew about microservices, but now many big companies benefit from it, and Uber isn’t an exception.
In the beginning, Uber started as a monolithic architecture. It was enough for the small enterprise, located in one city. With the worldwide growth, the program needed to be scaled, new features had been added, and it became quite a problem to maintain all of that as a monolith.
To avoid risks and hardships while updating and fixing bugs, Uber decided to build the microservice architecture.
Image Source: DZone
As you can see, each process has a separate unit in the system. Drivers and passengers are connected through the API Gateway, the service dependencies were broken, and each unit can be scaled independently.
As you may have understood, there is no one great solution for all of the companies. Choose the traditional monolithic structure for the small enterprise, keep the microservices for big boys with many operations. Keep in mind, that monolith requires a constant rebuild of the whole code base, whereas microservice units can be scaled independently.
You may also be interested in: 10 Ways to Reduce your AWS Bill
The development of the architecture is a complex process that requires an expert team with huge experience. Here, at Romexsoft, we love what we do and do it professionally. Visit our website for a consultation.