Microservices Introduction
Son Le - IBM Cloud Technical Evangelist
E: sonle@sg.ibm.com
T: @thsonvt
Agenda
Building Monolithic App
What's Great with Monolithic App
* Simple to develop
* Simple to test
* Simple to deploy
* Simple to scale
What's Bad with Monolithic App
* App is overwhelmingly complex. Fixing bugs and implementing new features become difficult & time consuming
* The development will be slow down due to app size
* Very hard to do continuous development (which has been become the new norm in modern SaaS business)
* Difficult to scale when different modules have conflicting resource requirements
* Reliability is an issue i.e a memory leak could impact entire app
* Extremely difficult to adopt new frameworks & technologies
What is Microservices
What is Microservices
Microservices are small, autonomous services that work together
Characteristics of Microservices
1. Small and focused on doing one thing well
* Single Responsibility Principle
Gather together those things that change for the same reason, and separate those things that change for different reasons.
* How small is small?
* When is small enough and no smaller?
Amazon CEO's Jeff Bezos Two Pizza Rule "teams shouldn’t be larger than what two pizzas can feed"
Characteristics of Microservices
2. Autonomous
* Separate entity, can be deployed on isolated "machine"
* Be able to change independently
"Can you make a change to a service and deploy it by itself without changing anything else?"
* Each service expose an API and communicate via API
Characteristics of Microservices
3. Language Neutral
* Should be built using the tech which makes most sense for it
* Communication through language-neutral APIs, typically an Hypertext Transfer Protocol (HTTP)-based resource API, such as REST
Characteristics of Microservices
4. Bounded Context
* A particular Microservice doesn't know anything about underlying implementation or architecture of other services.
App Re-Architected as Microservices
Microservices vs Monolithic App
A monolithic application is an application where all of the logic runs in a single application server.
Microservices vs Monolithic App
Microservices architecture with multiple languages and data store technologies
Microservices vs Monolithic App
Category | Monolithic | Microservice |
---|---|---|
Code | A single code base for the entire application | Multiple code bases. Each microservices has its own code base |
Understandability | Often confusing and hard to maintain | Much better readability and much easier to maintain |
Deployment | Complex deployments with maintenance windows and scheduled downtimes | Simple deployment as each microservice can be deployed individually, with minimal if not zero downtime |
Microservices vs Monolithic App
Category | Monolithic | Microservice |
---|---|---|
Language | Typically entirely developed in one programming language | Each microservice can be developed in a different programing language |
Scaling | Requires you to scale the entire application even though bottlenecks are localized | Enables you to scale bottlenecked services without scaling the entire application |
Microservices vs Monolithic App
Benefits of Microservices
* Their small size enables developers to be most productive.
* It's easy to comprehend and test each service.
* You can correctly handle failure of any dependent service.
* They reduce impact of correlated failures.
What to avoid with Microservices
1. Don't start with Microservices
2. Don't even think about Microsevices without DevOps
3. Don't manage your own infrastructure
4. Don't create too many Microservices
5. Don't forget to keep an eye on potential latency issue
Demo of Microservices App on Bluemix
Demo of Microservices App on Bluemix
Catalog App
* A backend RESTful API to keep track of all the items in the store.
* Developed using Node.js with Express framework. The catalog of items will be persisted in a Cloudant database.
* Node.js is selected due to it’s non-blocking, event-driven I/O, it’s ability to handle many requests, and for the use of a non-relational database for our catalog of items.
Demo of Microservices App on Bluemix
Catalog App
http://microservices-catalogapi-sonlethanh-165.mybluemix.net/
Demo of Microservices App on Bluemix
Orders App
* A backend RESTful API to keep track of all store orders.
* Implemented this using Java JAX-RS and use JPA to store the orders in a SQL Database.
* Java EE is selected due to the nature of this application handling customer orders and potential billing information, failures are not acceptable for this service and security is our utmost importance.
Demo of Microservices App on Bluemix
Orders App
http://microservices-ordersapi-sonlethanh-166.mybluemix.net/
Demo of Microservices App on Bluemix
UI App
PHP was chosen for the UI due to it being super easy to create a UI.
http://bit.ly/bluemix28012016-survey