Under certain conditions, Symfony can be used successfully in a microservices architecture. Symfony works best when services start large and decompose over time into bounded contexts, rather than starting with many small services. Key considerations include using minimal Symfony configurations, domain-driven design principles to map services to contexts, handling failures through circuit breakers, and focusing on behavior-driven development and integration testing between services. While Symfony introduces more complexity than micro frameworks, these strategies can help address issues of over-decomposition when applying it to microservices.
Introduces Symfony's role in microservices architecture. Highlights various technologies (GoLang, Python, Symfony, Django) used in a project with 8 microservices.
Introduces Symfony's role in microservices architecture. Highlights various technologies (GoLang, Python, Symfony, Django) used in a project with 8 microservices.
Introduces Symfony's role in microservices architecture. Highlights various technologies (GoLang, Python, Symfony, Django) used in a project with 8 microservices.
Discusses the characteristics of microservices, including autonomy and focused functionality. Cites Robert C. Martin on grouping and separating change.
Discusses the characteristics of microservices, including autonomy and focused functionality. Cites Robert C. Martin on grouping and separating change.
Addresses drawbacks of Symfony as a microservice framework, including complexity, learning curve, and configuration challenges.
Examines when Symfony can succeed in microservices, warns against premature decomposition, and recommends starting with a monolith.
Examines when Symfony can succeed in microservices, warns against premature decomposition, and recommends starting with a monolith.
Examines when Symfony can succeed in microservices, warns against premature decomposition, and recommends starting with a monolith.
Focuses on practical Symfony usage in microservices, including minimal scaffolding and configuration, with an example using Slack.
Discusses strategies for integration and testing of microservices using Symfony, including the circuit breaker pattern to handle failures.
Discusses strategies for integration and testing of microservices using Symfony, including the circuit breaker pattern to handle failures.
Discusses strategies for integration and testing of microservices using Symfony, including the circuit breaker pattern to handle failures.
Summarizes the potential of using Symfony in microservices, emphasizing minimal integration and the importance of proper team dynamics in implementation.
small and focusedon doing one thing well
"Gather together those things that
change for the same reason,
and separate those things that
change for different reasons"
Robert C. Martin
HOW SMALL IS SMALL?HOW SMALL IS SMALL?
SYMFONY IS NOTASYMFONY IS NOT A
MICROMICRO FRAMEWORKFRAMEWORK
IT CAN BEIT CAN BE
CONSIDERED MORECONSIDERED MORE
AA "FULL-STACK""FULL-STACK"
FRAMEWORKFRAMEWORK
"... ANOTHER LESSONI LEARNED WAS"... ANOTHER LESSON I LEARNED WAS
TO NOT GET TOO GRANULAR WITHTO NOT GET TOO GRANULAR WITH
MICROSERVICES AT THE BEGINNINGMICROSERVICES AT THE BEGINNING
OF A PROJECT"OF A PROJECT"
34.
"... INSTEAD OFDOING WHAT WE DID"... INSTEAD OF DOING WHAT WE DID
(STARTING WITH 8 SERVICES), TRY(STARTING WITH 8 SERVICES), TRY
STARTING WITH TWO OR THREESTARTING WITH TWO OR THREE
SERVICES OF LOGICALLY RELATEDSERVICES OF LOGICALLY RELATED
FUNCTIONALITY (THEY WON'T BEFUNCTIONALITY (THEY WON'T BE
MICRO, HOWEVER)"MICRO, HOWEVER)"
ERIC EVANSERIC EVANS
Hetalked about how microservices boundary enable DDD
https://skillsmatter.com/skillscasts/6259-ddd-and-microservices-at-last-some-
bounderies
DDD eXchange 2015
THOUGHWORKSTHOUGHWORKS
https://www.thoughtworks.com/insights/blog/domain-driven-design-services-
architecture
Domain Driven Design for Services Architecture
Bounded Contexts Designed as Service Applications
MESSAGE CONTEXTMESSAGE CONTEXT
Messages
Context
ALLOWSAALLOWS A PUBLISHERPUBLISHER
TO PUBLISH AND DELETETO PUBLISH AND DELETE
MESSAGGES ONMESSAGGES ON OPENOPEN
CHANNELSCHANNELS
AA PUBLISHERPUBLISHER MUST BEMUST BE
AUTHORIZEDAUTHORIZED TOTO
PUBLISH A MESSAGE ONPUBLISH A MESSAGE ON
A CHANNELA CHANNEL
MINIMAL SYMFONY CONFMINIMALSYMFONY CONF
Inspired by:
http://www.whitewashing.de/2014/10/26/symfony_all_the_things_web.html
environment variables
.env files
only one config.yml
only one entry point (index.php)
DotEnv
https://github.com/vlucas/phpdotenv
54.
require_once __DIR__ ."/../vendor/autoload.php";
require_once __DIR__ . "/../app/AppKernel.php";
use SymfonyComponentHttpFoundationRequest;
use DotenvDotenv;
//load environment variables. It doesn't overwrite existing ones
$dotenv = new Dotenv(__DIR__ . '/../');
$dotenv->load();
$request = Request::createFromGlobals();
$kernel = new AppKernel(
$_SERVER['SYMFONY_ENV'],
(bool)$_SERVER['SYMFONY_DEBUG']
);
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
Only one index.php
55.
Only 1 config.yml
publicfunction registerBundles()
{
...
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__ . '/config/config.yml');
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$loader->load(function ($container) {
$container->loadFromExtension('web_profiler', array(
'toolbar' => true,
));
$container->loadFromExtension('framework', array(
'test' => true,
));
});
}
}
MAKE THE VALUEEXPLICITMAKE THE VALUE EXPLICIT
(It's important also for other developers)
60.
Feature: message publisher
Asa Publisher
I need to be able to publish a message on a channel
...
Scenario: A publisher, if not authorized
is not able to publish a new
message on a channel
Given I am publisher
And exists an "open" channel
And I'm not authorized
to publish messages on that channel
When I write the message "Hi guys"
Then I'm informed that I'm not authorized
And no new messages will be published on
that channel
"A CIRCUIT BREAKERIS"A CIRCUIT BREAKER IS
USED TO DETECT FAILURESUSED TO DETECT FAILURES
AND ENCAPSULATES LOGICAND ENCAPSULATES LOGIC
OF PREVENTING A FAILUREOF PREVENTING A FAILURE
TO REOCCURTO REOCCUR
CONSTANTLY"CONSTANTLY"
namespace MessageContextInfrastructureBundleCircuitBreaker;
class CircuitBreakerimplements PostContextCircuitBreakerInterface
{
private $circuitBreaker;
...
public function isAvailable($serviceName)
{
return $this->circuitBreaker->isAvailable($serviceName);
}
public function reportSuccess($serviceName)
{
$this->circuitBreaker->reportSuccess($serviceName);
}
public function reportFailure($serviceName)
{
$this->circuitBreaker->reportFailure($serviceName);
}
}
83.
public function getChannel(ChannelId$channelId)
{
if ($this->circuitBreaker->isAvailable($this->serviceName)) {
try {
$channel = $this->channelAdapter->toChannel($channelId);
$this->circuitBreaker->reportSuccess($this->serviceName);
return $channel;
} catch (UnableToProcessResponseFromService $e) {
$this->handleNotExpectedResponse($e->getResponse());
}
}
$this->onServiceNotAvailable("Service not available");
}
private function handleNotExpectedResponse(Response $response)
{
$this->circuitBreaker->reportFailure($this->serviceName);
...
}
SYMFONY CAN BEUSED INSYMFONY CAN BE USED IN
SOME MICROSERVICESOME MICROSERVICE
ARCHITECTURES,ARCHITECTURES,
ESPECIALLY IF WE STARTESPECIALLY IF WE START
WITH A MONOLITH FIRSTWITH A MONOLITH FIRST
APPROACHAPPROACH
86.
HOWEVER WE MAYNEED TOHOWEVER WE MAY NEED TO
CONSIDER SOMECONSIDER SOME
EXPEDIENTSEXPEDIENTS
(env variables, avoid complex tools)
(IT DEPENDS ON THE TEAM!!)(IT DEPENDS ON THE TEAM!!)
87.
MINIMAL INTEGRATIONSMINIMAL INTEGRATIONS
&
HANDLINGFAILURESHANDLING FAILURES
ARE A GOOD STARTING POINTARE A GOOD STARTING POINT
TO FACE THE OVERCOMPLEXITYTO FACE THE OVERCOMPLEXITY
INTRODUCED BYINTRODUCED BY
THIS ARCHITECTURETHIS ARCHITECTURE