{"id":3617,"date":"2016-11-28T14:39:16","date_gmt":"2016-11-28T18:39:16","guid":{"rendered":"http:\/\/www.acarlstein.com\/?p=3617"},"modified":"2017-01-18T14:38:23","modified_gmt":"2017-01-18T18:38:23","slug":"microservices","status":"publish","type":"post","link":"http:\/\/blog.acarlstein.com\/?p=3617","title":{"rendered":"Microservices"},"content":{"rendered":"<h3><a href=\"http:\/\/www.acarlstein.com\/?p=3632\">Microservices: Design Principles Introduction\u00a0<i class=\"fa fa-angle-right\"><span style=\"color: transparent; display: none;\">icon-angle-right<\/span><\/i>\u00a0<\/a><\/h3>\n<h3>What is a Service?<\/h3>\n<p>A service is a piece of software that provides functionality to another pieces of software.<\/p>\n<p><a href=\"http:\/\/www.acarlstein.com\/?attachment_id=3618\" rel=\"attachment wp-att-3618\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-3618\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2016\/11\/What-is-a-service.png\" alt=\"what-is-a-service\" width=\"578\" height=\"150\" srcset=\"http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2016\/11\/What-is-a-service.png 578w, http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2016\/11\/What-is-a-service-300x78.png 300w\" sizes=\"auto, (max-width: 578px) 100vw, 578px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>Provide reusability of functionality.<\/li>\n<li>A service can provide functionality to any application.\n<ul>\n<li>Such a web server, mobile, or desktop application<\/li>\n<\/ul>\n<\/li>\n<li>A service can be use by another service<\/li>\n<li>Service-oriented Architecture (SOA)\n<ul>\n<li>Instead of using package modules within each client application, we have a service which provide the same functionality to different client applications.<\/li>\n<li>Allow for new services and application to use the same functionality, reusing it, in the future.<\/li>\n<li>Allows for scale up our software when demand increasing.\n<ul>\n<li>i.e. Load balancer which have multiple copies of the same service on multiple servers. When demand increases, we increase the instance of the service running across servers.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>As long as the signature of a service, contract and interface, doesn\u2019t change when the service changes, we can upgrade our service without having to update our clients.<\/li>\n<li>A service is stateless. When a request comes in, that instance of the service does not have to remember the previous request from that specific client.<\/li>\n<\/ul>\n<h3>Microservice Architecture<\/h3>\n<p>\n Traditional SOA resulted in monolithic services. You needed to know how to size a service. The micro sized services provide an efficiently, flexible, and high performance applications.<\/p>\n<p>A microservice architecture is an application which is powered by multiple microservices, in which each microservice provides a set of functions (or related functions) to a specific part of the application.<\/p>\n<p>A microservice have a single focus. It does one thing only and it does it well.<\/p>\n<p>Microservice architecture are used in lightweight and quick communication mechanisms (such as REST) between client and services; as well as, service to service.<\/p>\n<p>A microservice needs technology agnostic API which mean to use an open communication so it doesn\u2019t dictate the technology that the client needs to use.<\/p>\n<p>At difference to a monolithic service where there is a central database used to share data between applications and services, in microservices architecture, each microservice has its own data storage.<\/p>\n<table>\n<tbody>\n<tr>\n<td style=\"background-color: #e8e6e6;\"><strong>Monolithic Service Example<\/strong><\/td>\n<\/tr>\n<tr>\n<td><a href=\"http:\/\/www.acarlstein.com\/?attachment_id=3624\" rel=\"attachment wp-att-3624\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3624 aligncenter\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2016\/11\/Monolithic.png\" alt=\"monolithic\" width=\"611\" height=\"189\" srcset=\"http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2016\/11\/Monolithic.png 611w, http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2016\/11\/Monolithic-300x93.png 300w\" sizes=\"auto, (max-width: 611px) 100vw, 611px\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table>\n<tbody>\n<tr>\n<td style=\"background-color: #e8e6e6;\"><strong>Microservice Example<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong><a href=\"http:\/\/www.acarlstein.com\/?attachment_id=3625\" rel=\"attachment wp-att-3625\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3625 aligncenter\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2016\/11\/Microservice.png\" alt=\"microservice\" width=\"572\" height=\"334\" srcset=\"http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2016\/11\/Microservice.png 572w, http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2016\/11\/Microservice-300x175.png 300w\" sizes=\"auto, (max-width: 572px) 100vw, 572px\" \/><\/a><\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>A microservice is independently changeable. This means that we can upgrade or fix a microservice without forcing any changes to the clients or services.<\/p>\n<p>A microservice needs to be independently deployable. You should be able to deploy a microservice without having to deploy anything else.<\/p>\n<p><a href=\"http:\/\/www.acarlstein.com\/?attachment_id=3588\" rel=\"attachment wp-att-3588\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3588\" title=\"vertical-align: text-top;\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2016\/11\/dialog-warning-2.png\" alt=\"dialog-warning-2\" width=\"12\" height=\"12\" \/><\/a>\u00a0Note: You may need a centralized tooling for management of microservices.<\/p>\n<p>&nbsp;<\/p>\n<h3>The Monolithic System<\/h3>\n<p>Typical Enterprise Application:<\/p>\n<ul>\n<li>Large website with all modules packaged in together into one package.<\/li>\n<li>A service which talks to a website in which the service itself is a large service with all modules packaged together as one executable.<\/li>\n<li>As you add features and stuff, your application keeps growing.<\/li>\n<li>There is no restriction in size; as well as, there is no division.<\/li>\n<li>There is always one package which basically contains everything.<\/li>\n<li>Large code base which makes it harder and time consuming to add new functionality.<\/li>\n<li>Code can become intertwined making difficult to make changes without creating side effects to other parts of the systems.<\/li>\n<li>Testing can be challenging.<\/li>\n<li>Features may be in deep in the system that they can be utilized for external use.<\/li>\n<li>Commonly stuck with one technology stack which may bring restriction such as implementing some new technology that may be different to the current<\/li>\n<li>technology stack.<\/li>\n<li>The system is less competitive because it restrict the adoption of new technology.<\/li>\n<li>Large package with high levels of coupling which means that changes may produce a ripple effect (side effects). This coupling happens in all levels such as modules, services, and objects.<\/li>\n<li>A failure in one part of the system may affect the whole system.<\/li>\n<li>Duplication of the whole may require scaling.<\/li>\n<li>The system may requires a long time to compile. The larger the system gets, the longer the compilation time required.<\/li>\n<li>Any changes, no matter how minor, may requires a complete rebuild.<\/li>\n<\/ul>\n<table>\n<tbody>\n<tr>\n<td style=\"background-color: #e8e6e6;\"><strong>Monolithic System Example<\/strong><\/td>\n<\/tr>\n<tr>\n<td><a href=\"http:\/\/www.acarlstein.com\/?attachment_id=3629\" rel=\"attachment wp-att-3627\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-3629 size-full aligncenter\" src=\"http:\/\/www.elblender.com\/wordpress\/wp-content\/uploads\/2016\/11\/The-monolithic-system-example-1.png\" width=\"677\" height=\"462\" srcset=\"http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2016\/11\/The-monolithic-system-example-1.png 677w, http:\/\/blog.acarlstein.com\/wp-content\/uploads\/2016\/11\/The-monolithic-system-example-1-300x205.png 300w\" sizes=\"auto, (max-width: 677px) 100vw, 677px\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Emergence of Microservices<\/strong><\/p>\n<ul>\n<li>Need to respond to change quickly.<\/li>\n<li>Can split a large system into parts that can be upgraded and enhanced individually<\/li>\n<li>The entire system will not break if one part breaks.<\/li>\n<li>It allows for business domain-driven design.<\/li>\n<li>It takes advantage of automated test tools.<\/li>\n<li>Since transactions are distributed, each transaction will be processed by multiple services before it\u2019s completed.\n<ul>\n<li>The integration between those services requires to be tested.<\/li>\n<li>Instead of testing these microservices manually, we can automated the test.<\/li>\n<\/ul>\n<\/li>\n<li>Release and deployment of microservices may become complex; however, there are tools available to easier the work.<\/li>\n<li>We can host microservices using on-demand technology such using virtual machines to host our microservice.\n<ul>\n<li>Physical servers are no longer required in order to deploy our software.<\/li>\n<li>On-demand hosting is simpler in these days with cloud services available.<\/li>\n<li>We can clone these virtual machines.<\/li>\n<\/ul>\n<\/li>\n<li>We can move our microservice from one technology stack to another technology stack.<\/li>\n<li>It allows for asynchronous communication technology.\n<ul>\n<li>The distributed transaction do not have to wait for other services to complete their task.<\/li>\n<\/ul>\n<\/li>\n<li>We have simpler server side and client side technology, as well as many open communication protocols available which allows communication between different technology stacks.<\/li>\n<\/ul>\n<p><strong>Key Benefits<\/strong><\/p>\n<ul>\n<li>Shorter development times<\/li>\n<li>The split up of the system allows to work individually in one part or assign different parts to different people and\/or teams.<\/li>\n<li>Due the size and the concept of single focus, an individual or team has less to worry about in terms of scope.<\/li>\n<li>They only need to focus on their scope and not the whole system\n<ul>\n<li>As long as the contracts (interfaces) between the services remain.<\/li>\n<\/ul>\n<\/li>\n<li>Developers can rework, change and deploy individual components without affecting the system (or need to redeploy everything) since the services are loosely coupled.<\/li>\n<li>Deployment is more reliable and faster.<\/li>\n<li>Allows for shorter development times, reliable and faster deployment; therefore, frequent updates.\n<ul>\n<li>Frequent updates provide a competitive edge.<\/li>\n<\/ul>\n<\/li>\n<li>It allows us to decouple changeable parts.<\/li>\n<li>Increases security since each microservice has its own database and its own security mechanism.\n<ul>\n<li>Data is distributed which makes the data more secure.<\/li>\n<li>The monolithic system may have one database. By hacking that one system, you can gain access to the data.<\/li>\n<\/ul>\n<\/li>\n<li>Quicker to identify which service is having the problem.<\/li>\n<li>Highly scalable and better performance.\n<ul>\n<li>Scale part individually instead of the whole system.<\/li>\n<\/ul>\n<\/li>\n<li>Easier to change ownership of each microservice.<\/li>\n<li>Each microservice have their own database and code base.<\/li>\n<li>Enables distributed teams.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n\n<script>\nvar zbPregResult = '0';\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>Microservices: Design Principles Introduction\u00a0icon-angle-right\u00a0 What is a Service? A service is a piece of software that provides functionality to another pieces of software. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Provide reusability of functionality. A service can provide functionality to any application. Such a web server, mobile, or desktop application A service can be use [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,1472,1480],"tags":[1473,1479,1516,1534,1474,1533],"class_list":["post-3617","post","type-post","status-publish","format-standard","hentry","category-programming","category-architecture","category-microservices","tag-architecture","tag-microservices","tag-monolithic","tag-rest","tag-service","tag-soa"],"_links":{"self":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts\/3617","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3617"}],"version-history":[{"count":10,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts\/3617\/revisions"}],"predecessor-version":[{"id":3647,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=\/wp\/v2\/posts\/3617\/revisions\/3647"}],"wp:attachment":[{"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3617"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3617"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.acarlstein.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3617"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}