Advertisement
Advertisement

More Related Content

Advertisement

(micro)services avec Symfony et Tolerance

  1. (micro)services avec Symfony et Tolerance
  2. Samuel Roze Inviqa / SensioLabs UK @samuelroze github.com/sroze
  3. (micro)services
  4. The monolith
  5. Maintenance très chère
  6. SOA
  7. Microservices
  8. Fléxibilité
  9. Points clés » Organisation » Déploiement » Monitoring » Résiliance » Debugging
  10. Points clés Organisation » Responsabilité humaine (équipe) » Responsabilité technique (boudaries) » Communication humaine (objectifs communs) » Communication technique (documentation, BC, ...)
  11. Points clés Déploiement » Continuous Deployment » Continuous Delivery » Simple (Platform.sh, ContinuousPipe.io, ...) » Scalable (AWS, Google Cloud, ...)
  12. Points clés Monitoring » User-end monitoring (NewRelic, Google Analytics, ...) » Infrastructure monitoring (NewRelic, Sysdig, Datadog, ...) » Application monitoring (StatsD, ELK, Keen.io, ...) » Pro-active monitoring
  13. Points clés » Organisation » Déploiement » Monitoring » Résiliance » Debugging
  14. Tolerance  github.com/Tolerance/Tolerance tolerance.io
  15.  Résiliance
  16. Une opération $comments = $client->getLastComments();
  17. Une opération use ToleranceOperationCallback; $operation = new Callback(function() use ($client) { return $client->getLastComments(); });
  18. Runner $comments = $runner->run($operation);
  19.  Résiliance aux erreurs
  20. Retry $waitStrategy = new CountLimited( new ExponentialBackOff( new SleepWaiter(), 1 ), 10 ); $runner = new RetryOperationRunner( $decoratedRunner, $waitStrategy );
  21. Fallback $staticResultFactory = new StaticResultFactory([]); $runner = new FallbackOperationRunner( $decoratedRunner, $staticResultFactory ); // ... $messages = $runner->run($operation);
  22. Résiliance aux attaques
  23. Rate limiting $rateLimit = new LeakyBucket( new InMemoryStorage(), new TimeRate(10, TimeRate::PER_SECOND) ); $runner = new RateLimitedOperationRunner( $decoratedRunner, $rateLimit, new SleepWaiter() );
  24. D'autres types de runners...
  25. Buffered $buffer = new InMemoryOperationBuffer(); $bufferedRunner = new BufferedOperationRunner($runner, $buffer); // Run operations $bufferedRunner->run($firstOperation); $bufferedRunner->run($secondOperation); // ... // ... $results = $bufferedRunner->runBufferedOperations();
  26. Symfony!
  27. AppKernel.php ToleranceBridgeSymfonyBundleToleranceBundle();
  28. Runners with YAML tolerance: operation_runners: default: retry: runner: callback: ~ waiter: count_limited: count: 10 waiter: exponential_back_off: exponent: 1 waiter: sleep: ~
  29.  Buffered terminaison » Automatically with factory » Manual runners needs to be tagged <service id="app.my_buffered_operation_runner" class="ToleranceOperationRunnerBufferedOperationRunner"> <!-- Arguments... --> <tag name="tolerance.operation_runner" /> </service>
  30.  AOP
  31.  AOP tolerance: aop: ~
  32. AOP <services> <service id="app.comments_client" class="AppCommentsHttpClient"> <tag name="tolerance.operation_wrapper" methods="getLastComments" runner="tolerance.operation_runner.default" /> </service> </services>
  33. AOP $comments = $this->client->getLastComments();
  34. Debugging » Sentry » Tideways » NewRelic » Logs "manuels" » ...
  35. Tolerance  MessageProfile
  36. MessageProfile tolerance: message_profile: enabled: true storage: neo4j: neo4j_client_service_id current_peer: service: "My service" environment: %kernel.environment% version: 12345
  37. MessageProfile Integrations » Guzzle » Monolog » RabbitMqBundle » Symfony » HttpFoundation » PSR-7
  38. Merci! @samuelroze https://github.com/Tolerance/Tolerance https://joind.in/event/nouveau-sfpot--lille-le-3103-
Advertisement