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

Symfony @ BlaBlaCar

Symfony @ BlaBlaCar

Talk given with @odolbeau at the Symfony Con 2015. We present some of the use-cases we encountered with symfony at BlaBlaCar.

Benjamin De Bernardi

December 04, 2015
Tweet

More Decks by Benjamin De Bernardi

Other Decks in Technology

Transcript

  1. @odolbeau
    Web Architect
    Olivier Dolbeau

    View full-size slide

  2. @Genes0r
    Web Developer
    Benjamin De Bernardi

    View full-size slide

  3. Leader ride-sharing service.
    Our goal is to become the 1st travel platform.
    30€ 30€
    30€ 30€

    View full-size slide

  4. Unfortunately, this isn’t our ugliest slide! Sorry.

    View full-size slide

  5. Attract new people

    View full-size slide

  6. Let the journey begins!

    View full-size slide

  7. Started August 18th, 2011

    View full-size slide

  8. From 3 to 75
    contributors

    View full-size slide

  9. Symfony Upgrades
    Started with SF2 2.0
    Upgrade as soon as we can
    Remove deprecated code
    Follow best practices
    2.0 → 2.7

    View full-size slide

  10. Failure is not the end,
    it’s the beginning.

    View full-size slide

  11. Should we wear bermudas?

    View full-size slide

  12. DO!
    Bermudas will rule
    the world!

    View full-size slide

  13. Pimp your kernel.

    View full-size slide

  14. Use case
    Deal with white labeled products
    (and “medias”).

    View full-size slide

  15. Expected
    Deal with ∞ combination of brands / medias.
    Different configuration / views / ...
    Keep (a lot of) small containers.

    View full-size slide

  16. Before
    After
    Branding Media
    Environment
    Debug?

    View full-size slide

  17. Pimp your kernel?

    View full-size slide

  18. ● Not that small containers
    ● You need to add code in app_prod.
    php to choose the right kernel to boot.
    ● You can’t easily use your application
    as a consumer.
    DON’T!

    View full-size slide

  19. It’s not a troll.

    View full-size slide

  20. Queries from
    the view!
    Hard to control
    cache strategy
    No integrity
    check.

    View full-size slide

  21. What else?
    + Quick to bootstrap a new project
    + Quick to code a small project
    - Hard to respect MVC
    - Hard to deal with cache
    - Hard to deal with integrity problems in DB
    - Not made to decouple code (relations).
    - Not made to scale.

    View full-size slide

  22. DO? DON’T?
    Not an easy choice.

    View full-size slide

  23. Event Dispatcher
    a little? a lot? everywhere?

    View full-size slide

  24. ~100 listeners

    View full-size slide

  25. Check eventName
    & event interface
    Dispatch the event
    in the application.
    Decorated EventDispatcher.
    Publish to
    RabbitMQ

    View full-size slide

  26. 129 workers.
    mail
    sms
    publication
    push
    indexation
    image
    resizing
    alerts
    profile
    completion
    We love
    workers!

    View full-size slide

  27. + Perfect to decouple code inside the app.
    + Small listeners, easy to understand, to test.
    + Easy to dispatch events outside application.
    + Scalable!
    - Sometimes, hard to understand what happen.
    - Need tools / rules to keep a common logic.
    - Try to limit entities usage. ;)
    What else?

    View full-size slide

  28. DO!
    But do it carefully!

    View full-size slide

  29. Put everything in
    the same place?

    View full-size slide

  30. It’s called
    V3

    View full-size slide

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

    View full-size slide

  32. 406 187
    NLOC
    There are “only” 268 041 NLOC for symfony/symfony

    View full-size slide

  33. Size doesn’t matter!

    View full-size slide

  34. IT’S TOO BIG
    IT’S TOO BIG
    IT’S TOO BIG

    View full-size slide

  35. ~ 30
    minutes to run all the
    unit/functional tests

    View full-size slide

  36. ~ 30
    minutes to deploy the application

    View full-size slide

  37. What else ?
    ● Long learning curve
    ● Too many side effects
    ● Time consuming
    ● Big maintenance
    ● Spaghetti code

    View full-size slide

  38. DO! Then DON’T!
    You’ll know when
    you’ll need it. :)

    View full-size slide

  39. Put
    business
    logic inside
    Symfony?

    View full-size slide

  40. This is our
    application.
    I want to move
    this logic.

    View full-size slide

  41. Users, ratings, notifications, ridemap...
    MICRO-SERVICES

    View full-size slide

  42. MICRO-SERVICES

    View full-size slide

  43. MICRO-SERVICES

    View full-size slide

  44. The gateway
    ❖ It’s code
    ❖ It uses DDD
    ❖ Everyone love it
    ❖ It’s very well organized
    ❖ There’s a lot of (very) strict rules
    ❖ It separates business logic & data access
    ❖ It’s a vendor ! Easy to use everywhere

    View full-size slide

  45. How to: Get a rating

    View full-size slide

  46. A Web Service Like Conversation
    Request message
    Response message
    Client
    Server

    View full-size slide

  47. Data
    ● Cache ready
    ● Backend agnostic

    View full-size slide

  48. Data
    ● Cache ready
    ● Backend agnostic
    Encapsulation !

    View full-size slide

  49. Data
    RedisStorage is able to contain a
    DBALStorage
    Encapsulation !

    View full-size slide

  50. Data
    RedisStorage
    DBALRatingStorage
    Fallback on DBALRatingStorage

    View full-size slide

  51. The gateway
    ❖ Flexible
    ❖ Easy to test
    ❖ Deployed when needed
    ❖ Used for all new projects

    View full-size slide

  52. V3
    Previous ecosystem

    View full-size slide

  53. Gateway
    V3
    W
    W
    W
    W
    W
    C W
    C
    C
    C
    W
    Current ecosystem
    W
    ● 90 workers
    ● 40 commands

    View full-size slide

  54. V3
    W
    W
    W
    W
    W
    C
    W
    C
    C
    C
    W
    Future ecosystem?
    W
    Gateway
    Gateway
    Gateway

    View full-size slide

  55. V3
    W
    W
    W
    W
    W
    C
    W
    C
    C
    C
    W
    Future ecosystem?
    W
    B
    B
    B B
    B
    B
    D
    D
    D

    View full-size slide

  56. Put
    business
    logic inside
    Symfony?

    View full-size slide

  57. I’ve found a
    use case!

    View full-size slide

  58. NO YOU DON’T!

    View full-size slide

  59. DO! DON’T!
    + Use feature flags /
    on the fly toggling.
    + Make code reviews.
    + Keep a clean codebase.
    + Use encapsulation! <3
    + Be generic
    + Promote reusability
    - Onboard people too
    quickly.
    - Depend too much on
    the framework
    - Let your container get
    too big.
    - Try not to extend the
    framework.

    View full-size slide

  60. Symfony2 was a good
    choice.
    Even if we made lot of
    wrong choices.
    We’ll decouple!

    View full-size slide

  61. Keep growing!
    Simpler with several small applications?

    View full-size slide

  62. ● Fail, learn, succeed!
    ● Microservices FTW!
    ● Be worldwide!
    ● Bermudas are great tools to build performant websites
    Benjamin De
    Bernardi
    @Genes0r
    Olivier Dolbeau
    @odolbeau
    We’re hiring!
    In Paris & Warsaw!
    http://blbl.cr/dreamjobs

    View full-size slide