73
WILD microSERVICES 18+

WILD microSERVICES v2 (JEEConf Edition)

Embed Size (px)

Citation preview

WILD microSERVICES

18+

@tolkv

2

@aatarasoff

3

WILD microSERVICES

18+

DISCLAIMER

No warranty guarantee

5

Agenda

1. Theory

2. Practice

3. Q&A

6

7

8

9

Ball of Mud

10

SOA Principles1. standardized service contract

2. loose coupling

3. encapsulation

4. reusability

5. autonomy

6. statelessness

7. discoverability11

12

13

Никто не любит “некрасивые” технологии

поэтому они умирают

15

Про тренды

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

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

Размер имеет значение?

● Method/Function = Microservice?

● 10-300 LOC = Microservice?

● 1 week = Microservice?

● 1 developer = Microservice?

18

Размер не имеет значения*

● 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

Domain-Driven Design

20

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

Process segregation

22

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

Независимый деплой

build test

24

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

Language/technology segregation

26

Data segregation

27

Team segregation

28

Принцип LSD

- L языков программирования- S в среднем фреймворков на язык- D типов источников данных

complexity = L * S * D

29

Пример

- три языка программирования- два в среднем фреймворка на язык- семь типов источников данных

- legacy WS, mongo db- хранимые процедуры, JDBC-templates- elasticsearch, neo4j- мишкина база

complexity = 3 * 2 * 7 = 42 (!)30

Чем нельзя жертвовать?

min (L * S * D) -> ?

31

Закон трёх букв

min (L * S * D) -> max (D)

32

Почему Spring Boot/Spring Cloud?

33

А теперь попробуем

34

35

Хочу бегемота!

Хочу бегемота!

Rent Service

36

37

Хочу бегемота!

Rent Service

Payment Service

38

Хочу бегемота!

Rent Service

Payment Service

Security Service Blockchain Service

39

Хочу бегемота!

Rent Service

Payment Service

Security Service Blockchain Service

Insurance Service

Problem -> Many Services

Demo -> Bootstrapping

Problem -> Delivery value

Demo -> Build, Distr, Deploy

Problem -> Find them all

Service Discovery

45

Demo -> Time to Discover

Problem -> goto Production

Где мой порт?

48

49

Какие есть варианты?

● Nginx/Haproxy + consul template

● Haproxy + bamboo (need marathon)

● Netflix Zuul (Java way!!!)

● Custom Servlet <- все с этого начинают!

50

Netflix Zuul

51

Demo -> Gateway Time

Problem -> Defend yourself

54

Demo -> Hystrix the Saviour

Problem -> Find the Trace

59

60

Demo -> Sleuthing

Типичная микросервисная архитектура

62

63

А что в этих ваших интернетах?

64

65

DDDD (4D)

Выводы

66

● Микросервисы - это просто

Выводы

67

● Микросервисы - это просто

● Микросервисы - это сложно

Парадокс (де)централизации микросервисов

Чтобы эффективно работать с распределенными приложениями, нужно иметь очень хорошие

централизованные библиотеки/инструменты

Например: логирование, health-чеки, метрики, обработку программных ошибок

68

Парадокс (де)централизации микросервисов

Чтобы эффективно работать с распределенными приложениями, нужно иметь очень хорошие

централизованные библиотеки/инструменты

Но: не выносите бизнес-логику или доменные объекты

69

LSD вам в помощь

min (L * S * D) -> max (D)

70

Code. Better. Together.

Примеры сегодняшнего дняhttps://github.com/lavcraft/wild-microservices-in-kiev

71

Высокие теории

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

72

Спасибо! Готовы ответить на ваши вопросы

@tolkv

@aatarasoff

73