Microservices
How do I scale my codebase?
![](https://s3.amazonaws.com/media-p.slid.es/uploads/314435/images/1658005/Black-And-White-Buidings.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/314435/images/1795666/intro.jpg)
Microservices
A way of structuring your codebase to allow easy extensibility, higher maintainability and code collaboration.
The monolithic way
![](https://s3.amazonaws.com/media-p.slid.es/uploads/314435/images/1660496/skyscraper.jpg)
Separation of concerns
Divide your codebase in sections, such that each section is responsible for one and only thing.
Instead we do this
Magento
![](https://s3.amazonaws.com/media-p.slid.es/uploads/314435/images/1658064/Screen_Shot_2015-08-21_at_9.19.59_PM.png)
and this
https://goo.gl/1Nbxos (Bill Scott keynote)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/314435/images/1795740/Screen_Shot_2015-10-05_at_19.53.53.png)
MAINTAINABILITY
Think of the 80/20 Rule (The Pareto Law)
80% of your bugs are residing inside the 20% percent of your code.
NOW FIND THAT 20% INSIDE MILLIONS OF LOC.
Version control - conflicts
- How much time do you spend resolving conflicts?
- Do you dare to go back in history in search of a commit?
Scalability
- Monolithic Applications scale by adding more instances/servers/resources.
- But how much of those can you add?
- Are the resources used efficiently?
Extensibility
- Unless you have a test suite with 100% test coverage, you don't change things.
- Instead you add and add and keep adding.
- Monolithic apps are keep getting larger.
The monolithic way
One code base to rule em all.
- Maintainability
- Code collaboration
- Conflicts/Merges
- SoC
- Scalability/Extensiblity
Enter the new World Order
Microservices Architecture
- Easier to maintain
- Multiple teams work on multiple services
- Fewer conflicts
- Different stacks work for the same purpose
- SoC
- Easy to scale/extend, Just add a service
let's build an e-shop
Your app has/needs
-
Persistent storage
-
UI / Mobile App
-
Lots of Business Logic
Choose your intercommunication
-
Task Queue
-
REST APIs
Isolate the Database
-
Put a REST API in front of your Database
-
Let every other service that needs persistent storage to talk to the Data API
-
Reflect your Business Logic in your API endpoints
Create a Newsletter Service
-
Sends Emails, talks to Sendmail, Gunmail, etc
-
Keeps tracks of templates sent, analytics, etc
-
Utilizes the Data API
Create the UI Service
-
Will contain HTML, CSS, Client Side Business Logic, etc
-
Reads / Writes the Data API
Create the Mobile App
-
Will contain Native language stuff
-
Reads / Writes the Data API
What else do you need? Just create a service
Learn from the experts
- Netflix
Werner Vogels
If you hit the Amazon.com gateway page, the application calls more than 100 services to collect data and construct the page for you.
http://goo.gl/92xpfk
CTO/VP @ Amazon
If you start with Microservices, you are starting wrong.
Martin Fowler
Thank you
Microservices
By Kostas Bariotis
Microservices
- 4,132