Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

WILD microSERVICES v2

Everyone has heard about microservices. Someone tries to implement them in practice. And only the bravests of us have already used them in production environment. But then why so many people hype around microservices, if the idea is not quite new? What are microservices? What is the difference between it and good old SOA approach? How can developers create modern enterprise applications in Java easily with the help of this approach?
Our guests should try to answer these questions and share their own experience related to live coding of imaginary startup 'Hippos'. The following topics will be covered:
What are microservices? Where is the theory, bro?
What kind of technologies should we choose? What have we chosen and why?
Why RPC is still competetive in REST-domination era?
How to pack and distribute microservices? How can SpringBoot and Docker help us to solve our problems?
Why is service discovery considered as one of the crucial components? How to cook Spring Cloud and what problems you may face in real life?
Security of microservices, API gateway and other.
Speakers will also cover other topics related to distributed system development.

Related Books

Free with a 30 day trial from Scribd

See all
  • Be the first to comment

  • Be the first to like this

WILD microSERVICES v2

  1. 1. WILD microSERVICES 18+
  2. 2. @tolkv 2
  3. 3. @aatarasoff 3
  4. 4. WILD microSERVICES 18+
  5. 5. DISCLAIMER No warranty guarantee 5
  6. 6. Agenda 1. Theory 2. Practice 3. Q&A 6
  7. 7. 7
  8. 8. 8
  9. 9. 9
  10. 10. Ball of Mud 10
  11. 11. SOA Principles 1. standardized service contract 2. loose coupling 3. encapsulation 4. reusability 5. autonomy 6. statelessness 7. discoverability 11
  12. 12. 12
  13. 13. 13
  14. 14. Никто не любит “некрасивые” технологии поэтому они умирают
  15. 15. 15 Про тренды
  16. 16. In short, the microservice architectural style is an approach to developing a single application as a suite of small services, 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 programming languages and use different data storage technologies. -- James Lewis and Martin Fowler Что такое микросервисы? 16
  17. 17. In short, the microservice architectural style is an approach to developing a single application as a suite of small services, 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 programming languages and use different data storage technologies. -- James Lewis and Martin Fowler Что такое микросервисы? 17
  18. 18. Размер имеет значение? ● Method/Function = Microservice? ● 10-300 LOC = Microservice? ● 1 week = Microservice? ● 1 developer = Microservice? 18
  19. 19. Размер не имеет значения* ● Single Responsibility ● One capability ● Bounded context “In your organization, you should be thinking not in terms of data that is shared, but about the capabilities those contexts provide the rest of the domain.” – Sam Newman, Building Microservices *до разумных пределов конечно 19
  20. 20. Domain-Driven Design 20
  21. 21. In short, the microservice architectural style is an approach to developing a single application as a suite of small services, 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 programming languages and use different data storage technologies. -- James Lewis and Martin Fowler Что такое микросервисы? 21
  22. 22. Process segregation 22
  23. 23. In short, the microservice architectural style is an approach to developing a single application as a suite of small services, 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 programming languages and use different data storage technologies. -- James Lewis and Martin Fowler Что такое микросервисы? 23
  24. 24. Независимый деплой build test 24
  25. 25. In short, the microservice architectural style is an approach to developing a single application as a suite of small services, 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 programming languages and use different data storage technologies. -- James Lewis and Martin Fowler Что такое микросервисы? 25
  26. 26. Language/technology segregation 26
  27. 27. Data segregation 27
  28. 28. Team segregation 28
  29. 29. Принцип LSD - L языков программирования - S в среднем фреймворков на язык - D типов источников данных complexity = L * S * D 29
  30. 30. Пример - три языка программирования - два в среднем фреймворка на язык - семь типов источников данных - legacy WS, mongo db - хранимые процедуры, JDBC-templates - elasticsearch, neo4j - мишкина база complexity = 3 * 2 * 7 = 42 (!) 30
  31. 31. Чем нельзя жертвовать? min (L * S * D) -> ? 31
  32. 32. Закон трёх букв min (L * S * D) -> max (D) 32
  33. 33. Почему Spring Boot/Spring Cloud? 33
  34. 34. А теперь попробуем 34
  35. 35. Demo
  36. 36. Demo -> Deploy Time
  37. 37. Service Discovery 37
  38. 38. Demo -> Time to Discover
  39. 39. Где мой порт? 39
  40. 40. 40
  41. 41. Какие есть варианты? ● Nginx/Haproxy + consul template ● Haproxy + bamboo (need marathon) ● Netflix Zuul (Java way!!!) ● Custom Servlet <- все с этого начинают! 41
  42. 42. Netflix Zuul 42
  43. 43. Demo -> Gateway Time
  44. 44. Безопасность 44
  45. 45. Защита на уровне сервиса 45
  46. 46. Защита на уровне сервиса #2 46
  47. 47. Опять этот gateway 47
  48. 48. REST/HTTP Authorization: Bearer <TOKEN> ClientID: <ID> 48
  49. 49. Thrift API Gateway service InternalTestService { SomeReturnData getSomeData( 1: UserData userData, 2: RequestData requestData ) throws (1: SomeException e); } 49
  50. 50. Thrift API Gateway service InternalTestService { SomeReturnData getSomeData( 1: UserData userData, 2: RequestData requestData ) throws (1: SomeException e); } service ExternalTestService { SomeReturnData getSomeData( 1: AuthToken authData, 2: RequestData requestData ) throws (1: SomeException e, 99: UnauthorizedException ue); } 50
  51. 51. 51
  52. 52. Springway @SpringBootApplication @EnableThriftGateway public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } 52
  53. 53. Demo -> Thrift the Ripper
  54. 54. Demo -> Hystrix the Saviour
  55. 55. Типичная микросервисная архитектура 57
  56. 56. 58
  57. 57. А что в этих ваших интернетах?
  58. 58. 60 DDDD (4D)
  59. 59. Выводы 61 ● Микросервисы - это просто
  60. 60. Выводы 62 ● Микросервисы - это просто ● Микросервисы - это сложно
  61. 61. Парадокс (де)централизации микросервисов Чтобы эффективно работать с распределенными приложениями, нужно иметь очень хорошие централизованные библиотеки/инструменты Например: логирование, health-чеки, метрики, обработку программных ошибок 63
  62. 62. Парадокс (де)централизации микросервисов Чтобы эффективно работать с распределенными приложениями, нужно иметь очень хорошие централизованные библиотеки/инструменты Но: не выносите бизнес-логику или доменные объекты 64
  63. 63. LSD вам в помощь min (L * S * D) -> max (D) 65
  64. 64. Ссылки Оригинальное исполнение https://github.com/bsideup/thrift-spring-boot-starter Крутой плагин для Gradle https://github.com/bsideup/GradleThrift Forward2Docker https://github.com/bsideup/forward2docker/releases 66 @bsideup
  65. 65. Code. Better. Together. Spring Thrift Client https://github.com/aatarasoff/spring-thrift-starter Thrift API Gateway https://github.com/aatarasoff/thrift-api-gateway-core https://github.com/aatarasoff/spring-thrift-api-gateway Примеры сегодняшнего дня https://github.com/lavcraft/jug-samples 67
  66. 66. Высокие теории Sam Newman “Building Microservices” Martin Fowler “Microservice TradeOff” “Microservices” “The Twelwe-Factor App” http://12factor.net Hystrix: managing failures in distributed systems - Tomasz Nurkiewicz https: //www.youtube.com/watch?v=JadVts_prtA 68
  67. 67. Спасибо! Готовы ответить на ваши вопросы @tolkv @aatarasoff 69

×