Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Microservices @BlaBlaCar

Microservices @BlaBlaCar

A presentation about microservices at BlaBlaCar.

Talk given at sfPot March 2015 at SensioLabs

Olivier Dolbeau

March 17, 2015
Tweet

More Decks by Olivier Dolbeau

Other Decks in Programming

Transcript

  1. Microservices
    @BlaBlaCar

    View Slide

  2. Olivier Dolbeau
    @odolbeau
    Web Architect
    About me

    View Slide

  3. View Slide

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

    View Slide

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

    View Slide

  6. View Slide

  7. 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.

    View Slide

  8. Figures

    View Slide

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

    View Slide

  10. 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)

    View Slide

  11. 53
    Contributors

    View Slide

  12. View Slide

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

    View Slide

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

    View Slide

  15. 20
    minutes to deploy

    View Slide

  16. View Slide

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

    View Slide

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

    View Slide

  19. Let’s do it again!
    V4? No!

    View Slide

  20. View Slide

  21. Microservices
    The new developer silver bullet!
    #troll

    View Slide

  22. 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

    View Slide

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

    View Slide

  24. 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

    View Slide

  25. 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

    View Slide

  26. View Slide

  27. View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  31. Enter the
    gateway!

    View Slide

  32. 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

    View Slide

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

    View Slide

  34. View Slide

  35. 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
    ○ ...

    View Slide

  36. ● 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

    View Slide

  37. View Slide

  38. View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  42. Cassandra for messaging
    User sharding
    Rating data isolation

    View Slide

  43. View Slide

  44. View Slide

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

    View Slide

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

    View Slide

  47. I hope...

    View Slide

  48. View Slide

  49. 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! ;)

    View Slide

  50. View Slide