Micro Services - Small is Beautiful

3,685 views
3,322 views

Published on

General int

Published in: Technology

Micro Services - Small is Beautiful

  1. 1. Micro Services Small is Beautiful Eberhard Wolff Freelancer / adesso AG http://ewolff.com
  2. 2. Architecture of Enterprise Java Apps
  3. 3. Eberhard Wolff - @ewolff
  4. 4. Eberhard Wolff - @ewolff
  5. 5. How can I implement a new feature??? Eberhard Wolff - @ewolff
  6. 6. Eberhard Wolff - @ewolff L
  7. 7. ECommerce System Eberhard Wolff - @ewolff New Stuff Spring & OSGi
  8. 8. ECommerce System Eberhard Wolff - @ewolff New Stuff NSepwri nSgtu &ff OSGi
  9. 9. Eberhard Wolff - @ewolff HTTP New Stuff Links No legacy code Any technology J Small code base
  10. 10. Micro Services: A Component Model • Separate process • Individual deployment unit • GUI (?) • + Logic • + database • Independent technology stacks • Small services + GUI – unlike SOA Eberhard Wolff - @ewolff
  11. 11. Components Collaborate Eberhard Wolff - @ewolff Micro Service Micro Service Link REST Messaging Data Replication
  12. 12. Micro Service can easily integrate with Legacy
  13. 13. Eberhard Wolff - @ewolff Online Shop Order Catalog Search Billing
  14. 14. Eberhard Wolff - @ewolff Online Shop elasticsearch Spring Batch Oracle Spring MVC MongoDB Order Catalog Search Billing
  15. 15. Service might be even smaller
  16. 16. Continuous Delivery Eberhard Wolff - @ewolff
  17. 17. Continuous Delivery: Build Pipeline Manual Explorative Testing Eberhard Wolff - @ewolff Automated Acceptance Testing Commit Stage Automated Capacity Testing Release
  18. 18. Without Micro Services • Modify order process slightly • Billing, Search & Catalog unchanged Eberhard Wolff - @ewolff Order Catalog Search Billing
  19. 19. Eberhard Wolff - @ewolff Order Catalog Search Billing
  20. 20. Continuous Delivery: Everything Tested etc Manual Explorative Testing Eberhard Wolff - @ewolff Automated Acceptance Testing Commit Stage Automated Capacity Testing Order Release Catalog Search Billing
  21. 21. Eberhard Wolff - @ewolff Build Pipeline • Just one component changed! • Lots of unneeded work • Takes much too long
  22. 22. With Micro Services Manual Explorative Testing Eberhard Wolff - @ewolff Automated Acceptance Testing Commit Stage Automated Capacity Testing Order Release
  23. 23. Eberhard Wolff - @ewolff Release • Just a single component • Faster feedback • Easier deployment • Rollback of single service also easier
  24. 24. How to scale Eberhard Wolff - @ewolff agile? Implement more feature
  25. 25. Eberhard Wolff - @ewolff Conways Law Architecture copies communication structures of the organization
  26. 26. Eberhard Wolff - @ewolff Online Shop Order Catalog Search Billing Component = Team
  27. 27. Eberhard Wolff - @ewolff Micro Service • Team independent from each other • No code dependencies • Can use individual technology stack • Can even deploy independently • Speed up development
  28. 28. Architecture Challenges • Code Reuse? • Handling interfaces? • Managing dependencies between (>100) Services? • Global architecture? • Global refactorings? Eberhard Wolff - @ewolff
  29. 29. Install and configure App Server for each Microservice??
  30. 30. Spring Boot Demo
  31. 31. Why Spring Boot? Eberhard Wolff - @ewolff • Easier deployment • i.e. just a JAR • Built in operations support
  32. 32. Eberhard Wolff - @ewolff Technologies • Dropwizard by Yammer • Vert.x • Play Framework
  33. 33. Deploy & Operate?
  34. 34. Component Model • No restriction on languag & environment • Individual processes • + infrastructure (database etc) • JARs, WARs, EARs: No good fit • Virtual machines as components? • Overhead?? Eberhard Wolff - @ewolff
  35. 35. Eberhard Wolff - @ewolff Docker • No true virtualization • Linux Containers (lxc) • i.e. shared kernel • i.e. separate file systems
  36. 36. Docker File Systems Eberhard Wolff - @ewolff • Read only base images • +read/write image • Can be stacked
  37. 37. Eberhard Wolff - @ewolff Docker • Linux only • So: Run it in VM • Controlled by Vagrant
  38. 38. Redis on Docker Eberhard Wolff - @ewolff • Small NoSQL database • In memory • Quite a few cool features
  39. 39. Eberhard Wolff - @ewolff Vagrant VM Docker Container Redis 6379 6379 Port 6379
  40. 40. Docker Demo
  41. 41. Communication Between Docker Container Eberhard Wolff - @ewolff • Via ports • Via data volumes
  42. 42. Docker is a Component System
  43. 43. Example: Log File Analysis
  44. 44. No Docker, no Micro Services • Log file analysis • One Application • Store (database) • Parse • GUI • One artifact on one server • Logs provided e.g. by a port Eberhard Wolff - @ewolff
  45. 45. Docker, Small Services • Log file analysis • ELK Stack • Elasticsearch: Store • Logstash: Parse • Kibana: Web based GUI • Install three servers • Automate installation ... L Eberhard Wolff - @ewolff
  46. 46. Dockerized ELK Stack • 1 Vagrantfile (25 lines) • 6 Dockerfiles (total 22 lines) • 1 HTML file (11 lines) • 1 Config (Logstash) (29 lines) Eberhard Wolff - @ewolff • Total: 87 lines, 9 files • Including one RegExp L
  47. 47. 8080 8080 Eberhard Wolff - @ewolff Vagrant VM Container user-registration 8080 8081 Port 8081 Container elasticsearch Container logstash 9200 9200 Port 9200 9200 link Container kibana Port 8080 Browser Volume /log
  48. 48. Demo ELK Stack
  49. 49. Individual Scaling per Service
  50. 50. Eberhard Wolff - @ewolff Links • https://github.com/ewolff/user-registration • http://www.heise.de/developer/ artikel/Episode-44-Modularisierte- Architektur-fuer-grosse- Systeme-2195818.html • http://projects.spring.io/spring-boot/ • http://www.docker.com/ • http://www.docker.com/tryit
  51. 51. Eberhard Wolff - @ewolff
  52. 52. Eberhard Wolff - @ewolff Micro Services • A new hope against Java Monoliths • Also great for legacy • Spring Boot for implementation • Docker as component model & runtime
  53. 53. Thank You!! Eberhard Wolff - @ewolff @ewolff

×