take care of our micro services
TRANSCRIPT
![Page 1: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/1.jpg)
Let's take care of our micro-services
![Page 2: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/2.jpg)
Samuel RozeInviqa
twitter.com/samuelrozegithub.com/sroze
![Page 3: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/3.jpg)
(micro)services
![Page 4: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/4.jpg)
![Page 5: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/5.jpg)
![Page 6: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/6.jpg)
![Page 7: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/7.jpg)
![Page 8: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/8.jpg)
![Page 9: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/9.jpg)
![Page 10: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/10.jpg)
![Page 11: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/11.jpg)
Monolith costs a lot...(only) on the long run !
![Page 12: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/12.jpg)
![Page 13: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/13.jpg)
![Page 14: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/14.jpg)
![Page 15: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/15.jpg)
![Page 16: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/16.jpg)
![Page 17: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/17.jpg)
Microservices are flexible
but introduces complexity!
![Page 18: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/18.jpg)
![Page 19: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/19.jpg)
![Page 20: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/20.jpg)
![Page 21: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/21.jpg)
Key points» Organisation
» Deployment pipeline
» Monitoring & debugging
» Fault tolerance
![Page 22: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/22.jpg)
Key pointsOrganisation
» In the teamsSpotify's squads: the team knows about their services
» Between the teamsResponsibility boundaries, communication, shared goals
![Page 23: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/23.jpg)
Key pointsDeployment pipeline
» New servicesCreate new services within hours
» Continuous DeliverySmall and fast deployments
» Delivery as a ServiceThe teams can change the technology stack themselves
![Page 24: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/24.jpg)
Key pointsMonitoring and debugging
» Pro-active monitoringhealth-checks
» Active error logging and altertingknow what is going on
» Debugging after incidenttracing between services
![Page 25: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/25.jpg)
Key pointsFault tolerance
» Perfection, hopes or embracing faultsBecause that will happen
» ArchitectureA server dies
» ApplicationA service is down or throwing exceptions
![Page 26: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/26.jpg)
Key points, again» Organisation
» Deployment pipeline
» Monitoring & debugging
» Fault tolerance
![Page 27: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/27.jpg)
![Page 28: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/28.jpg)
Environments
![Page 29: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/29.jpg)
![Page 30: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/30.jpg)
![Page 31: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/31.jpg)
![Page 32: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/32.jpg)
![Page 33: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/33.jpg)
![Page 34: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/34.jpg)
Fault tolerance
![Page 35: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/35.jpg)
![Page 36: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/36.jpg)
![Page 37: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/37.jpg)
![Page 38: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/38.jpg)
![Page 39: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/39.jpg)
![Page 40: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/40.jpg)
![Page 41: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/41.jpg)
![Page 42: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/42.jpg)
![Page 43: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/43.jpg)
Tolerance github.com/Tolerance/Tolerance
tolerance.io
![Page 44: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/44.jpg)
ToleranceOperations
![Page 45: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/45.jpg)
Take something that can fail...$comments = $client->getLastComments();
![Page 46: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/46.jpg)
Wrap into an Operationuse Tolerance\Operation\Callback;
$operation = new Callback(function() use ($client) { return $client->getLastComments();});
![Page 47: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/47.jpg)
Run the operation$comments = $runner->run($operation);
![Page 48: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/48.jpg)
Be fault tolerantby decorating the operation
runners
![Page 49: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/49.jpg)
Retry
$waitStrategy = new CountLimited( new ExponentialBackOff( new SleepWaiter(), 1 ), 10);
$runner = new RetryOperationRunner( $decoratedRunner, $waitStrategy);
![Page 50: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/50.jpg)
Fallback
$staticResultFactory = new StaticResultFactory([]);
$runner = new FallbackOperationRunner( $decoratedRunner, $staticResultFactory);
// ...$messages = $runner->run($operation);
![Page 51: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/51.jpg)
![Page 52: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/52.jpg)
![Page 53: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/53.jpg)
Other operation runners...
![Page 54: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/54.jpg)
Rate limiting
$rateLimit = new LeakyBucket( new InMemoryStorage(), new TimeRate(10, TimeRate::PER_SECOND));
$runner = new RateLimitedOperationRunner( $decoratedRunner, $rateLimit, new SleepWaiter());
![Page 55: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/55.jpg)
Buffered (ie postponed runs)
$buffer = new InMemoryOperationBuffer();$bufferedRunner = new BufferedOperationRunner($runner, $buffer);
// Run operations$bufferedRunner->run($firstOperation);$bufferedRunner->run($secondOperation);
// ...// ...
$results = $bufferedRunner->runBufferedOperations();
![Page 56: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/56.jpg)
![Page 57: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/57.jpg)
AppKernel.phpnew Tolerance\Bridge\Symfony\Bundle
\ToleranceBundle();
![Page 58: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/58.jpg)
Get runners from YAML
tolerance: operation_runners: default: retry: # ... callback: # ... buffered: # ... fallback: # ...
![Page 59: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/59.jpg)
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
![Page 60: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/60.jpg)
AOPAspect Oriented Programming
![Page 61: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/61.jpg)
AOP
tolerance: aop: ~
![Page 62: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/62.jpg)
Wrap your services into operationsjust by using a tolerance.operation_wrapper tag
<services> <service id="app.comments_client" class="App\Comments\HttpClient">
<tag name="tolerance.operation_wrapper" methods="getLastComments" runner="tolerance.operation_runner.default" />
</service></services>
![Page 63: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/63.jpg)
Use your service as usual
$comments = $this->client->getLastComments();
![Page 64: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/64.jpg)
Tolerance MessageProfile
![Page 65: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/65.jpg)
![Page 66: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/66.jpg)
![Page 67: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/67.jpg)
MessageProfile
tolerance: message_profile: enabled: true storage: neo4j: neo4j_client_service_id
current_peer: service: "My service" environment: %kernel.environment% version: 12345
![Page 68: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/68.jpg)
MessageProfileIntegrations
» Guzzle
» Monolog
» RabbitMqBundle
» HttpFoundation
» PSR-7
![Page 69: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/69.jpg)
![Page 70: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/70.jpg)
![Page 71: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/71.jpg)
![Page 72: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/72.jpg)
![Page 73: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/73.jpg)
![Page 74: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/74.jpg)
![Page 75: Take care of our micro services](https://reader036.vdocuments.mx/reader036/viewer/2022062317/58ed19fb1a28ab2b2a8b45a7/html5/thumbnails/75.jpg)
Thank you!@samuelroze
https://github.com/Tolerance/Tolerance
https://joind.in/talk/2f75b