$30 off During Our Annual Pro Sale. View Details »

Symfony @ BlaBlaCar

Symfony @ BlaBlaCar

Talk given with Benjamin De Bernardi aka Junior (@Genes0r) during SymfonyCon Paris 2015

Olivier Dolbeau

December 04, 2015
Tweet

More Decks by Olivier Dolbeau

Other Decks in Programming

Transcript

  1. View Slide

  2. @odolbeau
    Web Architect
    Olivier Dolbeau

    View Slide

  3. @Genes0r
    Web Developer
    Benjamin De Bernardi

    View Slide

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

    View Slide

  5. View Slide

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

    View Slide

  7. View Slide

  8. View Slide

  9. View Slide

  10. View Slide

  11. View Slide

  12. Attract new people

    View Slide

  13. Let the journey begins!

    View Slide

  14. Started August 18th, 2011

    View Slide

  15. From 3 to 75
    contributors

    View Slide

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

    View Slide

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

    View Slide

  18. DO!
    DON’T!

    View Slide

  19. Should we wear bermudas?

    View Slide

  20. View Slide

  21. DO!
    Bermudas will rule
    the world!

    View Slide

  22. DO!
    DON’T!

    View Slide

  23. Pimp your kernel.

    View Slide

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

    View Slide

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

    View Slide

  26. Before
    After
    Branding Media
    Environment
    Debug?

    View Slide

  27. Pimp your kernel?

    View Slide

  28. DON’T!

    View Slide

  29. ● 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 Slide

  30. DO!
    DON’T!

    View Slide

  31. It’s not a troll.

    View Slide

  32. Code fast!

    View Slide

  33. Code well?

    View Slide

  34. View Slide

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

    View Slide

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

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

    View Slide

  38. DO!
    DON’T!

    View Slide

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

    View Slide

  40. ~100 listeners

    View Slide

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

    View Slide

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

    View Slide

  43. + 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 Slide

  44. DO!
    But do it carefully!

    View Slide

  45. DO!
    DON’T!

    View Slide

  46. Put everything in
    the same place?

    View Slide

  47. It’s called
    V3

    View Slide

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

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

    View Slide

  50. Size doesn’t matter!

    View Slide

  51. IT’S TOO BIG
    IT’S TOO BIG
    IT’S TOO BIG

    View Slide

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

    View Slide

  53. ~ 30
    minutes to deploy the application

    View Slide

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

    View Slide

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

    View Slide

  56. DO!
    DON’T!

    View Slide

  57. Put
    business
    logic inside
    Symfony?

    View Slide

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

    View Slide

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

    View Slide

  60. MICRO-SERVICES

    View Slide

  61. MICRO-SERVICES

    View Slide

  62. The gateway

    View Slide

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

  64. How to: Get a rating

    View Slide

  65. Business

    View Slide

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

    View Slide

  67. Data

    View Slide

  68. Data
    ● Cache ready
    ● Backend agnostic

    View Slide

  69. Data
    ● Cache ready
    ● Backend agnostic
    Encapsulation !

    View Slide

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

    View Slide

  71. Data
    RedisStorage
    DBALRatingStorage
    Fallback on DBALRatingStorage

    View Slide

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

    View Slide

  73. V3
    Previous ecosystem

    View Slide

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

    View Slide

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

    View Slide

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

  77. Put
    business
    logic inside
    Symfony?

    View Slide

  78. DON’T!

    View Slide

  79. I’ve found a
    use case!

    View Slide

  80. NO YOU DON’T!

    View Slide

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

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

    View Slide

  83. Keep growing!
    Simpler with several small applications?

    View Slide

  84. ● 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 Slide