evolutionary architectures and fitness functions: a pragmatic ......(asp.net webapi) http/rest...

38
Evolutionary architectures and fitness functions: A pragmatic approach Software Architecture #OReillySACon Rene Weiss Berlin, 2019

Upload: others

Post on 10-Aug-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Evolutionary architectures and fitness functions: A pragmatic approach

Software Architecture

#OReillySACon

Rene Weiss Berlin, 2019

Page 2: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

AgendaEvolution!What are Fitness Functions?Examples! (#Code)How to start?

Page 3: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Rene [email protected]

xing.to/rweiss

@renebiancoSoftware Architect, Consultant, Trainer @ embarc

Focus areasq Software architecture (review, design, …)q iSAQB trainer for agile software architecture

(AGILA)q Agile methodologiesq (.NET technologies)

Page 4: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not
Page 5: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Founded 2013 in Hamburg

Page 6: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Since 2015 also in Vienna

Page 7: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

IntroductionEvolutionary architectures

Fitness Functions

Page 8: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Nature has solutions for complex problems…

Evolutionary approaches….

… by using small, but steady adaptions

Page 9: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

“Software architecture is about the important stuff, whatever that is.”

(Martin Fowler)

… what about architecture

Page 10: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Evolutionary architecture

Evolutionary architecture supports small, incremental changes spanning multiple dimensions of the software architecture.

q small changesq broad involvement with a lot of participantsq geared toward common goals

à Fitness Functions!

Page 11: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Fitness Functions!DefinitionCategorization (why categorize?)Tool overview

Page 12: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Fitness FunctionsBorrowed from evolutionary computing, a fitnessfunction is an objective function, used to summarize how close a given design solution is to achieving the set aims.

q On the search for improvements, the Fitness Function defines what is „better“.

q Equally „good“, but simpler approaches are superiour

Neal Ford, Rebecca Parsons, Patrick Kua

Page 13: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

First Fitness Functions examplesProblem – Maintainability (Testability)� Is our test coverage sufficient?

Target audience:� Developers

Implementation idea:� Periodic review of test

coverage

Fitness Function(s):

§ Test coverage (Unit) > 0.9

§ Test coverage (Integration) > 0.6Timing:

� Each CI build� Each nightly integration test build

Page 14: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

First Fitness Functions examplesProblem – Reliability (Availability, Resilience)� Is our service up and running if latency increases?

Fitness Function(s):

§ Integration test errors = 0% (set network latency for 3rd party connections = 5s)

Target audience:� Developers, Operations

Implementation idea:� Periodic tests of our

service with increased latency

Timing:� Each nightly integration test build

Page 15: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

CategorizationExecution type§ Triggered § Continuous

Breadth of feedback§ Atomic § Holistic

Execution location§ CI/CD § Test environment§ Production

Quality attribute§ Maintainability§ Reliability§ Performance§ …

Monitoring type§ 0/1§ Value/Threshold§ Trend

Test applicability§ Temporary§ Permanent

Page 16: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Software quality attributes (-ilities)

Functional Suitability

Performance Compatibility Usability

Realiability Security Maintainability Portability

(ISO 25010)

Page 17: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Static code analysis (coupling, cyclomatic complexity, ..)

Functional tests + test coverage…

Autonomous runtime tests Immediate quality inspection

“Chaos Engineering”…

Consumer Driven ContractsExploratory testingPerformance testsQualitative analysis

LoggingMonitoring (transactions, queue

length, ressource usage …)...

Fitness Function Quadrantatomic

holistic

continuoustriggered

Page 18: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Fitness Function Quadrant - Toolingatomic

holistic

triggered continuous

Page 19: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Examples!A / B code testingMini-Chaos Engineering

< / >

Page 20: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not
Page 21: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Scientist (A / B Testing)Main Component Calculation Lib

Problems- Legacy (code not maintainable, „no“ test

cases)- Developers not available anymore- Errors are raised by various data constellations- Very hard to test – extremly large number of real world

test cases

Business-logic

Page 22: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Scientist (A / B Testing)

Solution idea

- Develop new library- Run experiments with new library in production- Continuous improvement through real world use cases

Fitness Function(s):

- Library V2 Result == Library V1 Result- Average: Lib. V2 Performance (processing time) -30% (vs. V1) - Worst Case (Single Result): Lib. V2 Performance (processing time) +10% (vs. V1)

Page 23: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Scientist (A / B Testing)

Main Component Calculation Lib. V1

Calculation Lib. V2

Scientist Experiment

Business-logic

Page 24: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Scientist Demo!

Page 25: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Scientist (A / B Testing)

Execution type: Continuous

Quality attribute: Funct. Suitability Performance

Monitoring type: 0/1Trend

Breadth of feedback: Atomic

Timing + Location: Production

Test applicability: Temporary

Fitness Function(s):

- Lib. V2 Result == Lib. V1 Result- Average: Lib. V2 Performance (processing time) -30% (vs. V1) - Worst Case (Single Result): Lib. V2 Performance (processing time) +10% (vs. V1)

Page 26: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not
Page 27: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Mini-Chaos Engineering

OpenWeather-Map

Client

Server(ASP.NET WebAPI)

HTTP/REST

HTTP/REST

WeatherApp

Problems- Dependency on 3rd party service- Resilience measures not testable

Page 28: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Mini-Chaos EngineeringSolution idea

- Circuit Breaker using Polly.NET- „Chaos“ (HTTP errors, latency, …) using Simmy- Tests running in integration test environment

Fitness Function(s):

- Integration-Test Error = 0% (network latency for 3rd party service = 5s)

Page 29: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Mini-Chaos Engineering

OpenWeather-Map

Client

Server(ASP.NET WebAPI)

HTTP/REST

HTTP/REST

WeatherApp

“CircuitBreaker” & fallback logic

Test for failure:

Page 30: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Chaos Demo!

Page 31: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Mini-Chaos Engineering

Execution type: Triggered(Continuous)

Quality attribute: Reliability

Monitoring type: 0/1

Breadth of feedback: Holistic

Timing + Location: Test env.(Production)

Test applicability: Permanent

Fitness Function(s):

- Integration-Test Error = 0% (network latency for 3rd party service = 5s)

Page 32: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

How to start?

Page 33: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Initially

5. Automate testing and evaluation

1. Identify central quality goals (use ISO 25010)

2. Develop quality scenarios

3. Select top priority for evaluation / testing

4. Develop + formulate Fitness Functions

6. Visualize results

Continuouslye.g. every sprint

Add new, change or decommission unnecessary Fitness Functions(4., 5., 6.).

Step

Add quality goals à risk driven approach (1.)

Add scenarios(2., 3.)

Page 34: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Summaryq Evolutionary architectures: Small incremental architectural

changesq Direction of change guidance by Fitness Functionsq Fitness Functions can help in environments not using evolutionary

architecture approach

q Fitness Function categorization helps to generate ideas in solutionspace

ÞA lot of possibilities to test architecture!q Examples:

q A / B Testing on code level (libraries, …) incl. performance testing (Scientist.net)q Mini-Chaos engineering (Circuit-Breaker: Polly, Chaos-Testing Tool: Simmy)

Page 35: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Don’t automate (architecture) tests because you can…

… but because it makesmost sense in yourbusiness environment!

Page 36: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Rate today’s session

Session page on conference website O’Reilly Events App

Page 37: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Thank you very much!

Slide download: https://embarc.de/blogDemo source code: https://git.io/JegFX

[email protected]

xing.to/rweiss

www.embarc.de

@renebiancoAny Questions?

Page 38: Evolutionary architectures and fitness functions: A pragmatic ......(ASP.NET WebAPI) HTTP/REST HTTP/REST WeatherApp Problems-Dependency on 3rd party service-Resilience measures not

Ressources

q Sample source codehttps://git.io/JegFX

q Pollyhttps://github.com/App-vNext/Polly

q Simmyhttps://github.com/Polly-Contrib/Simmy

q Scientist.nethttps://github.com/scientistproject/Scientist.net

q Scientist Case Study (GitHub)https://github.blog/2015-12-15-move-fast/

q Building Evolutionary Architectures. Support Constant Change N. Ford, R. Parsons, P. Kua, Patrick | O'Reilly 2017

q Software Architecture in PracticeChapter 4 (Understanding Quality Attributes, Quality Scenarios)Len Bass, Rick Kazman, Paul Clements | SEI Series in Software Engineering 2012

q Thoughtworks / Fitness Functionhttps://www.thoughtworks.com/search?q=fitness+functions&c=sitewide