Slide 1

Slide 1 text

non-blocking I/O for the masses High performance for fun and profit.

Slide 2

Slide 2 text

Agenda - Hello! - 101 of non-blocking I/O - Examples from scratch - Putting into practice - Conclusions 2

Slide 3

Slide 3 text

Hello! 3

Slide 4

Slide 4 text

$ whoami 4

Slide 5

Slide 5 text

$ whoami Christian Lück 5

Slide 6

Slide 6 text

$ whoami Christian Lück 6

Slide 7

Slide 7 text

$ whoami Christian Lueck 7

Slide 8

Slide 8 text

$ whoami Christian Lueck 8

Slide 9

Slide 9 text

$ whoami Christian Lueck @clue 9

Slide 10

Slide 10 text

$ whoami Christian Lueck @another_clue 10

Slide 11

Slide 11 text

$ whoami Christian Lueck @another_clue passionate about pushing the limits 11

Slide 12

Slide 12 text

$ whoami Christian Lueck @another_clue passionate about pushing the limits freelance software engineer 12

Slide 13

Slide 13 text

Who are you? 13 now that you know me…

Slide 14

Slide 14 text

Who are you? 14 now that you know me… - programmers / developers? - architects / engineers?

Slide 15

Slide 15 text

What is non-blocking I/O? 15

Slide 16

Slide 16 text

What is I/O? 16

Slide 17

Slide 17 text

input / output 17

Slide 18

Slide 18 text

IPO 18

Slide 19

Slide 19 text

IPO 19 input = read()

Slide 20

Slide 20 text

IPO 20 input = read() result = process(input)

Slide 21

Slide 21 text

IPO 21 input = read() result = process(input) output(result)

Slide 22

Slide 22 text

I/O is everywhere 22

Slide 23

Slide 23 text

I/O is everywhere third party HTTP APIs (RESTful, SOAP, you name it…) 23

Slide 24

Slide 24 text

I/O is everywhere third party HTTP APIs (RESTful, SOAP, you name it…) mysql, postgres 24

Slide 25

Slide 25 text

I/O is everywhere third party HTTP APIs (RESTful, SOAP, you name it…) mysql, postgres filesystem I/O (session files) 25

Slide 26

Slide 26 text

I/O is everywhere third party HTTP APIs (RESTful, SOAP, you name it…) mysql, postgres filesystem I/O (session files) redis, memcache 26

Slide 27

Slide 27 text

I/O is everywhere! 27

Slide 28

Slide 28 text

28 Source: Latency Numbers Every Programmer Should Know: https://gist.github.com/jboner/2841832 CPU vs I/O

Slide 29

Slide 29 text

I/O is slow! 29

Slide 30

Slide 30 text

What is non-blocking I/O? 30

Slide 31

Slide 31 text

the idea 31

Slide 32

Slide 32 text

the idea calculations are fast 32

Slide 33

Slide 33 text

the idea calculations are fast I/O is slow 33

Slide 34

Slide 34 text

the idea calculations are fast I/O is slow why wait? 34

Slide 35

Slide 35 text

Show me some code! Programming language? 35

Slide 36

Slide 36 text

Node.js 36

Slide 37

Slide 37 text

Node.js 37 good fit, huge ecosystem

Slide 38

Slide 38 text

Node.js 38 good fit, huge ecosystem did not invent concept

Slide 39

Slide 39 text

Node.js 39 good fit, huge ecosystem did not invent concept npm install…

Slide 40

Slide 40 text

nodejs? 40

Slide 41

Slide 41 text

no js! 41

Slide 42

Slide 42 text

Everybody’s favorite language… 42

Slide 43

Slide 43 text

PHP 43

Slide 44

Slide 44 text

PHP 44 gets the job done

Slide 45

Slide 45 text

PHP 45 gets the job done widespread usage

Slide 46

Slide 46 text

PHP 46 gets the job done widespread usage if PHP can do it…

Slide 47

Slide 47 text

Examples and demo time 47

Slide 48

Slide 48 text

48

Slide 49

Slide 49 text

Putting into practice 49

Slide 50

Slide 50 text

Knowing concepts is good! 50 Building from scratch is not!

Slide 51

Slide 51 text

Non-blocking I/O can get complex 51

Slide 52

Slide 52 text

Non-blocking I/O can get complex use abstractions! 52

Slide 53

Slide 53 text

53

Slide 54

Slide 54 text

54

Slide 55

Slide 55 text

55 related

Slide 56

Slide 56 text

56 related event-driven

Slide 57

Slide 57 text

57 related event-driven asynchronous

Slide 58

Slide 58 text

58 related event-driven asynchronous multi-threaded

Slide 59

Slide 59 text

core concept 59

Slide 60

Slide 60 text

core concept often intertwined 60

Slide 61

Slide 61 text

61

Slide 62

Slide 62 text

for the masses? 62

Slide 63

Slide 63 text

700 MiB/s 63 dockerd maxed out PHP not

Slide 64

Slide 64 text

5k requests/s 64 this is a local single core benchmark! dual core i3 => 10k requests/s 36M requests/h

Slide 65

Slide 65 text

50k OP/s pure PHP who needs native code anyway? 65

Slide 66

Slide 66 text

non-blocking I/O is massively fast 66

Slide 67

Slide 67 text

for the masses? 67

Slide 68

Slide 68 text

when? 68

Slide 69

Slide 69 text

when? 69 app is I/O bound

Slide 70

Slide 70 text

when? 70 app is I/O bound high(er) performance is wanted

Slide 71

Slide 71 text

when? 71 app is I/O bound high(er) performance is wanted blocking and non-blocking can be separated

Slide 72

Slide 72 text

non-blocking I/O is massively useful 72

Slide 73

Slide 73 text

Conclusions 73

Slide 74

Slide 74 text

nbio 74

Slide 75

Slide 75 text

nbio 75 basic paradigm

Slide 76

Slide 76 text

nbio 76 basic paradigm very fast & versatile

Slide 77

Slide 77 text

nbio 77 basic paradigm very fast & versatile consider when app is I/O bound

Slide 78

Slide 78 text

integration 78

Slide 79

Slide 79 text

integration non-blocking and blocking don’t mix well 79

Slide 80

Slide 80 text

integration non-blocking and blocking don’t mix well decide for either approach 80

Slide 81

Slide 81 text

integration non-blocking and blocking don’t mix well decide for either approach isolate & communicate 81

Slide 82

Slide 82 text

ReactPHP 82

Slide 83

Slide 83 text

ReactPHP 83 a real deal and here to stay

Slide 84

Slide 84 text

ReactPHP 84 a real deal and here to stay stable & production ready

Slide 85

Slide 85 text

ReactPHP 85 a real deal and here to stay stable & production ready *awesome*

Slide 86

Slide 86 text

86

Slide 87

Slide 87 text

87

Slide 88

Slide 88 text

// thank you! $loop->stop(); 88 @another_clue – https://lueck.tv/