{"id":55323,"date":"2021-03-19T09:22:17","date_gmt":"2021-03-19T09:22:17","guid":{"rendered":"https:\/\/www.globallogic.com\/ua\/?post_type=insightsection&#038;p=55323"},"modified":"2025-01-31T05:09:17","modified_gmt":"2025-01-31T05:09:17","slug":"microservices-architecture-for-beginners-part-one","status":"publish","type":"insightsection","link":"https:\/\/www.globallogic.com\/ua\/insights\/blogs\/microservices-architecture-for-beginners-part-one\/","title":{"rendered":"\u041c\u0456\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0456\u0441\u043d\u0430 \u0430\u0440\u0445\u0456\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0434\u043b\u044f \u043f\u043e\u0447\u0430\u0442\u043a\u0456\u0432\u0446\u0456\u0432. \u0427\u0430\u0441\u0442\u0438\u043d\u0430 \u0406"},"content":{"rendered":"<div class=\"classic_editor_content\">\n<h6 style=\"text-align: right;\" align=\"justify\"><strong><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Author: Orkhan Gasimov, Technology Director, GlobalLogic<\/span><\/span><\/strong><\/h6>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Microservice architecture has been around for a while. However, there are many people looking for materials to get started and learn more about it. Despite the abundance of books and articles available, it is difficult to find a starting point for a quick start. Introductory material for the manager, engineer or architect, anyone. That is why I decided to write this article, in which I will list the basic principles and touch on the topics that you need to study if you want to gain a deep understanding of microservice architecture.<\/span><\/span><\/p>\n<h3 style=\"text-align: center;\"><span style=\"color: #ff6600;\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">What is a microservice?<\/span><\/span><\/span><\/h3>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">A microservice is the simplest unit, a service that accepts incoming requests to perform an action. It can be a backend service that is available 24\/7 or a function that is called when an event occurs. In simple words, a function or set of functions available through a specific API over a network. So, this is a backend service deployed on a server. In a sense, it is a monolithic application. However, it does not carry the entire functionality of the system, but only a smaller part of the logic. Unlike a monolith, the resulting application is built as a set of relatively small independent services, called &#8220;microservices,&#8221; that communicate over a computer network. We can say that microservices are the same logical modules of a monolithic application that are distributed over a computer network, instead of working within a single process (device).<\/span><\/span><\/p>\n<div class=\"img_container\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-55025\" src=\"https:\/\/www.globallogic.com\/ua\/wp-content\/uploads\/sites\/6\/2021\/03\/image-1024x410.png\" alt=\"\" width=\"604\" height=\"242\" srcset=\"https:\/\/www.globallogic.com\/ua\/wp-content\/uploads\/sites\/6\/2021\/03\/image-1024x410.png 1024w, https:\/\/www.globallogic.com\/ua\/wp-content\/uploads\/sites\/6\/2021\/03\/image-300x120.png 300w, https:\/\/www.globallogic.com\/ua\/wp-content\/uploads\/sites\/6\/2021\/03\/image-768x307.png 768w, https:\/\/www.globallogic.com\/ua\/wp-content\/uploads\/sites\/6\/2021\/03\/image.png 1050w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/p>\n<\/div>\n<p style=\"text-align: center;\"><em><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">A typical microservice web application reference architecture<\/span><\/span><\/em><\/p>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Microservices are usually structured in tiers. There are no rules as to how many or what tiers there should be, but there are best practices. The diagram above shows the most common tiers used in such architectures. The names may vary, but the structure is very similar to classic multi-tiered architecture. Logical tiers we see:<\/span><\/span><\/p>\n<p><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Front-End \u2014 Client Application, Static Content <\/span><\/span><br \/>\n<span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Back-End \u2014 API Gateway, Experience Microservices, Domain Microservices <\/span><\/span><br \/>\n<span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Data &amp; Integration \u2014 Data Stores, Integration Interfaces \/ Connectors<\/span><\/span><\/p>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Let&#8217;s consider each tier and describe what it is responsible for.<\/span><\/span><\/p>\n<h3 style=\"text-align: center;\"><span style=\"color: #ff6600;\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Logical tiers<\/span><\/span><\/span><\/h3>\n<ul>\n<li><strong><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Client program<\/span><\/span><\/strong><\/li>\n<\/ul>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">In the case of a web application, the client is usually a web browser. Some people think that the client is the UI, but it is not. A browser is a client that downloads static content from a remote server and renders the UI internally. And it is a client that processes physical HTTP requests that are sent to the server. It is important to distinguish between the client and the content. Especially if you are developing a micro-app frontend.<\/span><\/span><\/p>\n<div class=\"img_container\">\n<p class=\"imgyoutube\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-55026\" src=\"https:\/\/www.globallogic.com\/ua\/wp-content\/uploads\/sites\/6\/2021\/03\/unnamed.png\" alt=\"\" width=\"512\" height=\"124\" srcset=\"https:\/\/www.globallogic.com\/ua\/wp-content\/uploads\/sites\/6\/2021\/03\/unnamed.png 512w, https:\/\/www.globallogic.com\/ua\/wp-content\/uploads\/sites\/6\/2021\/03\/unnamed-300x73.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/p>\n<\/div>\n<p style=\"text-align: center;\"><em><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">The client (web browser) interacts with the backend to render the UI and call the API.<\/span><\/span><\/em><\/p>\n<ul>\n<li><strong><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Static content<\/span><\/span><\/strong><\/li>\n<\/ul>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">A best practice is to separate responsibility by decoupling logical components so that no single component is responsible for everything. For this reason, it is recommended to serve static content through a separate server component. This allows you to separate static content from the API. A few important principles to consider are server-side rendering, caching, and access control.<\/span><\/span><\/p>\n<ul>\n<li><strong><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">API Gateway<\/span><\/span><\/strong><\/li>\n<\/ul>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">API Gateway is the central door to all public APIs. It is the single entry point for so-called Experience APIs available to client applications and is an important component of API Management best practices. Basically, it passes requests to real backend services and is able to make decisions. Most often, API Gateway is responsible for such functionality as:<\/span><\/span><\/p>\n<hr \/>\n<ul>\n<li><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Request handling<\/span><\/span><\/li>\n<li><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Upstream (or downstream) data transfer (or transformation)<\/span><\/span><\/li>\n<li><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Access control<\/span><\/span><\/li>\n<li><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Security policies<\/span><\/span><\/li>\n<li><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Throttling<\/span><\/span><\/li>\n<li><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Rate limiting<\/span><\/span><\/li>\n<li><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Analytics<\/span><\/span><\/li>\n<li><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Caching<\/span><\/span><\/li>\n<\/ul>\n<hr \/>\n<ul>\n<li><strong><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Experience microservices<\/span><\/span><\/strong><\/li>\n<\/ul>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">In an unstructured distributed environment, it is very easy to lose control over a multitude of microservices. For this reason, it is recommended to control microservices by structuring them in tiers. There are various architectural patterns that can help. What these templates have in common is that they all focus on experience.<\/span><\/span><\/p>\n<div class=\"img_container\">\n<p class=\"imgyoutube\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-55029\" src=\"https:\/\/www.globallogic.com\/ua\/wp-content\/uploads\/sites\/6\/2021\/03\/unnamed-2.png\" alt=\"\" width=\"512\" height=\"138\" srcset=\"https:\/\/www.globallogic.com\/ua\/wp-content\/uploads\/sites\/6\/2021\/03\/unnamed-2.png 512w, https:\/\/www.globallogic.com\/ua\/wp-content\/uploads\/sites\/6\/2021\/03\/unnamed-2-300x81.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/p>\n<\/div>\n<p style=\"text-align: center;\" align=\"justify\"><em><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Experience services rely on domain services located at a lower level.<\/span><\/span><\/em><\/p>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Imagine a set of microservices that provide higher-level APIs focused on the customer experience, reusing the low-level granular APIs available in the system. For example, different products delivered for web and mobile clients (Experience) may use a different set of experience APIs represented by independent microservices behind an API gateway.<\/span><\/span><\/p>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">These microservices form the experience tier, which is logically separated from other tiers. It can be managed and configured (scaled, configured, secured, etc.) independently. Refer to API-Led Connectivity and Backend For Frontend architectural patterns to dive deep into related concepts.<\/span><\/span><\/p>\n<ul>\n<li><strong><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Domain microservices<\/span><\/span><\/strong><\/li>\n<\/ul>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Domain microservices are a lower layer that is responsible for business logic and on which experience services depend.<\/span><\/span><\/p>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">In this way, experience services are focused on the user and the product, while domain microservices are responsible for the data and resources under their control. So, domain microservices provide granular, lower-level APIs that allow you to create different experience services by reusing available domain logic.<\/span><\/span><\/p>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">As a result, we have a situation where the addition of each new experience service does not require additional time spent on re-developing the domain logic.<\/span><\/span><\/p>\n<ul>\n<li><strong><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Databases<\/span><\/span><\/strong><\/li>\n<\/ul>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">The best practice is that the database should belong to only one microservice. No other services should be able to directly access the database, only through the API of the owning service. This allows each service to manage the consistency and structure of the database it owns. It also allows you to choose the most suitable database for specific purposes without any dependence on the requirements of the system as a whole. For example, one service may use a normalized SQL database, while another may benefit from a NoSQL database. However, a single microservice can manage multiple databases.<\/span><\/span><\/p>\n<div class=\"img_container\">\n<p class=\"imgyoutube\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-55028\" src=\"https:\/\/www.globallogic.com\/ua\/wp-content\/uploads\/sites\/6\/2021\/03\/unnamed-1.png\" alt=\"\" width=\"512\" height=\"216\" srcset=\"https:\/\/www.globallogic.com\/ua\/wp-content\/uploads\/sites\/6\/2021\/03\/unnamed-1.png 512w, https:\/\/www.globallogic.com\/ua\/wp-content\/uploads\/sites\/6\/2021\/03\/unnamed-1-300x127.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/p>\n<\/div>\n<p style=\"text-align: center;\"><em><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">A service can only have direct access to a database if it is the owner. Otherwise, it should use the API of the owning microservice and never have direct access to the database of other services.<\/span><\/span><\/em><\/p>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Database sharing can potentially lead to the Distributed Monolith anti-pattern. If you need to share data, refer to centralized storage concepts such as:<\/span><\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">DWH (Data Warehouse),\u00a0<\/span><\/span><\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">DFS (Distributed File System)\u00a0<\/span><\/span><\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Data Lake.\u00a0<\/span><\/span><\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">It is recommended to apply the correct schemes and approaches from the beginning, because you will have to do it later anyway.\u00a0<\/span><\/span><\/span><\/p>\n<ul>\n<li><b><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Integration interfaces and connectors<\/span><\/span><\/b><\/li>\n<\/ul>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">In addition to internal data sources, the application may need access to other subsystems and third-party APIs. A useful practice is to separate the integration tier by introducing separate services-connectors.<\/span><\/span><\/p>\n<p align=\"justify\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Let&#8217;s sum up. Microservice architecture is essentially a pattern that teaches how to apply different (or other) architectural <\/span><\/span><a href=\"https:\/\/www.globallogic.com\/ua\/insights\/blogs\/dive-into-the-selenium-patterns\/\" target=\"_blank\" rel=\"noopener\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">patterns<\/span><\/span><\/a><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\"> , styles and approaches within a single application distributed over a network. In this article, we considered only the tip of the iceberg, the so-called high-level architecture. In the next part, we will analyze a set of lower-level approaches and patterns that deserve attention when diving further into the topic.<\/span><\/span><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">Read the second part of the article <\/span><\/span><a href=\"https:\/\/www.globallogic.com\/ua\/insights\/blogs\/microservices-architecture-for-beginners-part-two\/\"><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\">at the link<\/span><\/span><\/a><span style=\"vertical-align: inherit;\"><span style=\"vertical-align: inherit;\"> .<\/span><\/span><\/span><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u0420\u043e\u0437\u0431\u0438\u0440\u0430\u0454\u043c\u043e\u0441\u044c \u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u0438\u043c\u0438 \u043f\u043e\u043d\u044f\u0442\u0442\u044f\u043c\u0438 \u043c\u0456\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0456\u0441\u043d\u043e\u0457 \u0430\u0440\u0445\u0456\u0442\u0435\u043a\u0442\u0443\u0440\u0438 \u0442\u0430 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u043e \u0447\u0435\u0440\u0435\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u0456 \u0442\u0435\u0440\u043c\u0456\u043d\u0438 \u0442\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0438<\/p>\n","protected":false},"author":26,"featured_media":55033,"parent":0,"menu_order":0,"template":"","insight":[41],"insight-subcats":[61],"insight-industry":[791],"insight-services":[],"insight-partners":[],"class_list":["post-55323","insightsection","type-insightsection","status-publish","has-post-thumbnail","hentry","insight-blogs","insight-subcats-architecture","insight-industry-cross-industry"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.globallogic.com\/ua\/wp-json\/wp\/v2\/insightsection\/55323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globallogic.com\/ua\/wp-json\/wp\/v2\/insightsection"}],"about":[{"href":"https:\/\/www.globallogic.com\/ua\/wp-json\/wp\/v2\/types\/insightsection"}],"author":[{"embeddable":true,"href":"https:\/\/www.globallogic.com\/ua\/wp-json\/wp\/v2\/users\/26"}],"version-history":[{"count":2,"href":"https:\/\/www.globallogic.com\/ua\/wp-json\/wp\/v2\/insightsection\/55323\/revisions"}],"predecessor-version":[{"id":101648,"href":"https:\/\/www.globallogic.com\/ua\/wp-json\/wp\/v2\/insightsection\/55323\/revisions\/101648"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.globallogic.com\/ua\/wp-json\/wp\/v2\/media\/55033"}],"wp:attachment":[{"href":"https:\/\/www.globallogic.com\/ua\/wp-json\/wp\/v2\/media?parent=55323"}],"wp:term":[{"taxonomy":"insight","embeddable":true,"href":"https:\/\/www.globallogic.com\/ua\/wp-json\/wp\/v2\/insight?post=55323"},{"taxonomy":"insight-subcats","embeddable":true,"href":"https:\/\/www.globallogic.com\/ua\/wp-json\/wp\/v2\/insight-subcats?post=55323"},{"taxonomy":"insight-industry","embeddable":true,"href":"https:\/\/www.globallogic.com\/ua\/wp-json\/wp\/v2\/insight-industry?post=55323"},{"taxonomy":"insight-services","embeddable":true,"href":"https:\/\/www.globallogic.com\/ua\/wp-json\/wp\/v2\/insight-services?post=55323"},{"taxonomy":"insight-partners","embeddable":true,"href":"https:\/\/www.globallogic.com\/ua\/wp-json\/wp\/v2\/insight-partners?post=55323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}