Symfony @ BlaBlaCar

Symfony @ BlaBlaCar

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

418997665c4a3368515ecf9c3d746b95?s=128

Olivier Dolbeau

December 04, 2015
Tweet

Transcript

  1. None
  2. @odolbeau Web Architect Olivier Dolbeau

  3. @Genes0r Web Developer Benjamin De Bernardi

  4. Leader ride-sharing service. Our goal is to become the 1st

    travel platform. 30€ 30€ 30€ 30€
  5. None
  6. Unfortunately, this isn’t our ugliest slide! Sorry.

  7. None
  8. None
  9. None
  10. None
  11. None
  12. Attract new people

  13. Let the journey begins!

  14. Started August 18th, 2011

  15. From 3 to 75 contributors

  16. Symfony Upgrades Started with SF2 2.0 Upgrade as soon as

    we can Remove deprecated code Follow best practices 2.0 → 2.7
  17. Failure is not the end, it’s the beginning.

  18. DO! DON’T!

  19. Should we wear bermudas?

  20. None
  21. DO! Bermudas will rule the world!

  22. DO! DON’T!

  23. Pimp your kernel.

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

  25. Expected Deal with ∞ combination of brands / medias. Different

    configuration / views / ... Keep (a lot of) small containers.
  26. Before After Branding Media Environment Debug?

  27. Pimp your kernel?

  28. DON’T!

  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!
  30. DO! DON’T!

  31. It’s not a troll.

  32. Code fast!

  33. Code well?

  34. None
  35. Queries from the view! Hard to control cache strategy No

    integrity check.
  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.
  37. DO? DON’T? Not an easy choice.

  38. DO! DON’T!

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

  40. ~100 listeners

  41. Check eventName & event interface Dispatch the event in the

    application. Decorated EventDispatcher. Publish to RabbitMQ
  42. 129 workers. mail sms publication push indexation image resizing alerts

    profile completion We love workers!
  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?
  44. DO! But do it carefully!

  45. DO! DON’T!

  46. Put everything in the same place?

  47. It’s called V3

  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)
  49. 406 187 NLOC There are “only” 268 041 NLOC for

    symfony/symfony
  50. Size doesn’t matter!

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

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

  53. ~ 30 minutes to deploy the application

  54. What else ? • Long learning curve • Too many

    side effects • Time consuming • Big maintenance • Spaghetti code
  55. DO! Then DON’T! You’ll know when you’ll need it. :)

  56. DO! DON’T!

  57. Put business logic inside Symfony?

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

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

  60. MICRO-SERVICES

  61. MICRO-SERVICES

  62. The gateway

  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
  64. How to: Get a rating

  65. Business

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

    Server
  67. Data

  68. Data • Cache ready • Backend agnostic

  69. Data • Cache ready • Backend agnostic Encapsulation !

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

  71. Data RedisStorage DBALRatingStorage Fallback on DBALRatingStorage

  72. The gateway ❖ Flexible ❖ Easy to test ❖ Deployed

    when needed ❖ Used for all new projects
  73. V3 Previous ecosystem

  74. Gateway V3 W W W W W C W C

    C C W Current ecosystem W • 90 workers • 40 commands
  75. V3 W W W W W C W C C

    C W Future ecosystem? W Gateway Gateway Gateway
  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
  77. Put business logic inside Symfony?

  78. DON’T!

  79. I’ve found a use case!

  80. NO YOU DON’T!

  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.
  82. Symfony2 was a good choice. Even if we made lot

    of wrong choices. We’ll decouple!
  83. Keep growing! Simpler with several small applications?

  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