Advertisement

Take care of our micro services

Software Engineer at Inviqa
Sep. 10, 2016
Advertisement

More Related Content

Similar to Take care of our micro services(20)

Advertisement

Take care of our micro services

  1. Let's take care of our micro-services
  2. Samuel Roze Inviqa twitter.com/samuelroze github.com/sroze
  3. (micro)services
  4. Monolith costs a lot... (only) on the long run !
  5. Microservices are flexible but introduces complexity!
  6. Key points » Organisation » Deployment pipeline » Monitoring & debugging » Fault tolerance
  7. Key points Organisation » In the teams Spotify's squads: the team knows about their services » Between the teams Responsibility boundaries, communication, shared goals
  8. Key points Deployment pipeline » New services Create new services within hours » Continuous Delivery Small and fast deployments » Delivery as a Service The teams can change the technology stack themselves
  9. Key points Monitoring and debugging » Pro-active monitoring health-checks » Active error logging and alterting know what is going on » Debugging after incident tracing between services
  10. Key points Fault tolerance » Perfection, hopes or embracing faults Because that will happen » Architecture A server dies » Application A service is down or throwing exceptions
  11. Key points, again » Organisation » Deployment pipeline » Monitoring & debugging » Fault tolerance
  12. Environments
  13. Fault tolerance
  14. Tolerance  github.com/Tolerance/Tolerance tolerance.io
  15. Tolerance Operations
  16. Take something that can fail... $comments = $client->getLastComments();
  17. Wrap into an Operation use ToleranceOperationCallback; $operation = new Callback(function() use ($client) { return $client->getLastComments(); });
  18. Run the operation $comments = $runner->run($operation);
  19.  Be fault tolerant by decorating the operation runners
  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. Other operation runners...
  23. Rate limiting $rateLimit = new LeakyBucket( new InMemoryStorage(), new TimeRate(10, TimeRate::PER_SECOND) ); $runner = new RateLimitedOperationRunner( $decoratedRunner, $rateLimit, new SleepWaiter() );
  24. Buffered (ie postponed runs) $buffer = new InMemoryOperationBuffer(); $bufferedRunner = new BufferedOperationRunner($runner, $buffer); // Run operations $bufferedRunner->run($firstOperation); $bufferedRunner->run($secondOperation); // ... // ... $results = $bufferedRunner->runBufferedOperations();
  25. AppKernel.php new ToleranceBridgeSymfonyBundle ToleranceBundle();
  26. Get runners from YAML tolerance: operation_runners: default: retry: # ... callback: # ... buffered: # ... fallback: # ...
  27.  Buffered runner A lot of operations don't have to be executed just now. $runner->run(new Callback(function() { $this->pushMyBusinessMetricToElasticSearch(); })); » Run operations on kernel.terminate event
  28.  AOP Aspect Oriented Programming
  29.  AOP tolerance: aop: ~
  30. Wrap your services into operations just by using a tolerance.operation_wrapper tag <services> <service id="app.comments_client" class="AppCommentsHttpClient"> <tag name="tolerance.operation_wrapper" methods="getLastComments" runner="tolerance.operation_runner.default" /> </service> </services>
  31. Use your service as usual $comments = $this->client->getLastComments();
  32. Tolerance  MessageProfile
  33. MessageProfile tolerance: message_profile: enabled: true storage: neo4j: neo4j_client_service_id current_peer: service: "My service" environment: %kernel.environment% version: 12345
  34. MessageProfile Integrations » Guzzle » Monolog » RabbitMqBundle » HttpFoundation » PSR-7
  35. Thank you! @samuelroze https://github.com/Tolerance/Tolerance https://joind.in/talk/2f75b
Advertisement