Slide 1

Slide 1 text

Moving People with Clojure EuroClojure 2017 / Berlin Kartik Gupta & Abhinav Sarkar

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

• Indonesian transport, logistics and payments startup • First billion dollar startup in Indonesia • Operating in more than 25 cities with more than 300.000 motorbike and car drivers • More than 25 products, using the same fleet • Processing more than 1000 orders per second

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Prologue

Slide 6

Slide 6 text

Prologue Jan 2015 App launched 800 drivers New verticals 30.000 drivers Java monolith Go service Aug 2015

Slide 7

Slide 7 text

Prologue Feb 2016 Business grew 200.000 drivers Rewrite starts Go service Clojure service Aug 2016 Rewrite ends Oct 2016 Rewrite in prod Nov 2016

Slide 8

Slide 8 text

The Rewrite

Slide 9

Slide 9 text

Architecture Customers Order Management Systems Allocation Service Drivers Call Callback

Slide 10

Slide 10 text

Why Rewrite? • Go is imperative and mutation heavy • Domain heavy code is hard to reason about • Moving fast is more important than high performance • Immutability, laziness and dynamic typing in Clojure • leads to simpler domain specific code

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Testing the Rewrite • Two weeks in testing • Duplicating live traffic • Feature toggles • Mock downstream services • Match data and external effects

Slide 14

Slide 14 text

Duplicate Traffic Live Traffic Shared Services Actual Services Mock Services Toggled-off Services Go Allocation Service Clojure Allocation Service OMSes

Slide 15

Slide 15 text

Releasing the Rewrite • AOT compiled uberjar • saves startup time • Monitoring: application and business metrics, errors • Incremental rollout over two weeks

Slide 16

Slide 16 text

1% Live Traffic 99% Live Traffic Go Allocation Service Clojure Allocation Service OMSes

Slide 17

Slide 17 text

Lessons Learned

Slide 18

Slide 18 text

Generative Testing • At all levels (unit, functional and integration) • Using test.check library • Handwritten generators

Slide 19

Slide 19 text

Generative Testing

Slide 20

Slide 20 text

Generative Testing

Slide 21

Slide 21 text

prismatic/schema

Slide 22

Slide 22 text

swagger

Slide 23

Slide 23 text

• The protected function call is wrapped in a circuit breaker object, which monitors for failures. • Once the failures reach a certain threshold, the circuit breaker trips. • Once tripped all further calls to the circuit breaker return with an error, without the protected call being made at all. Circuit Breaker

Slide 24

Slide 24 text

Netflix Hystrix

Slide 25

Slide 25 text

Hystrix Dashboard

Slide 26

Slide 26 text

etcd service nodes Config change request Config change callbacks load balancer etcd Config change call

Slide 27

Slide 27 text

tolitius/mount

Slide 28

Slide 28 text

tolitius/mount

Slide 29

Slide 29 text

Either Monad

Slide 30

Slide 30 text

Either Monad

Slide 31

Slide 31 text

Epilogue

Slide 32

Slide 32 text

Epilogue • Around 1 new release per week • Experimentation • Clojure Sessions • More services in Clojure

Slide 33

Slide 33 text

Thank You Abhinav Sarkar @abhin4v nilenso.com @nilenso Kartik Gupta @kartik7153 gojekengineering.com @gojektech