Slide 1

Slide 1 text

Principles Of Microservices Alper Hankendi @alper_hankendi github.com/alperhankendi

Slide 2

Slide 2 text

20 2019 KrakenD API Gateway About Me Working as Product Engineering Director at Hepsiburada 20 Years Experience… approximately (professional) Ninja Developer, Servant Leader and Mentor Like to build useless stuff Drummer, Brewer and…. Father Golang and Linux Lover

Slide 3

Slide 3 text

33 2020 Authorization granularity ● Definition of Microservices ● How big is a Microservices ● Scaling the organization ● Principles Of Microservices ○ Modelled Around business domain ○ Culture Of Automation ○ Hide Implementation Details ○ Decentralise All The Things ○ Deploy Independently ○ Isolate Failure ○ Consumer First ○ Highly Observable AGENDA

Slide 4

Slide 4 text

The microservice architectural style is an approach to developing a single application as a suite of small service, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different languages and use different data storage technologies. James Lewis@2014 Definition Of Microservices

Slide 5

Slide 5 text

How Big is a Microservices

Slide 6

Slide 6 text

Microservices Size Categories “Macro”services “Mini”services “Micro”services Ex: price,availability and shipping feature Ex: shopping cart domain calling the price, availability and shipping microservices Ex: ordering business capability using different miniservices, such as the shopping cart &&|| payment

Slide 7

Slide 7 text

Scaling in Amazon & Netflix

Slide 8

Slide 8 text

Starwars… Death Star ?

Slide 9

Slide 9 text

38 2019 KrakenD API Gateway Where to cut the services ?

Slide 10

Slide 10 text

Where to cut the services? Social Tech

Slide 11

Slide 11 text

Where to cut the services?

Slide 12

Slide 12 text

2 Recognize Conway’s Law 1 Right-size your teams 3 Enable unplanned innovation Scaling the Organization TL;DR Three Things You Can Do...

Slide 13

Slide 13 text

Scaling the Organization 1- Right-sizing Teams Dunbar’s Number Aim for a team size of Dunbar Level 1 (5), Possibly Dunbar Level 2 (15) https://en.wikipedia.org/wiki/Dunbar's_number

Slide 14

Slide 14 text

Scaling the Organization 2- Conway’s Law “A system’s design is a copy of the organization’s communication structure” Mel Conway@1967 Srv1 Index UI Srv2 Database UI Srv1 Srv2 Index Database UI https://www.melconway.com/Home/Committees_Paper.html

Slide 15

Slide 15 text

Scaling the Organization 3- Unplanned Innovation If you want to achieve greatness, stop asking for permission

Slide 16

Slide 16 text

Principles Of Microservices

Slide 17

Slide 17 text

20 2019 KrakenD API Gateway Principles Of Microservices TL;DR 2 Culture Of Automation 1 Modelled Around Business Domain 3 Deploy Independently 4 Decentralise All The Things 5 Hide Implementation Details 6 Isolate Failure 7 Consumer First 8 Highly Observable

Slide 18

Slide 18 text

20 2019 KrakenD API Gateway Principles Of Microservices Modelled Around Business Domain Define Bounded Context Analyze your domain Define entities,aggregates, and services Identify microservices

Slide 19

Slide 19 text

20 2019 KrakenD API Gateway Principles Of Microservices Modelled Around Business Domain

Slide 20

Slide 20 text

20 2019 KrakenD API Gateway Principles Of Microservices Modelled Around Business Domain Checkout Search Payment Customer Content Campaign Shipping & Delivery Customer Service Fulfillment Customer Service Products not Projects per team per product Amazon’s notion of “you build, you run it”. This brings developers into contact with the day-to-day operation of their software. It also brings them into day-to-day contact with the customer. This customer feedback loop is essential for improving the quality of the service. https://queue.acm.org/detail.cfm?id=1142065

Slide 21

Slide 21 text

20 2019 KrakenD API Gateway Principles Of Microservices Culture Of Automation Infrastructure Automation (provision an isolated operation system or service, database, cache service, e.g) Automated Testing (sufficient testing in place that helps me understand whether I can release my software) Continuous Delivery (treating every check-in as a release candidates , building deployment pipelines , canary)

Slide 22

Slide 22 text

20 2019 KrakenD API Gateway Principles Of Microservices Culture Of Automation Canary Deployment https://docs.flagger.app/tutorials/istio-progressive-delivery

Slide 23

Slide 23 text

20 2019 KrakenD API Gateway Principles Of Microservices Culture Of Automation Canary Deployment Istio and Flagger to automate canary deployments https://docs.flagger.app/tutorials/istio-progressive-delivery

Slide 24

Slide 24 text

20 2019 KrakenD API Gateway Principles Of Microservices Deploy Independently Single Service Instance Per Host ● Services are written using a variety of languages, frameworks, and framework versions ● Each service consists of multiple service instances for throughput and availability ● Service must be independently deployable and scalable ● Service instances need to be isolated from one another ● You need to be able to quickly build and deploy a service ● You need to be able to constrain the resources (CPU and memory) consumed by a service ● You need to monitor the behavior of each service instance ● You want deployment to reliable ● You must deploy the application as cost-effectively as possible https://microservices.io/patterns/deployment/single-service-per-host.html Inventory Promotions Basket Payments HOST Inventory HOST Payments Container

Slide 25

Slide 25 text

20 2019 KrakenD API Gateway Principles Of Microservices Deploy Independently CO-Exist Endpoints Basket Promotions V1 V2

Slide 26

Slide 26 text

20 2019 KrakenD API Gateway Principles Of Microservices Decentralise All The Things Make your teams more Autonomous What is autonomy ? Giving people as much freedom as possible to do the job at hand

Slide 27

Slide 27 text

Hepsiburada Tech stack https://stackshare.io/hepsiburada/hepsiburada

Slide 28

Slide 28 text

20 2019 KrakenD API Gateway Principles Of Microservices Decentralise All The Things Dumb-Pipes… Smart Endpoints... Anti-pattern: Centralized Service Bus Source:: https://medium.com/@nathankpeck/microservice-principles-smart-endpoints-and-dumb-pipes-5691d410700f

Slide 29

Slide 29 text

20 2019 KrakenD API Gateway Principles Of Microservices Hide Implementation Details Database Per Service Service must be loosely coupled so that they can be developed, deployed and scaled independently. Different services have different data storage requirements. Keep each microservice’s persistent data private to that service and accessible only via its API. My List Service Catalog Service Projection Builder Reco Service

Slide 30

Slide 30 text

20 2019 KrakenD API Gateway Principles Of Microservices Hide Implementation Details Bounded Context Source : martinfowler.com/bliki/BoundedContext.html

Slide 31

Slide 31 text

Search

Slide 32

Slide 32 text

Product Detail

Slide 33

Slide 33 text

My List

Slide 34

Slide 34 text

Order Preview

Slide 35

Slide 35 text

20 2019 KrakenD API Gateway Principles Of Microservices Consumer First API Documentation

Slide 36

Slide 36 text

Mesh: east-west traffic API GW: North-south traffic 20 2019 KrakenD API Gateway Principles Of Microservices Isolate Failure Microservice Microservice Monolith Microservice Microservice Microservice API GW Microservice Microservice Microservice Strategies to handle partial failure - Grained Timeout - Health Checks API - Caching

Slide 37

Slide 37 text

20 2019 KrakenD API Gateway Principles Of Microservices Isolate Failure Strategies to handle partial failure - Circuit Breakers (even on your database) - Bulkhead - Throttling ( Rate limiting, User Quota ) } } } CMS Service Catalog Service Recommendation Service Basket Recommendation Service API GW & Backend For Frontend

Slide 38

Slide 38 text

20 2019 KrakenD API Gateway Principles Of Microservices Back to Consumer First Question : Should I Provide a client library for access to my service... Well, It depends Client libraries can be useful for many reasons, one of which is isolating the specifics of communicating with a remote resource. For service registries, client libraries like those provided by Consul or Netflix Eureka handle service registration and heart beating. Other libraries, such as Netflix Ribbon, provide client-side load balancing. But not good in polyglot development ecosystem.

Slide 39

Slide 39 text

20 2019 KrakenD API Gateway Principles Of Microservices Isolate Failure Need more Resilience! Containerization - K8S, Istio (Service Mesh) , pod2pod communication thx to etcd

Slide 40

Slide 40 text

20 2019 KrakenD API Gateway Principles Of Microservices Observable Logging Splunk , ELK Metrics Prometheus , statsd , Grafana Distributed Tracing Jaeger, Zipkin , Kiali 3 Pillars of Observability

Slide 41

Slide 41 text

Logging

Slide 42

Slide 42 text

Logging

Slide 43

Slide 43 text

Metrics

Slide 44

Slide 44 text

Metrics

Slide 45

Slide 45 text

Metrics

Slide 46

Slide 46 text

Distributed Tracing

Slide 47

Slide 47 text

Distributed Tracing

Slide 48

Slide 48 text

Distributed Tracing

Slide 49

Slide 49 text

Questions? @alper_hankendi github.com/alperhankendi