Slide 1

Slide 1 text

High Performance Architecture Patterns Celso Crivelaro @celsocrivelaro

Slide 2

Slide 2 text

$ whoami > Celso Crivelaro - Engineer and MSc in Computer Engineering - Dev Ruby / Python / Java @celsocrivelaro http://crivelaro.me

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

SMTP Locaweb - Transaction email platform - Fast and high quality email sending - Live reports - Integration by SMTP Protocol and HTTP API - 2,5 Millions of messages per day - + 2 years

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Platforms

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

High Availability

Slide 13

Slide 13 text

Resource Consumption

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Disk Memory Band- width Processor time Logs GC Open Connections Deadlocks Stop all disk activities Swap Slowness Services stop responding Queues Amount Workers Slowness

Slide 16

Slide 16 text

Integrations

Slide 17

Slide 17 text

Integrations always fails!

Slide 18

Slide 18 text

Integration Fails always Internal External DB API Storage Network API ISP Hop Cloud

Slide 19

Slide 19 text

Map hidden integrations E.g. DNS

Slide 20

Slide 20 text

Fail Fast

Slide 21

Slide 21 text

Failing Fast reduces transient errors

Slide 22

Slide 22 text

Timeouts

Slide 23

Slide 23 text

Never trust in default timeouts

Slide 24

Slide 24 text

Threads Timeouts to get rid of deadlocls Internal Little timeout External Depends: The least possible

Slide 25

Slide 25 text

Retry

Slide 26

Slide 26 text

1 2 3 5 8 n Fibonacci Proportion ...

Slide 27

Slide 27 text

Isolate Critical Components

Slide 28

Slide 28 text

Panel / API Painel Web Internal API - HTTP Resources Connection Pool App Server Business Rules Integrations

Slide 29

Slide 29 text

App Internal API App Panel Painel Web API - HTTP Resources Conn. Pool App Server Business Rules Integrations Resources Conn. Pool App Server Business Rules Integrations

Slide 30

Slide 30 text

Less Components == Less Problems

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Redundancy

Slide 33

Slide 33 text

Health Check

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

Scalability

Slide 37

Slide 37 text

CAP Theorem

Slide 38

Slide 38 text

Availability Consistency Tolerance to network partition

Slide 39

Slide 39 text

Availability Consistency Partition Tolerance to network partition whether system is available or not

Slide 40

Slide 40 text

Availability Consistency Tolerance to network partition Same data in all nodes

Slide 41

Slide 41 text

Availability Consistency Tolerance to network partition Tolerante when a network fails

Slide 42

Slide 42 text

Availability Consistency Partition Tolerance Postgres

Slide 43

Slide 43 text

Availability Consistency Partition Tolerance DNS

Slide 44

Slide 44 text

Availability Consistency Partition Tolerance Protocols

Slide 45

Slide 45 text

Evaluate which one is acceptable to your platform

Slide 46

Slide 46 text

Pool of Resources

Slide 47

Slide 47 text

App Connection Resource Connection Connection Connection Connection

Slide 48

Slide 48 text

Controlled Timeouts Controlled Resource Consumption Avoid opening/closing connections overhead

Slide 49

Slide 49 text

Cache

Slide 50

Slide 50 text

Make your data closer to your app

Slide 51

Slide 51 text

When use cache App API DB

Slide 52

Slide 52 text

Default Cache Strategy App Cache Source 1 2 3

Slide 53

Slide 53 text

Hot Cache Strategy App Cache Source 2 1

Slide 54

Slide 54 text

Load Balacing

Slide 55

Slide 55 text

LB App App App App

Slide 56

Slide 56 text

Load Balance Strategy matters!

Slide 57

Slide 57 text

Decoupled Architecture

Slide 58

Slide 58 text

Slow Processing Fast processing Asynchronous Processing Authentication Message Transformation MTA Providers User Message Persistence Consolidation

Slide 59

Slide 59 text

Background jobs Messaging frameworks

Slide 60

Slide 60 text

How to discover bottlenecks?

Slide 61

Slide 61 text

Test your limits... Load Test Stress Test Peak Test

Slide 62

Slide 62 text

Telemetry

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

Grafana + InfluxDB

Slide 65

Slide 65 text

Other scalabity patterns

Slide 66

Slide 66 text

Indexes

Slide 67

Slide 67 text

Sharding

Slide 68

Slide 68 text

References

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

http://use-the-index-luke.com

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

Thank you! Celso Crivelaro @celsocrivelaro [email protected]