Slide 1

Slide 1 text

Microservices @BlaBlaCar

Slide 2

Slide 2 text

Olivier Dolbeau @odolbeau Web Architect About me

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

What’s the v3? ● after the v2 (thanks cap’tain obvious!) ● Full sf2 application ● contains EVERYTHING ○ web ○ admin ○ workers ○ dead code ○ ...

Slide 5

Slide 5 text

18 août 2011 First commit 6 days after: Steve Jobs resigns as the CEO of Apple Inc.

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Thanks v3 ● Pragmatic! ● Everything in the same place ● only one application to deploy ● only one application to explain to newcomers (even if a lot of time is needed to understand everything) It was a good choice at this moment.

Slide 8

Slide 8 text

Figures

Slide 9

Slide 9 text

340 494 NLOC There is “only” 268 041 NLOC for symfony/symfony

Slide 10

Slide 10 text

24 906 Commits There is “only” 15 506 commits for symfony/symfony There is “only” 10 228 commits for joyent/node There is “only” 9 266 commits for twbs/bootstrap There is 44 809 commits for rails/rails (but it’s ruby… #troll)

Slide 11

Slide 11 text

53 Contributors

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

3 537 Tests There is “only” 17 593 tests for symfony/symfony… #ohwait

Slide 14

Slide 14 text

30 minutes to run them all 28 minutes for symfony/symfony… #fake

Slide 15

Slide 15 text

20 minutes to deploy

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Problems of a very huge code base ● Very (VERY) Hard to maintain ● Deployment process (including tests) is too long

Slide 18

Slide 18 text

“With minor change comes major bugs” Myself, based on my personal experience.

Slide 19

Slide 19 text

Let’s do it again! V4? No!

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Microservices The new developer silver bullet! #troll

Slide 22

Slide 22 text

Definition “In computing, microservices is a software architecture design pattern, in which complex applications are composed of small, independent processes communicating with each other using language-agnostic APIs. These services are small, highly decoupled and focus on doing a small task.” You know from where comes this definition

Slide 23

Slide 23 text

How? Workers first. ● mail ● sms ● user-action ● … We now have 60+ workers in… 60+ git repositories.

Slide 24

Slide 24 text

Pros ● easy to: ○ understand ○ write / launch tests ○ deploy ● always the same code base: ○ same command to consume ○ same deployment script ○ … ● We made OSS: swarrot/swarrot

Slide 25

Slide 25 text

Cons ● process: ○ new repo ○ new build plan in bamboo ○ a bit of chef for deployment ● new side projects: ○ to configure our broker (Rabbit) ○ to deal with configuration ● increase ops complexity

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Think global! ● Multi DC. \o/ ● Need to split data across the world. ● Need to shard data.

Slide 29

Slide 29 text

But how to achieve this when you don’t even know how your application works?

Slide 30

Slide 30 text

How to shard users? You gonna hate Doctrine ORM. You gonna hate all your listeners. You gonna hate everyone.

Slide 31

Slide 31 text

Enter the gateway!

Slide 32

Slide 32 text

Goals ● identify & isolate the business logic ● identify & isolate data calls ● without rewriting the whole application ● without impacting the actual delivery ● must be usable everywhere (not only in our main application) Do what we want with our data and our business

Slide 33

Slide 33 text

Implementation Strict separation of concerns ● business ● data One repository for everything ● tried with more => complex for development ● still easily splittable

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Data ● 1 interface. Can have several implementations. ● easy to ○ add cache ○ change backend ○ shard data ● Strict rules: ○ findOne* => return an array or throw exception ○ findBy* => return an Adapter ○ ...

Slide 36

Slide 36 text

● Lots of entry points! (called “action”) ● Request / Response / Handler pattern ● Flat request / response => no objects. \o/ ● can call 0-n times the data layer. Business

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

● concise ● event dispatched into RabbitMQ ● We always have a response object or an exception. No more null everywhere. \o/

Slide 40

Slide 40 text

Pros ● Separation of concern ● The ability to isolate anything! ● strict rules (exceptions & co) ● easy to understand

Slide 41

Slide 41 text

Cons ● versioning ● applications updates ● new side projects (again) ○ to deal with fixtures ● kind of duplicate code

Slide 42

Slide 42 text

Cassandra for messaging User sharding Rating data isolation

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

Facts ● Need to deploy the whole application ● 1 bundle ● 54 controllers ● 36 957 NLOC ● Lot of shared code ● Can break the website

Slide 46

Slide 46 text

Goal ● Several independent applications ● Centralized application to handler permissions / connection ● A bit like SensioConnect for all Sensio products

Slide 47

Slide 47 text

I hope...

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

The silver bullet doesn’t exist! Microservices comes with several drawbacks but it is worth it! We will continue to move forward We need your help! ;)

Slide 50

Slide 50 text

No content