(micro)services avec symfony et tolerance

Post on 16-Apr-2017

470 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

(micro)services avec Symfony et Tolerance

Samuel RozeInviqa / SensioLabs UK

@samuelrozegithub.com/sroze

(micro)services

The monolith

Maintenancetrès chère

SOA

Microservices

Fléxibilité

Points clés» Organisation

» Déploiement

» Monitoring

» Résiliance

» Debugging

Points clésOrganisation

» Responsabilité humaine (équipe)

» Responsabilité technique (boudaries)

» Communication humaine (objectifs communs)

» Communication technique (documentation, BC, ...)

Points clésDéploiement

» Continuous Deployment

» Continuous Delivery

» Simple (Platform.sh, ContinuousPipe.io, ...)

» Scalable (AWS, Google Cloud, ...)

Points clésMonitoring

» User-end monitoring (NewRelic, Google Analytics, ...)

» Infrastructure monitoring (NewRelic, Sysdig, Datadog, ...)

» Application monitoring (StatsD, ELK, Keen.io, ...)

» Pro-active monitoring

Points clés» Organisation

» Déploiement

» Monitoring

» Résiliance

» Debugging

Tolerance github.com/Tolerance/Tolerance

tolerance.io

 Résiliance

Une opération$comments = $client->getLastComments();

Une opérationuse Tolerance\Operation\Callback;

$operation = new Callback(function() use ($client) { return $client->getLastComments();});

Runner$comments = $runner->run($operation);

 Résilianceaux erreurs

Retry

$waitStrategy = new CountLimited( new ExponentialBackOff( new SleepWaiter(), 1 ), 10);

$runner = new RetryOperationRunner( $decoratedRunner, $waitStrategy);

Fallback

$staticResultFactory = new StaticResultFactory([]);

$runner = new FallbackOperationRunner( $decoratedRunner, $staticResultFactory);

// ...$messages = $runner->run($operation);

Résilianceaux attaques

Rate limiting

$rateLimit = new LeakyBucket( new InMemoryStorage(), new TimeRate(10, TimeRate::PER_SECOND));

$runner = new RateLimitedOperationRunner( $decoratedRunner, $rateLimit, new SleepWaiter());

D'autres types de runners...

Buffered

$buffer = new InMemoryOperationBuffer();$bufferedRunner = new BufferedOperationRunner($runner, $buffer);

// Run operations$bufferedRunner->run($firstOperation);$bufferedRunner->run($secondOperation);

// ...// ...

$results = $bufferedRunner->runBufferedOperations();

Symfony!

AppKernel.phpTolerance\Bridge\Symfony\Bundle\ToleranceBundle();

Runners with YAML

tolerance: operation_runners: default: retry: runner: callback: ~

waiter: count_limited: count: 10 waiter: exponential_back_off: exponent: 1 waiter: sleep: ~

 Buffered terminaison

» Automatically with factory

» Manual runners needs to be tagged

<service id="app.my_buffered_operation_runner" class="Tolerance\Operation\Runner\BufferedOperationRunner"> <!-- Arguments... -->

<tag name="tolerance.operation_runner" /></service>

 AOP

 AOP

tolerance: aop: ~

AOP

<services> <service id="app.comments_client" class="App\Comments\HttpClient">

<tag name="tolerance.operation_wrapper" methods="getLastComments" runner="tolerance.operation_runner.default" />

</service></services>

AOP

$comments = $this->client->getLastComments();

Debugging» Sentry

» Tideways

» NewRelic

» Logs "manuels"

» ...

Tolerance MessageProfile

MessageProfile

tolerance: message_profile: enabled: true storage: neo4j: neo4j_client_service_id

current_peer: service: "My service" environment: %kernel.environment% version: 12345

MessageProfileIntegrations

» Guzzle

» Monolog

» RabbitMqBundle

» Symfony

» HttpFoundation

» PSR-7

Merci!@samuelroze

https://github.com/Tolerance/Tolerance

https://joind.in/event/nouveau-sfpot--lille-le-3103-

top related