Upgrade to Pro — share decks privately, control downloads, hide ads and more …

LINE TODAY - 微服務架構支撐千萬,活躍用戶的影音內容平臺

LINE TODAY - 微服務架構支撐千萬,活躍用戶的影音內容平臺

LINE Developers Taiwan

October 18, 2022
Tweet

More Decks by LINE Developers Taiwan

Other Decks in Technology

Transcript

  1. • LINE TODAY and its architecture • How miniservices and

    K8S changes our development and operation • Lessons learnt Agenda
  2. LINE TODAY Stays With You Today 個人化訊息 8:00 財經天氣 12:30

    國際/國內/娛樂 生活內容 15:00 話題/投票/電影 官方帳號 18:00 TODAY看世界 20:00 棒球/NBA/演唱會 新聞內容 直播
  3. CDN Object Storage In Mem Cach e Backend Server Frontend

    Server Cache Server Mini Service Feeding Service Internal CMS External CMS Vue.js Third Party API Content Provider Internal Editor External Editor Report Service Data Warehouse LINE TODAY Architecture ML Data Analysis
  4. CDN 96% Object Storage In Mem Cach e Backend Server

    Frontend Server Cache Server Mini Service Feeding Service Internal CMS External CMS Vue.js Third Party API Content Provider Internal Editor External Editor Report Service Data Warehouse LINE TODAY Architecture ML Data Analysis 4%
  5. CDN Object Storage In Mem Cach e Backend Server Frontend

    Server Cache Server Mini Service Feeding Service Internal CMS External CMS Vue.js Third Party API Content Provider Internal Editor External Editor Report Service Data Warehouse LINE TODAY Architecture ML Data Analysis
  6. CDN Object Storage In Mem Cach e Backend Server Frontend

    Server Cache Server Mini Service Feeding Service Internal CMS External CMS Vue.js Third Party API Content Provider Internal Editor External Editor Report Service Data Warehouse LINE TODAY Architecture ML Data Analysis
  7. CDN Object Storage In Mem Cach e Backend Server Frontend

    Server Cache Server Mini Service Feeding Service Internal CMS External CMS Vue.js Third Party API Content Provider Internal Editor External Editor Report Service Data Warehouse LINE TODAY Architecture ML Data Analysis
  8. CDN Object Storage In Mem Cach e Backend Server Frontend

    Server Cache Server Mini Service Feeding Service Internal CMS External CMS Vue.js Third Party API Content Provider Internal Editor External Editor Report Service Data Warehouse LINE TODAY Architecture ML Data Analysis
  9. CDN Object Storage In Mem Cach e Backend Server Frontend

    Server Cache Server Mini Service Feeding Service Internal CMS External CMS Vue.js Third Party API Content Provider Internal Editor External Editor Report Service Data Warehouse LINE TODAY Architecture ML Data Analysis
  10. • LINE TODAY and its architecture • How miniservices and

    K8S changes our development and operation • Refactor to mini services • Lessons learnt Agenda
  11. Small change requires entire system rebuild and deployment - Break

    down coarse-grained deployments into functionally cohesive mini services - Move to Kubernetes Problem Solutions How to improve development and deployment efficiency? Module Module Module Module Module Module Module Module Module Module Module Module Module deployment (eg. war file) OCI image OCI image OCI image
  12. Migrate to mini services and Kubernetes Article Service Subscription Service

    Interaction Service Frontend Server Cache Server Ingress Controller Kubernetes Web Server (VM) API Server (VM) Observability logs metrics tracing Mini Services CD
  13. • LINE TODAY and its architecture • How miniservices and

    K8S changes our development and operation • Refactor to mini services • Refine CI/CD • Lessons learnt Agenda
  14. Build and test what was changed service1 service2 libA Changing

    service1 => rebuild service1 service1 service2 libA Changing libA => rebuild libA, service1, service2 libB libB
  15. • LINE TODAY and its architecture • How miniservices and

    K8S changes our development and operation • Refactor to mini services • Refine CI/CD • Integrate with observability • Lessons learnt Agenda
  16. Observability improves operation efficiencies Article Mini Service Subscription Mini Service

    Interaction Mini Service Frontend Server Cache Server Ingress Controller Kubernetes Web Server (VM) API Server (VM) Observability logs metrics tracing Mini Services CD
  17. Troubleshooting via observability Alerts Metrics Logs Traces Logs Received alerts

    from slack Check error source and time period Inspect access logs Open trace viewer Jump to service logs of the trace Exemplars Split view with labels Metric queries Span metrics processor Trace to logs Followed Trace ID Metrics Traces Logs
  18. • LINE TODAY and its architecture • How miniservices and

    K8S changes our development and operation • Refactor to mini services • Refine CI/CD • Integrate with observability • Leverage K8S CronJob • Lessons learnt Agenda
  19. Run periodic simple tasks (java) on Kubernetes • Requirements •

    run at the specific time / interval • simple • concurrency control • running history and logs • monitor • easy to run in local and test env • Options • Spring @scheduled • Quartz • Spring Cloud Data Flow • AirFlow • K8S CronJob
  20. • LINE TODAY and its architecture • How miniservices and

    K8S changes our development and operation • Lessons learnt Agenda
  21. Issue - intermittent errors during rolling update K8S API Server

    kube-proxy kubelet Pod Worker node kube-proxy Worker node 1a delete pod 1b. remove pod from service endpoint
  22. Solution - graceful shutdown Main container process SIGTERM SIGKILL Pre-stop

    hook Container killed (if running) Container shutdown deployment manifest spring boot application.yaml • Existing services allowed to complete • No new requests permitted K8S API Server kube-proxy kubelet Pod Worker node kube-proxy Worker node delete pod remove pod from service endpoint
  23. Issue - unpredictable request spikes • pod removed from endpoint

    at 30ish seconds • fewer pods available to serve requests • requeusts queue up • pod restarted at 60ish seconds • downward spiral
  24. Options to handle request spikes - it depends • Overprovision

    • $$$$ • Auto scaling • pod - 20+ seconds • node - ~5 minutes • serverless (lambda) - seconds • Protection via ingress controller / api gateway • circuit breaker - 503 • rate-limit - 429 • Improve design
  25. • LINE TODAY and its architecture • Mini services and

    K8S helps dev / ops efficiency for large systems • Refactor to mini services • Refine CI/CD • Integrate with observability • Leverage K8S CronJob • Build in-depth DevOps and K8S skills Summary