i will be showing clojure code, however this is all the ...€¦ · clojure syntax primer (1)...

48
CLOJURE SYNTAX PRIMER (1) Function denition (2) Function call 1 (defn- function-name [arg1 arg2 … argn] ;; function call(s) ) (function-name arg1 arg2 … argn) I will be showing Clojure code, however this is all the syntax you need to understand to be able to read it. p.s No monads :-)

Upload: others

Post on 17-Aug-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

CLOJURE SYNTAX PRIMER

(1) Function definition (defn function-name [arg1 arg2 … argn] ;; body )

(2) Function call (function-name arg1 arg2 … argn)

1

(defn- function-name [arg1 arg2 … argn] ;; function call(s) )

(function-name arg1 arg2 … argn)

I will be showing Clojure code, however this is all the syntax you need to understand to be able to read it. p.s No monads :-)

Page 2: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

MICROSERVICESmacromonitoring for

Andy Marks @andee_marks

[email protected]

Page 3: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

CHAPTER 8 - MONITORING

Monitoring for monolithic architectures Monitoring for microservice architectures Thanks to Sam’s book Introducing the sample app

3

Page 4: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

why should I care?

4

Page 5: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

(WEB) ARCHITECTURE: PRE 2013

5

Web Server

App Server

DB

Legacy App

Page 6: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

MONITORING

6

Page 7: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

MONITORING @ SCALE

7

Page 8: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

MULTIPLEXING FTW!

8

Page 9: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

MATURE TOOLS

9

Page 10: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

compared with…

10

Page 11: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

(WEB) ARCHITECTURE: PRE 2013

11

Web Server

DB

Legacy App

uSvc uSvc uSvc

uSvc uSvc uSvc

uSvc uSvc uSvc

App Server

Page 12: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

(WEB) ARCHITECTURE: 2013-

12

DB

Legacy App

uSvc uSvc uSvc

uSvc uSvc uSvc

uSvc uSvc uSvc

Page 13: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

MONITORING MICROSERVICES

13

Complex Architecture

Collaborating Components

Nuanced Failure Modes

Page 14: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

Correlation IDs

Synthetic Transactions

Proactive monitoring

14

Page 15: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

let’s get practical!

15

Page 16: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

OUR SAMPLE APP

16

Page 17: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

1. NORMALISE INPUT

macromonitoring4microservices

17

"Macromonitoring 4 Microservices"

Page 18: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

2. SPLIT INTO ROWS

macrom onitor ing4mi croser vices

18

macromonitoring4microservices

Length = 29 chars 52 = 25 62 = 36

Page 19: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

m a c r o m o n i t o r i n g 4 m i c r o s e r v i c e s

1 2 3 4 5 6

3. READ DOWN THE COLUMNS

macrom onitor ing4mi croser vices

Page 20: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

4. CONSTRUCT THE CIPHERTEXT

moicvannricigocrt4seoomesmrir

m a c r o m o n i t o r i n g 4 m i c r o s e r v i c e s

1 2 3 4 5 6

Page 21: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

to the code!

21

Page 22: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

SERVICES

22

1. Get input 2. Normalise plaintext 3. Split into rows 4. Read down the columns 5. Construct ciphertext 6. Display ciphertext

Front-End (4000)

Back-End (3000)

Normaliser (3002)

Square sizer (3001)

Column handler (3003)

1 6

2

3

4

5

Page 23: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

BEWARE OF OVERKILL!

23

Square sizer (3001)

3

Page 24: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

CORRELATION IDS

Page 25: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

CORRELATION IDS

GUID for all calls pertaining to a single user transaction Generated by first service in call chain Propagated through all downstream calls Challenges: asynchronous services

25

Page 26: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

CORRELATION IDS

26

Front-End (4000)

Back-End (3000)

Normaliser (3002)

Square sizer (3001)

Column handler (3003)

Generate Propogate

Page 27: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

ID GENERATION

27

Front-End (4000)

“crypto-square-6092d335-57f7-4220-afc7-2f677f9390e6”

Constant

Unique across user transactions

Page 28: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

ID PROPOGATION

28

Front-End (4000)

Back-End (3000)

x-correlation-id: crypto-square-6092…90e6

Page 29: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

now what?

29

Page 30: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

RIEMANN.IO

30

Page 31: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

RIEMANN EVENTS

31

(defrecord Event [ service state description metric tags time ttl

“reg1.foo.bar” “reg-service http” “ok” “apache-log” 201 [“reg1” “http”] 104534892 60

Page 32: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

CORRELATION IDS

32

Front-End

(4000)

Back-End

(3000)

Normaliser

Square sizer

Column handler (3003)

Riemann

Page 33: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

GENERATING EVENTS

33

Page 34: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

DEMO!

Correlation IDs allow us to: (1) spot which services participate (ok/fail/warning in which transactions (2) gather relative metrics across transactions

34

Page 35: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

corr-id mapping

CHALLENGES

35

Foo Barcorr-id Synchronous

Foo Barcorr-id

corr-id

Asynchronous

Page 36: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

SYNTHETIC TRANSACTIONS

Page 37: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

SYNTHETIC TRANSACTIONS

Fake transactions injected into production system Sole intention of checking “is the system working?” Reuse functional tests as clients Challenges: excluding from metrics

37

Page 38: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

FUNCTIONAL TESTS

38

Page 39: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

RUN THE TESTS

39

Page 40: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

DEMO!

Synthetic Transactions allow us to: Get confidence that key user transactions are working in production

40

Page 41: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

CHALLENGES

41

Are these all real sales?

Page 42: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

PROACTIVE MONITORING

Page 43: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

PROACTIVE MONITORING - CIRCUIT BREAKERS

(1) Closed: execute (2) Open/Tripped: use fallback (if available) (3) Half-Open: try 1 request Monitors circuit health (error % > threshold %) Help build antifragility

43Source: https://github.com/Netflix/Hystrix/wiki/How-it-Works#CircuitBreaker

Page 44: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

HYSTRIX BY NETFLIX

44

Page 45: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

in conclusion

45

Page 46: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

MONITORING MICROSERVICES

46

Complex Architecture

Collaborating Components

Nuanced Failure Modes

• Correlation IDs

• Synthetic Transactions

• Proactive Monitoring

Page 47: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

FINAL THOUGHTS

▫︎Monitoring microservices environments can be tricky

▫︎ Invest in operational capabilities in line with microservices development

▫︎ Reuse OSS from organisations doing this stuff well (e.g., Netflix)

▫︎ Passive/reactive monitoring is necessary, but “failure demand” (aka waste)

47

Page 48: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function

THANKS

Andy Marks @andee_marks

[email protected]