24
From PHP Monolith to Polyglot Microservices Kazki Matz @ CareerLink Vietnam

From PHP monolith to polyglot microservices

Embed Size (px)

Citation preview

Page 1: From PHP monolith to polyglot microservices

From  PHP  Monolith    to  

 Polyglot  Microservices

Kazki  Matz  @  CareerLink  Vietnam

Page 2: From PHP monolith to polyglot microservices

About  me

•  Kazuki  MATSUMOTO  (Kazki  Matz)  •  Rubyist  (Since  2009)  •  Been  living  in  Vietnam  (Since  2012)  

•  CTO  at  CareerLink  Vietnam  (Since  2012)  

Page 3: From PHP monolith to polyglot microservices

www.careerlink.vn

Page 4: From PHP monolith to polyglot microservices

Our  architecture  (~  2015)

•  PHP  Monolith  built  with  Symfony2

Symfony2  Monolith  (mod_php)

LB  (Nginx)

MySQL

mongoDB

ElasXcsearch

Page 5: From PHP monolith to polyglot microservices

Microservices  Architecture

Building  applicaXon  as  a  suite  of  small  services  •  Each  service  has  it’s  own  codebase  •  Each  service  runs  under  dedicated  process    •  Each  service  can  be  wriZen  in  different  languages  

•  Each  service  has  it’s  own  datastore  •  Each  service  has  it’s  own  deployment  strategy  

Page 6: From PHP monolith to polyglot microservices

Our  architecture  (2015  ~)

ElasXcsearch

LB  (Nginx)

mongo MySQL

Symfony2  Monolith  

(mod_php  +  CLI)

mongo MySQL

API  endpoint  (Rails)

MySQL

Messaging  (Rails)

ElasXcsearch

RecommendaXon  Engine  

Document  censorship

Document  Converter

RabbitMQ  Broker

ElasXcsearch

Site  StaXsXcs  Dashboard

Page 7: From PHP monolith to polyglot microservices

•  Inter-­‐process  communicaXon  overhead  – SerializaXon,  Network  RTT  

•  New  middlewares  – Load  balancing  /  API  discovery  

•  More  management  costs  – Monitoring  &  Error  NoXficaXons  

– Deployment  Infrastructure  – Performance  Profiling  

Cost  of  Microservices

Page 8: From PHP monolith to polyglot microservices

•  Inter-­‐process  communicaXon  overhead  – SerializaXon,  Network  RTT  

•  New  middlewares  – Load  balancing  /  API  discovery  /  Profiling  

•  More  management  costs  – Monitoring  &  Error  NoXficaXons  

– Deployment  Infrastructure  – Performance  Profiling  

Cost  of  Microservices

Page 9: From PHP monolith to polyglot microservices

•  Inter-­‐process  communicaXon  overhead  – SerializaXon,  Network  RTT  

•  New  middlewares  – Load  balancing  /  API  discovery  

•  More  management  costs  – Monitoring  &  Error  NoXficaXons  

– Deployment  Infrastructure  – Performance  Profiling  

Cost  of  Microservices

Page 10: From PHP monolith to polyglot microservices

New  middlewares

•  Load  balancing  •  API  discovery  /  rouXng  service  •  RPC  request  profiling  

Page 11: From PHP monolith to polyglot microservices
Page 12: From PHP monolith to polyglot microservices

RabbitMQ  RPC:  Pros

•  No  need  of  load  balancing  •  No  need  of  API  discovery  service  •  Synchronous  RPC  /  Asynchronous  Messaging  

•  Nice  built-­‐in  web  UI  

Page 13: From PHP monolith to polyglot microservices
Page 14: From PHP monolith to polyglot microservices

RabbitMQ  RPC:  Cons

•  Not  scalable  •  No  request  logging/profiling

Page 15: From PHP monolith to polyglot microservices

•  Inter-­‐process  communicaXon  overhead  – SerializaXon,  Network  RTT  

•  New  middlewares  – Load  balancing  /  API  discovery  

•  More  management  costs  – Monitoring  &  Error  NoXficaXons  

– Deployment  Infrastructure  – Performance  Profiling  

Cost  of  Microservices

Page 16: From PHP monolith to polyglot microservices

Error  NoXficaXons

Page 17: From PHP monolith to polyglot microservices

Deployment

Page 18: From PHP monolith to polyglot microservices

Cost  of  Microservices

•  Inter-­‐process  communicaXon  overhead  – SerializaXon,  Network  roundtrip  

•  New  middlewares  – API  gateway  

•  More  management  costs  – Monitoring  &  Error  NoXficaXons  

– Deployment  Infrastructure  – Performance  Profiling  

Page 19: From PHP monolith to polyglot microservices

fluentd:  The  Log  Collector  for  Rubyists

Page 20: From PHP monolith to polyglot microservices

ElasXcsearch

Logging  each  RPC  request…

ElasXcsearch

LB  (Nginx)

mongo MySQL

Symfony2  Monolith  

(mod_php  +  CLI)

MySQL

mongo MySQL

API  endpoint  (Rails)

Messaging  (Rails)

ElasXcsearch

RecommendaXon  Engine  

Document  censorship

Document  Converter

Site  StaXsXcs  Dashboard

fluent-­‐logger-­‐php

fluent-­‐logger

fluent-­‐logger fluent-­‐logger

fluent-­‐logger

fluent-­‐logger

fluent-­‐logger

fluentd

ElasXcsearch

fluent-­‐plugin-­‐kibana

Kibana

Page 21: From PHP monolith to polyglot microservices

DEMO

Page 22: From PHP monolith to polyglot microservices

Summary

•  Microservices  architecture  is  a  good  way  to…  

–   Keep  moXvated  on  coding  

–   Catch  up  latest  technologies  

Page 23: From PHP monolith to polyglot microservices

Jobs  on  careerlink.vn

Page 24: From PHP monolith to polyglot microservices

QuesXons?