Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Microservices

 Microservices

Microservices are a software development technique—a variant of the service-oriented architecture architectural style that structures an application as a collection of loosely coupled services. In a microservices architecture, services are fine-grained and the protocols are lightweight.
The benefit of decomposing an application into different smaller services is that it improves modularity. This makes the application easier to understand, develop, test, and become more resilient to architecture erosion. It parallelizes development by enabling small autonomous teams to develop, deploy and scale their respective services independently. It also allows the architecture of an individual service to emerge through continuous refactoring. Microservice-based architectures facilitate continuous delivery and deployment. (Wiki)

Krishantha Dinesh

October 10, 2019
Tweet

More Decks by Krishantha Dinesh

Other Decks in Programming

Transcript

  1. * 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
  2. * 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.
  3. * 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.
  4. * 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.
  5. * 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 …………….
  6. * 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)
  7. * 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.
  8. * 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
  9. * 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)
  10. * 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.
  11. * 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
  12. * 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?
  13. * 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
  14. * 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
  15. * 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.
  16. * 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.
  17. * 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 )
  18. * 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
  19. * 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
  20. * 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
  21. * 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