Slide 1

Slide 1 text

Microservices Krishantha Dinesh Msc, MIEEE, MBCS Software Architect www.krishantha.com www.youtube.com/krish @krishantha

Slide 2

Slide 2 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ WARNING If(mobilephone){ throw new LeaveTheSessionException(“sorry”); } //No mobile phones != silent mode

Slide 3

Slide 3 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ This is how we see about us

Slide 4

Slide 4 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Sometimes we do see other people work on M/S projects with state of art technologies

Slide 5

Slide 5 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ You get an opportunity on M/S project

Slide 6

Slide 6 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ I am working on microservice project

Slide 7

Slide 7 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Listen to tech talk about M/S dockers CICD

Slide 8

Slide 8 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ You have no idea what they talk about

Slide 9

Slide 9 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ The time you realize you did monolithic project using M/S framework

Slide 10

Slide 10 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ How to be fearless and live like king for your territory?

Slide 11

Slide 11 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ What is Microservice • Microservice is independently scalable and deployable loosely coupled service oriented architecture which has bounded context There are few points of above very important. • Independently deployable • Independently scalable • Loosely couple • Bounded context

Slide 12

Slide 12 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Current problem • Long release cycle for small change • When work with more developers merging is nightmare • It take long time to see functional outcome • Deployment is risk and become headache.

Slide 13

Slide 13 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Why it is trend • Because people want to get latest architecture / technologies despite its fit to them or not ------------------------------------------------------------------------------------------------------------------------------------------------ if people comes to it after knowing what it is then it because • Change friendly. Microservices are mean to faster change • Business are keep changing. some monolithic projects take longer time to incorporate new changes of business process. Sometime when system ready.. Business process change again.

Slide 14

Slide 14 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ • Availability friendly. • Microservices are loosely coupled. So it will not create bigger load on single server. Also failures are separated. So there Is not signle point of failured anymore. • Scalability friendly • In a system one module may have high demand than the other one. In such case we can scale only and only particular call. Since it is loosely coupled it is not required to scale unnecessary modules when you need to scale. Also if one service has a problem that does not cause to cascade failures.

Slide 15

Slide 15 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ How it looks like • It has dedicated purpose of living (well define scope) • It can communicate it own way. Can be HTTP or JMS etc • Can be (should be) deploy independently • Can be (should be) scale independently • Language independent ……………. Do one thing and do it well …………….

Slide 16

Slide 16 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Independently scalable • Scale out through X like add data center or new instance • Sharding through Z i.e geo partitioning • Functional decomposition via Y (microservices)

Slide 17

Slide 17 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Does Microservice has magical power ? • It does not fallen from sky • It does not came from spirit • It does not have political background • It has nothing to do with God or Devil So Microservices are not “fit all” solution. It has its own issues risk and disadvantages. If you do right it will save you. If you do wrong.. It will bite you.

Slide 18

Slide 18 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Microservices Vs SOA • Microservices considered as SOA 2.0 (is it ? ) • However Microservices other side of the ESB page • ESB has intelligent middleware and dump backend however microservices dump pipe and intelligent backend

Slide 19

Slide 19 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ You build it – you own it • Microservice ideally build from smaller team which know A-Z about the service. • since it is isolated debug made easy • Domain is unique and well define, so understanding the problem is easy • Since same team who develop the service look in to the support tickets (ideally) isolating problem is easy • Since there is no tight coupling deployment of bug fixes / new features easy (independently deployable)

Slide 20

Slide 20 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Characteristics • Each functionality exposed as service • And every service has fixed bounded contract / purpose of living • Service should be loosely coupled. • Respect to right of being independency of each • Resilience should not a feature any more and it is must • Continues delivery should “ must” support • Should be able develop deploy maintain by separate teams.

Slide 21

Slide 21 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ How micro it should be • This is very debatable and open topic • Should limit number of lines? • Each functionality should go as separate service ? isn’t it too granular? • Two combo meal / two pizza team concept

Slide 22

Slide 22 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Should start from scratch / re write? • Not necessary. Still some architects prefer to start as monolithic and convert later to micro service. • Any monolithic application can convert as micro services phase by phase. • Important point is not “where it start” but “How it starts” means need to identify boundaries for the services properly. And solve tight couplings. • Identify where it belongs to. i.e customer may exist in customer registration as well as support module. Which service should responsible to maintain customer?

Slide 23

Slide 23 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Should we go for microservices? • Can we separate clear boundary (DDD) • Do we have full stack team OR can we form full stack team

Slide 24

Slide 24 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Available frameworks • Spring cloud • Based on most popular java framework out there. takes an opinionated view of building production-ready Spring applications. Spring Boot favors convention over configuration and is designed to get you up and running as quickly as possible. • Dropwizard • It is a bundle of some successful libraries such as Jetty, Jersey and Jackson • Vertx • Vertx is a tool-kit for building reactive applications on the JVM.”. You can develop with it in Java of course, but also many languages running on the JVM (Javascript, Scala, Ruby, Python, Clojure) • Restlet • many people heard of it but few use it (including me J ) • MSF4J • WSO2 Microservices Framework for Java (WSO2 MSF4J) offers the best option to create microservices in Java with container-based deployment in mind

Slide 25

Slide 25 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Spring cloud • Released in 2015 • Open source framework • Run anywhere • Build on Industry standard patterns and best practices. • Include Netflix OSS technologies.

Slide 26

Slide 26 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Then what is Spring Boot • Started early 2013 • Version 1.0.0 released on April 2014 • Convention over configuration • Opinions can be override. (i.e change port to whatever you want) • Dependency management made simple. • Container less (embed server in to jar) • Most of required features are inbuilt as various frameworks.

Slide 27

Slide 27 text

Create basic microservice

Slide 28

Slide 28 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Hello world • There are multiple ways you can start microservice project using sping cloud • Create project from initializer website and import to IDE [https://start.spring.io/] • Use spring STS create using wizard • Use inteliJ (only ultimate edition support for wizard) • Create classic maven project and add dependency manually. (demo – I love basics J )

Slide 29

Slide 29 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ pom file

Slide 30

Slide 30 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Project can find here : https://github.com/krishantha/microservice-samples/tree/master/hello-microservice

Slide 31

Slide 31 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Get health of the service • /health – Shows application health information (a simple ‘status’ when accessed over an unauthenticated connection or full message details when authenticated). • ./info – Displays arbitrary application info. • /metrics – Shows ‘metrics’ information for the current application. • /trace – Displays trace information (by default the last few HTTP requests). • /beans – all the beans • /env – get environment information • /mappings – get mapping information

Slide 32

Slide 32 text

Tasks for Asynchronous

Slide 33

Slide 33 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Why we need it • To make Asynchronous processors so can make reduce dependencies between services. – usually rest services use HTTP as protocol and which is Synchronous and it cause wait until process complete (suggest: messaging) • Reduce blocking calls can increase latency and deliver high throughput. • Support for event driven model. Can trigger external services beyond usual request response architecture. • Can avoid cascading failures due to thread or resource lock/ block

Slide 34

Slide 34 text

* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-din/ Why it is important • Sometime we have services which not frequently used. • Though its not use frequently we have to keep it online to serve when it need. • Solve problem of scaling problem as task work on demand no coupling