Эволюционный дизайн. joker students day 2016
TRANSCRIPT
10
У нас конечно же так
Потому что● мы работаем в лучшем банке● и все остальные банки завидуют нам● …● Стойте, кажется это про другое
yoman
Yo
start.spring.io
Ss
python
Py
lazybones
Lzjava
Ja
spring boot
Sb
gradle
Grasciidoctor
Adthrift
Thdocker
Dr
mesos
Ms
marathon
Machronos
Chaurora
AuArtifactory
Ar
Kubernetes
Kb
eureka
Eu
consul
Cl
etcd
Ed
zookeeper
Zkhystrix
Hx
sleuth
Sl
zipkin
Zn
groovy
Gy
28
Data Isolation
DiCentralization paradox
CpLSD principle
LsDDD
DdConway’s Law
CoSmart Docs
SdDynamic Sharing
DsSmart Libs
SlSOA
So
ansible
An
yoman
Yo
start.spring.io
Ss
python
Py
lazybones
Lzjava
Ja
spring boot
Sb
gradle
Grasciidoctor
Adthrift
Thdocker
Dr
mesos
Ms
marathon
Machronos
Chaurora
AuArtifactory
Ar
Kubernetes
Kb
eureka
Eu
consul
Cl
etcd
Ed
zookeeper
Zkhystrix
Hx
sleuth
Sl
zipkin
Zn
groovy
Gy
29
Data Isolation
DiCentralization paradox
CpLSD principle
LsDDD
DdConway’s Law
CoSmart Docs
SdDynamic Sharing
DsSmart Libs
SlSOA
So
ansible
An
yoman
Yo
start.spring.io
Ss
python
Py
lazybones
Lzjava
Ja
spring boot
Sb
gradle
Grasciidoctor
Adthrift
Thdocker
Dr
mesos
Ms
marathon
Machronos
Chaurora
AuArtifactory
Ar
Kubernetes
Kb
eureka
Eu
consul
Cl
etcd
Ed
zookeeper
Zkhystrix
Hx
sleuth
Sl
zipkin
Zn
groovy
Gy
30
Data Isolation
DiCentralization paradox
CpLSD principle
LsDDD
DdConway’s Law
CoSmart Docs
SdDynamic Sharing
DsSmart Libs
SlSOA
So
ansible
An
34
Проблемы архитектуры
● Сильная связанность между модулями
● Слабое тестовое прикрытие
● Регрессионная спираль смерти○ частично решалась Selenium-тестами
○ но это дорого
12 April 1996Первое упоминание SOA
https://www.gartner.com/doc/302868/service-oriented-architectures- 41
Принципы SOA1. Standardized service contract
2. Loose coupling
3. Encapsulation
4. Reusability
5. Autonomy
6. Statelessness
7. Discoverability42
Принципы SOA1. Standardized service contract
2. Loose coupling
3. Encapsulation
4. Reusability
5. Autonomy
6. Statelessness
7. Discoverability43
5 January 2009SOA is Dead
http://apsblog.burtongroup.com/2009/01/soa-is-dead-long-live-services.html 45
48
Проблема эволюции
● Начинали с одного проекта○ одна команда○ ui + три сервиса
● Более 10-ти однотипных проектов○ несколько команд○ десятки сервисов○ технологически одинаковые
52
● Spring Boot/Spring Cloud
● Ratpack
● Dropwizard
● Vert.x
● Restlet
● Spark
● KumuluzEE
Выбирайте то, что больше нравится
/ в чем есть экспертиза
Принцип LSD
- L языков программирования- S среднее число фреймворков на язык- D типов источников данных
complexity = L * S * D
55
Немного LSD для вас
- три языка программирования- два в среднем фреймворка на язык- семь типов источников данных
- legacy WS, mongo db- OLTP, OLAP- elasticsearch, neo4j- Мишкина база %)
complexity = 3 * 2 * 7 = 42 (!)56
68
Код устарелНужно переименовать классыНужно удалить неиспользуемоеПрочая магия
Время, ошибки, фрагментация
~home > lazybones create api 0.0.1 rent-serviceCreating project from template api 0.0.1 in 'rent-service'Define value for 'group' [ru.joker]:
74
~home > lazybones create api 0.0.1 rent-serviceCreating project from template api 0.0.1 in 'rent-service'Define value for 'group' [ru.joker]:Define value for 'version' [0.0.1]:
75
~home > lazybones create api 0.0.1 rent-serviceCreating project from template api 0.0.1 in 'rent-service'Define value for 'group' [ru.joker]:Define value for 'version' [0.0.1]:
srv1 ├──srv2 └──srv3
loggingsleuth
Define value for 'dependencies' [logging,sleuth]:
76
~home > lazybones create api 0.0.1 rent-serviceCreating project from template api 0.0.1 in 'rent-service'Define value for 'group' [ru.joker]:Define value for 'version' [0.0.1]:
srv1 ├──srv2 └──srv3
loggingsleuth
Define value for 'dependencies' [logging,sleuth]:
Project created for rent-service!
77
lazybones
Lz
yeoman
Yo
start.spring.io
Ssjava
Ja
spring boot
Sbgroovy
Gy
79
LSD principle
LsDDD
DdSOA
SoConway’s Law
Co
TServerTransport serverTransport = new TServerSocket( new InetSocketAddress(InetAddress.getLocalHost(), port));
TProcessor processor = new TInsuranceService.Processor<>(
//business value here);
server = new TSimpleServer(new
TServer.Args(serverTransport).processor(processor));
server.serve();
81
TSocket transport = new TSocket(host, port);transport.open();
TBinaryProtocol tBinaryProtocol = new TBinaryProtocol(transport);TInsuranceService.Client client =
new TInsuranceService.Client(tBinaryProtocol);
perform(client); //business value here
transport.close(); 82
@ThriftControllerpublic class InsuranceController implements TInsuranceService.Iface { @Override public void someMethod(TInsurance insurance){ //business value here }}
83
@ThriftClient(serviceId = "insurance-service")TInsuranceService.Client client;
...perform(client); //business value here...
84
@ThriftClient(serviceId = "insurance-service")TInsuranceService.Client client;
TInsuranceService.Client client = Creator.create(TInsuranceService.Client.class,
"insurance-service");
...perform(client); //business value here...
87
@Getter // generate getters@Setter // generate setters@Aspect // we are an aspect@ToString // generate toString()@EnableWs // SOAP is so enterprisy, we definitely need it@Endpoint // Seriously, just read above@EnableWebMvc // we want MVC@EnableCaching // and we want to cache stuff@Configuration // this class can configure itself@RestController // we want some REST@XmlRootElement // this component is marshallable@EnableWebSocket // we want web socket, it's so new-generation@RedisHash("cat") // this class is an entity saved in redis@EnableScheduling // we want scheduled tasks@EnableWebSecurity // and some built-in security@NoArgsConstructor // generate no args constructor@ContextConfiguration // we want context configuration for unit testing@SpringBootApplication // this is a Sprint Boot application@Accessors(chain = true) // getters/setters are chained (ala jQuery)@EnableAspectJAutoProxy // we want AspectJ auto proxy@EnableAutoConfiguration // and auto configuration@EnableRedisRepositories // since it is an entity we want to enable spring data repositories for redis@EnableWebSocketMessageBroker // we want a broker for web socket messages
88
Not smart= This is main documentation
This document describes how to be the most fundamental and important document in the world of documents
...COPY-PASTE documentation from another document...
91
Not so smart= This is main documentation
This document describes how to be the most fundamental and important document in the world of documents
include::https://raw.github.com/asciidoctor/asciidoctor/master/Gemfile[]
include::../other.adoc[]include::/home/tolkv/git/docs-0/superdoc.adoc[]
92
Really smart= This is main documentation
This document describes how to be the most fundamental and important document in the world of documents
include::https://raw.github.com/asciidoctor/asciidoctor/master/Gemfile[]
include::gradle://gradle-advanced:service-with-deps:1.0/deps.adoc[]include::gradle://:service/doc.adoc[]
93
Payment Service[jar,doc] Insurance Service [jar,doc]
One Point of View [UberDoc.zip]
Rent Service[jar,doc] Other Service [jar,doc]
Агрегация информации
94
Парадокс централизацииЧтобы эффективно разрабатывать распределённые
приложения, нам нужны очень хорошие централизованные библиотеки и инструменты
Например: логирование, health-checking, метрики, обработка типовых ошибок, автодокументирование
95
Парадокс централизацииЧтобы эффективно разрабатывать распределённые
приложения, нам нужны очень хорошие централизованные библиотеки и инструменты
Но: не выносите бизнес-логику или доменные объекты!Не размывайте бизнес-контекст вашего API
96
lazybones
Lz
yoman
Yo
start.spring.io
Ssjava
Ja
thrift
Th
spring boot
Sb
gradle
Grasciidoctor
Ad
groovy
Gy
97
Centralization paradox
CpLSD principle
LsDDD
DdSmart Docs
SdSmart Libs
SlSOA
SoConway’s Law
Co
lazybones
Lz
yoman
Yo
start.spring.io
Ssjava
Ja
thrift
Th
spring boot
Sb
gradle
Grasciidoctor
Ad
groovy
Gy
113
Data Isolation
DiCentralization paradox
CpLSD principle
LsDDD
DdConway`s law
CoSmart Docs
SdSmart Libs
SlSOA
So
./gradlew deployToArtifactoryansible -i [stage,dev,test] -t deploy
“Прибитая молотком” конфигурация122
Представьте, что кластер это просто одна большая машина
WEB
WASTED
CACHE
WASTED WASTED
HADOOP
WASTED
WEBCACHE
HADOOP FREE FREE
134
lazybones
Lz
yoman
Yo
start.spring.io
Ss
python
Py
java
Ja
spring boot
Sb
gradle
Grasciidoctor
Addocker
Dr
mesos
Ms
marathon
Machronos
Chaurora
Au
Kubernetes
Kbgroovy
Gy
135
Data Isolation
DiCentralization paradox
CpLSD principle
LsDDD
DdSAGAS
SaSmart Docs
SdDynamic Sharing
DsSmart Libs
SlSOA
So
ansible
Anthrift
ThArtifactory
Ar
140
Service ClientRegistry-aware
HTTP Client
Service Registry
Service Instance 1
Service Instance N
Service Instance ...
Load balance request
Client side discovery
141
Service Client
Service Registry
Service Instance 1
Service Instance N
Service Instance ...
Load balance requestRouter/Proxy
Server side discovery
yoman
Yo
start.spring.io
Ss
python
Py
lazybones
Lzjava
Ja
spring boot
Sb
gradle
Grasciidoctor
Adthrift
Thdocker
Dr
mesos
Ms
marathon
Machronos
Chaurora
AuArtifactory
Ar
Kubernetes
Kb
eureka
Eu
consul
Cl
etcd
Ed
zookeeper
Zkgroovy
Gy
142
Data Isolation
DiCentralization paradox
CpLSD principle
LsDDD
DdSAGAS
SaSmart Docs
SdDynamic Sharing
DsSmart Libs
SlSOA
So
ansible
An
145
Хочу бегемота!
Rent Service
Payment Service
Security Service Blockchain Service
Insurance Service
5мс
146
Хочу бегемота!
Rent Service
Payment Service
Security Service Blockchain Service
Insurance Service
300мс
147
Хочу бегемота!
Rent Service
Payment Service
Security Service Blockchain Service
Insurance Service
300мс
148
Хочу бегемота!
Rent Service
Payment Service
Security Service Blockchain Service
Insurance Service
300мс
149
Хочу бегемота!
Rent Service
Payment Service
Security Service Blockchain Service
Insurance Service
300мс
151
Хочу бегемота!
Rent Service
Payment Service
Security Service Blockchain Service
Insurance Service
300мс
152
Хочу бегемота!
Rent Service
Payment Service
Security Service Blockchain Service
Insurance Service
300мсOpen
153
Хочу бегемота!
Rent Service
Payment Service
Security Service Blockchain Service
Insurance Service
300мсHalf-Open
154
Хочу бегемота!
Rent Service
Payment Service
Security Service Blockchain Service
Insurance Service
5мсHalf-Open
155
Хочу бегемота!
Rent Service
Payment Service
Security Service Blockchain Service
Insurance Service
5мс
yoman
Yo
start.spring.io
Ss
python
Py
lazybones
Lzjava
Ja
spring boot
Sb
gradle
Grasciidoctor
Adthrift
Thdocker
Dr
mesos
Ms
marathon
Machronos
Chaurora
AuArtifactory
Ar
Kubernetes
Kb
eureka
Eu
consul
Cl
etcd
Ed
zookeeper
Zkhystrix
Hxgroovy
Gy
158
Data Isolation
DiCentralization paradox
CpLSD principle
LsDDD
DdSmart Docs
SdDynamic Sharing
DsSmart Libs
SlSOA
So
ansible
An
Conway’s Law
Co
164
Rent
Ser
vice
Paym
ent
Serv
ice
No TraceIdNo SpanId
TraceId = XSpanId = A
TraceId = XSpanId = B
TraceId = XSpanId = C
165
Rent
Ser
vice
Paym
ent
Serv
ice
Bloc
kcha
in S
ervi
ce
No TraceIdNo SpanId
TraceId = XSpanId = A
TraceId = XSpanId = B
TraceId = XSpanId = C
TraceId = XSpanId = D
TraceId = XSpanId = D
TraceId = XSpanId = F
166
Rent
Ser
vice
Paym
ent
Serv
ice
Secu
rity
Ser
vice
Bloc
kcha
in S
ervi
ce
No TraceIdNo SpanId
TraceId = XSpanId = A
TraceId = XSpanId = B
TraceId = XSpanId = C
TraceId = XSpanId = D
TraceId = XSpanId = D
TraceId = XSpanId = E
TraceId = XSpanId = E
TraceId = XSpanId = F
TraceId = XSpanId = G
167
Rent
Ser
vice
Paym
ent
Serv
ice
Secu
rity
Ser
vice
Bloc
kcha
in S
ervi
ce
No TraceIdNo SpanId
TraceId = XSpanId = A
TraceId = XSpanId = B
TraceId = XSpanId = B
TraceId = XSpanId = C
TraceId = XSpanId = C
TraceId = XSpanId = D
TraceId = XSpanId = D
TraceId = XSpanId = E
TraceId = XSpanId = E
TraceId = XSpanId = F
TraceId = XSpanId = G
168
Rent
Ser
vice
Paym
ent
Serv
ice
Secu
rity
Ser
vice
Bloc
kcha
in S
ervi
ce
TraceId = XSpanId = A
No TraceIdNo SpanId
TraceId = XSpanId = A
TraceId = XSpanId = A
TraceId = XSpanId = B
TraceId = XSpanId = B
TraceId = XSpanId = C
TraceId = XSpanId = C
TraceId = XSpanId = D
TraceId = XSpanId = D
TraceId = XSpanId = E
TraceId = XSpanId = E
TraceId = XSpanId = F
TraceId = XSpanId = G
173
Rent
Ser
vice
Paym
ent
Serv
ice
SpanId = BClient Send
SpanId = BServer Received
TraceId = XSpanId = A
TraceId = XSpanId = C
174
Rent
Ser
vice
Paym
ent
Serv
ice
SpanId = BClient Send
SpanId = BServer Received
SpanId = BServer Send
TraceId = XSpanId = A
TraceId = XSpanId = C
175
Rent
Ser
vice
Paym
ent
Serv
ice
SpanId = BClient Send
SpanId = BServer Received
SpanId = BClient Received
SpanId = BServer Send
TraceId = XSpanId = A
TraceId = XSpanId = C
yoman
Yo
start.spring.io
Ss
python
Py
lazybones
Lzjava
Ja
spring boot
Sb
gradle
Grasciidoctor
Adthrift
Thdocker
Dr
mesos
Ms
marathon
Machronos
Chaurora
AuArtifactory
Ar
Kubernetes
Kb
eureka
Eu
consul
Cl
etcd
Ed
zookeeper
Zkhystrix
Hx
sleuth
Sl
zipkin
Zn
groovy
Gy
176
Data Isolation
DiCentralization paradox
CpLSD principle
LsDDD
DdSmart Docs
SdDynamic Sharing
DsSmart Libs
SlSOA
So
ansible
An
Conway’s Law
Co
yoman
Yo
start.spring.io
Ss
python
Py
lazybones
Lzjava
Ja
spring boot
Sb
gradle
Grasciidoctor
Adthrift
Thdocker
Dr
mesos
Ms
marathon
Machronos
Chaurora
AuArtifactory
Ar
Kubernetes
Kb
eureka
Eu
consul
Cl
etcd
Ed
zookeeper
Zkhystrix
Hx
sleuth
Sl
zipkin
Zn
groovy
Gy
177
Data Isolation
DiCentralization paradox
CpLSD principle
LsDDD
DdSmart Docs
SdDynamic Sharing
DsSmart Libs
SlSOA
So
ansible
An
Conway’s Law
Co
yoman
Yo
start.spring.io
Ss
python
Py
lazybones
Lzjava
Ja
spring boot
Sb
gradle
Grasciidoctor
Adthrift
Thdocker
Dr
mesos
Ms
marathon
Machronos
Chaurora
AuArtifactory
Ar
Kubernetes
Kb
eureka
Eu
consul
Cl
etcd
Ed
zookeeper
Zkhystrix
Hx
sleuth
Sl
zipkin
Zn
groovy
Gy
178
Data Isolation
DiCentralization paradox
CpLSD principle
LsDDD
DdSmart Docs
SdDynamic Sharing
DsSmart Libs
SlSOA
So
ansible
An
Conway’s Law
Co
?
1. Архитектура – функция от множества переменных
2. Архитектура – результат эволюции на протяжении времени
Простить, потому что
181
1. Архитектура – функция от множества переменных
2. Архитектура – результат эволюции на протяжении времени
3. Принципы должны быть “вечны”, а инструменты актуальны и эффективны
Простить, потому что
182
1. SOA принципы живы2. Принцип LSD3. Изоляция данных делает жизнь приятнее
Придерживайтесь принципов
185
1. SOA принципы живы2. Принцип LSD3. Изоляция данных делает жизнь приятнее4. Парадокс централизации
Придерживайтесь принципов
186
1. SOA принципы живы2. Принцип LSD3. Изоляция данных делает жизнь приятнее4. Парадокс централизации5. Планируй ресурсы динамически
Придерживайтесь принципов
187
LinksЛекция Жени Кривошеева про архитектуру:https://www.youtube.com/watch?v=_Kex5hwGE-w
Пример Smart-библиотеки: https://github.com/lavcraft/grpc-spring-boot-starter
Пример реализации “умной документации”: https://github.com/aatarasoff/documentation-plugin-demo
188