PHP distribuído, fault-tolerant e assíncrono - Microserviços vs Monolito

799efab30a6db8436e6941dfd372c66f?s=47 Zizaco
March 28, 2017

PHP distribuído, fault-tolerant e assíncrono - Microserviços vs Monolito

PHP distribuído, fault-tolerant e assíncrono
"Microserviços vs Monolito": O melhor dos 2 mundos

Vídeo da Apresentação (2017/03/28): https://youtu.be/3alX9_RAouw
Apresentado em: https://phpexperience2017.imasters.com.br/

Who am I?
Luiz Fernando / Zizaco
http://zizaco.net

Monolíto/Camadas vs Microserviços

Microserviços:
- Vantagens
- Escalabilidade
- Melhor utilização de recursos
- Isolamento de falhas
- Deploy parcial
- Equipes focadas em cada serviço
- Organização do codebase
- Agnóstico de tecnologia
- Desvantagens
- Desenvolvimento trabalhoso
- Complexidade operacional
- Orquestração de serviços
- Chamadas remotas lentas
- Service discovery
- Controle de versão entre serviços

"The code became very complex to read and nobody understood the platform end to end. This caused pull requests and code reviews to be ineffective [...] We were also duplicating effort across teams since there were no shared components."
- By Avi Cavale, Shippable.com

"To solve these issues, we switched to a ‘mono repo’ a few months ago. This meant that even though our services are still developed and deployed independently, the code for all services lives in one repository."
- By Avi Cavale, Shippable.com

Microserviços MonoRepo:
- Vantagens
- Escalabilidade
- Melhor utilização de recursos
- Isolamento de falhas
- Deploy parcial
- Equipes focadas em cada serviço
- Organização do codebase
- Agnóstico de tecnologia
- Desvantagens
- Desenvolvimento trabalhoso
- Complexidade operacional
- Orquestração de serviços
- Chamadas remotas lentas
- Service discovery
- Controle de versão entre serviços

Command Bus Architecture:
- Vantagens
- Escalabilidade
- Melhor utilização de recursos
- Isolamento de falhas
- Deploy parcial
- Equipes focadas em cada serviço
- Organização do codebase
- Agnóstico de tecnologia
- Desvantagens
- Desenvolvimento trabalhoso
- Complexidade operacional
- Orquestração de serviços
- Chamadas remotas lentas
- Service discovery
- Controle de versão entre serviços

Distributed Application, Definição:
- Multiplos nodes interconectados.
- Não existe memória física compartilhada entre os nodes.
- Toda a comunicação entre os nodes é realizada via troca de mensagens.
- Concorrência de componentes.
- Não existe "lock global".
- Tolerante a falha de um componente.

Upswarm:

Multi-processed, async, fault-tolerant micro-framework
for writing distributed service-oriented PHP applications.

https://github.com/Zizaco/upswarm

[Live Demo]

Isolado e Concorrente
- Crashes são isolados
- Estado e dados são isolados
- Balanceamento de carga de IO e CPU (eficiente em multicore)

Broker
(Ex: RabbitMQ, Beanstalkd, IronMQ, Kafka)
Brokerless
(Ex: ZeroMQ)

Performance?

[Live Demo]

Upswarm / Distributed App:
- Vantagens
- Escalabilidade
- Melhor utilização de recursos
- Isolamento de falhas
- Deploy parcial
- Equipes focadas em cada serviço
- Organização do codebase
- Agnóstico de tecnologia
- Desvantagens
- Desenvolvimento trabalhoso
- Complexidade operacional
- Orquestração de serviços
- Chamadas remotas lentas
- Service discovery
- Controle de versão entre serviços

"Good modular structure is useful in any program, but becomes exponentially more important as the software grows in size. Perhaps more importantly, it grows more in importance as the team developing it grows in size."
- Martin Fowler about "Microservice Trade-Offs"

Arquitetura em camadas

"Another challenge is deciding how to partition the system into microservices.This is very much an art, [...]"
- Chris Richardson - microservices.io

Arquitetura "self-contained"

Conway’s Law: "The architecture of the system will reflect the organization that produced it. Parts of the organization that don’t talk together will likely produce software that doesn’t talk together."

Fontes:
Our Journey to Microservices: Mono Repo vs Multiple Repos - Avi Cavale - Shippable.com
http://blog.shippable.com/our-journey-to-microservices-and-a-mono-repository

ZeroMQ: Broker vs Brokerless
http://zeromq.org/whitepapers:brokerless

We use one repository at google - Jeremy Wall - Google
https://news.ycombinator.com/item?id=7020584

Microservices: A definition of this new architectural term - Martin Fowler
https://martinfowler.com/articles/microservices.html

Micro-Services: Is HTTP the only way? - Ben Shaw
https://www.youtube.com/watch?v=O1qaoykYIXY

PHP Framework Benchmark - kenjis
https://github.com/kenjis/php-framework-benchmark

Distributed computing - Wikipedia
https://en.wikipedia.org/wiki/Distributed_computing

What Exactly is DevOps? - Neil Garnichaud
http://www.drdobbs.com/architecture-and-design/what-exactly-is-devops/240009147

Building Microservice Architectures - Neal Ford
https://www.youtube.com/watch?v=pjN7CaGPFB4

Microservice Trade-Offs - Martin Fowler
https://martinfowler.com/articles/microservice-trade-offs.html

Trabalhe conosco (:

799efab30a6db8436e6941dfd372c66f?s=128

Zizaco

March 28, 2017
Tweet

Transcript

  1. PHP distribuído, fault-tolerant e assíncrono "Microserviços vs Monolito" O melhor

    dos 2 mundos
  2. Who am I? • Software Developer • Product Owner •

    Leroy Merlin (Laravel) • Keep learning http://zizaco.net Luiz Fernando / Zizaco
  3. Monolíto/Camadas vs Microserviços

  4. Monolíto/Camadas vs Microserviços

  5. Microserviços: Vantagens - Escalabilidade - Melhor utilização de recursos -

    Isolamento de falhas - Deploy parcial - Equipes focadas em cada serviço - Organização do codebase - Agnóstico de tecnologia
  6. Microserviços: Desvantagens - Desenvolvimento trabalhoso - Complexidade operacional - Orquestração

    de serviços - Chamadas remotas lentas - Service discovery - Controle de versão entre serviços
  7. Monolíto/Camadas vs Microserviços Microservices Monolithic

  8. None
  9. Monolíto/Camadas vs Microserviços Microservices Mono Repo Microservices Monolithic

  10. "The code became very complex to read and nobody understood

    the platform end to end. This caused pull requests and code reviews to be ineffective [...] We were also duplicating effort across teams since there were no shared components." - By Avi Cavale, Shippable.com
  11. "To solve these issues, we switched to a ‘mono repo’

    a few months ago. This meant that even though our services are still developed and deployed independently, the code for all services lives in one repository." - By Avi Cavale, Shippable.com
  12. Monolíto/Camadas vs Microserviços Microservices Mono Repo Microservices Monolithic

  13. Microserviços MonoRepo: Vantagens - Escalabilidade - Melhor utilização de recursos

    - Isolamento de falhas - Deploy parcial - Equipes focadas em cada serviço - Organização do codebase - Agnóstico de tecnologia
  14. Microserviços MonoRepo: Desvantagens - Desenvolvimento trabalhoso - Complexidade operacional -

    Orquestração de serviços - Chamadas remotas lentas - Service discovery - Controle de versão entre serviços
  15. Monolíto/Camadas vs Microserviços Microservices Mono Repo Microservices Monolithic

  16. None
  17. None
  18. Monolíto/Camadas vs Microserviços Monolithic Microservices Mono Repo Microservices Command Bus

    Based Architecture
  19. Command Bus Arch.: Vantagens - Escalabilidade - Melhor utilização de

    recursos - Isolamento de falhas - Deploy parcial - Equipes focadas em cada serviço - Organização do codebase - Agnóstico de tecnologia
  20. Command Bus Arch.: Desvantagens - Desenvolvimento trabalhoso - Complexidade operacional

    - Orquestração de serviços - Chamadas remotas lentas - Service discovery - Controle de versão entre serviços
  21. Monolíto/Camadas vs Microserviços Monolithic Microservices Mono Repo Microservices Command Bus

    Based Architecture
  22. Monolíto/Camadas vs Microserviços Monolithic Microservices Mono Repo Microservices Command Bus

    Based Architecture Distributed Application
  23. Monolíto/Camadas vs Microserviços Monolithic Microservices Mono Repo Microservices Command Bus

    Based Architecture Distributed Application
  24. Distributed Application - Multiplos nodes interconectados. - Não existe memória

    física compartilhada entre os nodes. - Toda a comunicação entre os nodes é realizada via troca de mensagens. - Concorrência de componentes. - Não existe "lock global". - Tolerante a falha de um componente.
  25. Multi-processed, async, fault-tolerant micro-framework for writing distributed service-oriented PHP applications.

    https://github.com/Zizaco/upswarm
  26. Distributed Application Server Client Client Client

  27. Distributed Application Client Client Client

  28. Live Demo

  29. Live Demo

  30. Live Demo

  31. Live Demo

  32. Live Demo

  33. Live Demo

  34. Live Demo

  35. Live Demo

  36. Live Demo

  37. Live Demo

  38. Live Demo

  39. Live Demo

  40. Live Demo

  41. Live Demo

  42. Live Demo

  43. Live Demo

  44. Live Demo

  45. Live Demo

  46. Live Demo

  47. Live Demo

  48. Distributed Application Server Client Client Client Client

  49. Distributed Application Server Client Client Client Server Client

  50. Distributed Application Server Client Client Client Server Client ZeroMQ

  51. Distributed Application Client Client Client Client

  52. Distributed Application Client Client Client Client

  53. Distributed Application Client HttpServer Service Products Controller Categories Controller Repository

    Service Permissions Service
  54. Distributed Application Client HttpServer Service Products Controller Categories Controller Repository

    Service Permissions Service
  55. Isolado e Concorrente - Crashes são isolados - Estado e

    dados são isolados - Balanceamento de carga de IO e CPU (eficiente em multicore)
  56. Distributed Application Client Client Client Client

  57. Distributed Application Client Client Client Client Server Server Server

  58. Distributed Application Client Client Client Client Server Server Server ZeroMQ

  59. Distributed Application Broker (Ex: RabbitMQ, Beanstalkd, IronMQ, Kafka) Brokerless (Ex:

    ZeroMQ)
  60. Distributed Application Client Client Client Client Server Server Server

  61. Performance?

  62. Live Demo

  63. Live Demo

  64. None
  65. Upswarm / Distributed App.: Vantagens - Escalabilidade - Melhor utilização

    de recursos - Isolamento de falhas - Deploy parcial - Equipes focadas em cada serviço - Organização do codebase - Agnóstico de tecnologia
  66. Upswarm / Distributed App.: Desvantagens - Desenvolvimento trabalhoso - Complexidade

    operacional - Orquestração de serviços - Chamadas remotas lentas - Service discovery - Controle de versão entre serviços
  67. None
  68. "Good modular structure is useful in any program, but becomes

    exponentially more important as the software grows in size. Perhaps more importantly, it grows more in importance as the team developing it grows in size." - Martin Fowler about "Microservice Trade-Offs"
  69. src Http WebServerService.php ProductCatalog CatalogService.php Cart CartService.php Product.php Category.php Cart.php

    ... Arquitetura em camadas
  70. src Http WebServerService.php ProductCatalog Cart CartService.php Cart.php ... Infrastructure Persistance

    Caching Arquitetura em camadas
  71. src Http WebServerService.php ProductCatalog Cart PersistanceService.php DataMapperInterface.php Infrastructure Persistance Product

    Cart Arquitetura em camadas
  72. "Another challenge is deciding how to partition the system into

    microservices. This is very much an art, [...]" - Chris Richardson - microservices.io
  73. src Http WebServerService.php ProductCatalog CatalogService.php Product.php Category.php Cart.php Arquitetura "self-contained"

    Persistance Cart CartService.php Caching
  74. src Http WebServerService.php ProductCatalog CatalogService.php Product.php Category.php PersistanceService.php Arquitetura "self-contained"

    Persistance ProductDataMapper.php CategoryDataMapper.php
  75. Conway’s Law: "The architecture of the system will reflect the

    organization that produced it. Parts of the organization that don’t talk together will likely produce software that doesn’t talk together."
  76. Fontes Our Journey to Microservices: Mono Repo vs Multiple Repos

    - Avi Cavale - Shippable.com http://blog.shippable.com/our-journey-to-microservices-and-a-mono-repository ZeroMQ: Broker vs Brokerless http://zeromq.org/whitepapers:brokerless We use one repository at google - Jeremy Wall - Google https://news.ycombinator.com/item?id=7020584 Microservices: A definition of this new architectural term - Martin Fowler https://martinfowler.com/articles/microservices.html Micro-Services: Is HTTP the only way? - Ben Shaw https://www.youtube.com/watch?v=O1qaoykYIXY PHP Framework Benchmark - kenjis https://github.com/kenjis/php-framework-benchmark Distributed computing - Wikipedia https://en.wikipedia.org/wiki/Distributed_computing What Exactly is DevOps? - Neil Garnichaud http://www.drdobbs.com/architecture-and-design/what-exactly-is-devops/240009147
  77. Fontes Building Microservice Architectures - Neal Ford https://www.youtube.com/watch?v=pjN7CaGPFB4 Microservice Trade-Offs

    - Martin Fowler https://martinfowler.com/articles/microservice-trade-offs.html
  78. Trabalhe conosco (: Back-end Front-end UX gguitte@leroymerlin.com.br assunto: [vaga]