Slide 1

Slide 1 text

Building an IoT platform with Go and Python David Majda @dmajda Golang Prague #3 · Prague · 13 September, 2018

Slide 2

Slide 2 text

Outline What do we do? Data pipeline Python vs. Go What did we learn?

Slide 3

Slide 3 text

What do we do?

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Data pipeline

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

Typical Go service Service Data Data Config

Slide 12

Slide 12 text

Python vs. Go

Slide 13

Slide 13 text

Comparison Language Ecosystem Performance Concurrency Deployment

Slide 14

Slide 14 text

Language

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Simple

Slide 17

Slide 17 text

Simple Easy to learn

Slide 18

Slide 18 text

Simple Easy to learn Fast development

Slide 19

Slide 19 text

Simple Easy to learn Fast development Reliable

Slide 20

Slide 20 text

Simple Easy to learn Fast development Reliable No complaints

Slide 21

Slide 21 text

Simple Easy to learn Fast development Reliable No complaints Simple

Slide 22

Slide 22 text

Simple Easy to learn Fast development Reliable No complaints Simple Easy to learn

Slide 23

Slide 23 text

Simple Easy to learn Fast development Reliable No complaints Simple Easy to learn Fast development

Slide 24

Slide 24 text

Simple Easy to learn Fast development Reliable No complaints Simple Easy to learn Fast development Reliable

Slide 25

Slide 25 text

Simple Easy to learn Fast development Reliable No complaints Simple Easy to learn Fast development Reliable Tons of complaints

Slide 26

Slide 26 text

Complaints

Slide 27

Slide 27 text

Complaints Too simple

Slide 28

Slide 28 text

Complaints Too simple Unnecessarily different

Slide 29

Slide 29 text

Complaints Too simple Unnecessarily different Inflexible

Slide 30

Slide 30 text

Complaints Too simple Unnecessarily different Inflexible Likes to be left alone

Slide 31

Slide 31 text

Complaints Too simple Unnecessarily different Inflexible Likes to be left alone Many other small issues

Slide 32

Slide 32 text

{ "type": "gateway", "sn": "3FCF54AADCB6E7DC" } { "type": "sensor", "gateway_sn": "3FCF54AADCB6E7DC", "channel": 5 }

Slide 33

Slide 33 text

type Device struct { Type string `json:"type"` SN *string `json:"sn,omitempty"` // pointer! GatewaySN *string `json:"gateway_sn,omitempty"` // pointer! Channel *uint `json:"channel,omitempty"` // pointer! } input := `{"type": "Gateway", "sn": "3FCF54AADCB6E7DC"}` device := Device{} json.Unmarshal([]byte(input), &device) fmt.Println(device) // {Gateway 0x1050c160 } output, _ := json.Marshal(device) fmt.Printf("%s\n", output) // {"type":"Gateway","sn":"3FCF54AADCB6E7DC"}

Slide 34

Slide 34 text

@JsonTypeInfo( use = JsonTypeInfo.Id.NAME, include = As.PROPERTY, property = "type" ) @JsonSubTypes({ @JsonSubTypes.Type(value = Gateway.class, name = "gateway"), @JsonSubTypes.Type(value = Sensor.class, name = "sensor") }) public class Device { } @JsonTypeName("gateway") public class Gateway extends Device { public String sn; } @JsonTypeName("sensor") public class Sensor extends Device { public String gatewaySN; public int channel; }

Slide 35

Slide 35 text

{ "type": "gateway", "gateway": { "sn": "3FCF54AADCB6E7DC" } } { "type": "sensor", "sensor": { "gateway_sn": "3FCF54AADCB6E7DC", "channel": 5 } }

Slide 36

Slide 36 text

Ecosystem

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

Excellent Except asyncio (later)

Slide 39

Slide 39 text

Excellent Except asyncio (later) Excellent

Slide 40

Slide 40 text

Performance

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

Good :-)

Slide 43

Slide 43 text

Good :-) Better :-)

Slide 44

Slide 44 text

Concurrency

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

Threads 90’s technology

Slide 47

Slide 47 text

Threads 90’s technology asyncio Parallel world Poor usability Bad libraries

Slide 48

Slide 48 text

Threads 90’s technology asyncio Parallel world Poor usability Bad libraries Goroutines & channels Model the real world really nicely

Slide 49

Slide 49 text

Deployment

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

Python 2/3

Slide 52

Slide 52 text

Python 2/3 Virtualenvs

Slide 53

Slide 53 text

Python 2/3 Virtualenvs Packaging

Slide 54

Slide 54 text

Python 2/3 Virtualenvs Packaging Tons of files

Slide 55

Slide 55 text

Python 2/3 Virtualenvs Packaging Tons of files Single binary

Slide 56

Slide 56 text

All invalidated by…

Slide 57

Slide 57 text

What did we learn?

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

Simple services One well-defined task Performance needed Concurrency useful

Slide 60

Slide 60 text

Apps Simple services One well-defined task Performance needed Concurrency useful

Slide 61

Slide 61 text

Apps Complex services Simple services One well-defined task Performance needed Concurrency useful

Slide 62

Slide 62 text

Apps Complex services Scripts Simple services One well-defined task Performance needed Concurrency useful

Slide 63

Slide 63 text

Apps Complex services Scripts Prototyping Simple services One well-defined task Performance needed Concurrency useful

Slide 64

Slide 64 text

What would we do differently?

Slide 65

Slide 65 text

Not much

Slide 66

Slide 66 text

The End David Majda @dmajda Interested in working with us? Let’s talk!