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

Node.js Recipes: Road to Production.

Node.js Recipes: Road to Production.

In IT, the terms Day 0/Day 1/Day 2 refer to different phases of the software development life cycle. During this talk, Nikita will show recipes for each day:

For day 0 (design and PoC) – how to choose tech stack and design API.
For day 1 (development and deploying) – how to test application, dockerize and configure.
For day 2 (maintaining and monitoring) – how to collect logs& metrics and create business reports.

Nikita Galkin

May 23, 2021
Tweet

More Decks by Nikita Galkin

Other Decks in Programming

Transcript

  1. Road to Production
    by Nikita Galkin
    May 23, 2021

    View Slide

  2. Nikita
    Galkin
    Love and Know:
    ▰ How to make developers and business happy
    ▰ Technical and process debt elimination
    Believe that:
    ▰ Any problem must be solved at the right level
    ▰ Software is easy. People are hard
    ▰ A problem should be highlighted, an idea should
    be "sold", a solution should be demonstrated
    Links:
    Site GitHub Twitter Facebook
    2

    View Slide

  3. ▰ Cloud Native, k8s, etc
    ▰ Google Cloud Study Jams
    ▰ Case studies
    ▰ Telegram channel, daily
    ▰ Voice chat, weekly
    ▰ Workshops, coming soon

    View Slide

  4. MAIN IDEA

    View Slide

  5. Understand Software
    Development Life Cycle
    and know what to do
    at every phase

    View Slide

  6. SDLC and
    Day 0, 1, 2

    View Slide

  7. View Slide

  8. very general and
    therefore useless

    View Slide

  9. View Slide

  10. Day 0:
    Design

    View Slide

  11. Day 0 activities:
    ▰ Requirements analysis
    ▰ Domain terms definition
    ▰ Architecture creation
    ▰ Choosing a technical stack

    View Slide

  12. Requirements analysis:
    ▰ Milestones
    ▰ User stories:
    As a
    I want
    So that
    ▰ No-functional requirements

    View Slide

  13. Domain terms definition:
    ▰ Term definition starts with noun
    ▰ Team knows Single Source of
    Truth of this definition list
    ▰ Used at access-control list
    ▰ Subset exists at API
    specification

    View Slide

  14. Architecture & Tech Stack
    ▰ What architecture approach use?
    ▰ Is Node.js right tool?
    ▰ What DB and why?
    ▰ What protocol chose for API?
    ▰ How host Node.js?

    View Slide

  15. How host Node.js?
    ▰ Virtual machine
    ▰ Docker
    ▰ Kubernetes
    ▰ Serverless
    ▰ Cloud Native

    View Slide

  16. How host Node.js?
    ▰ Virtual machine
    ▰ Docker
    ▰ Kubernetes
    ▰ Serverless
    ▰ Cloud Native

    View Slide

  17. PM2

    View Slide

  18. View Slide

  19. View Slide

  20. Cloud
    Native

    View Slide

  21. View Slide

  22. View Slide

  23. Day 1:
    Start
    development

    View Slide

  24. Day 1 activities:
    ▰ package.json content
    ▰ Code style
    ▰ Setup environments
    ▰ API specification
    ▰ Testing framework
    ▰ Setup CI/CD

    View Slide

  25. package.json content:
    ▰ CommonJS or ECMAScript
    modules
    ▰ How write code: without or
    with transpiling (babel or ts)
    ▰ What code patterns?
    ▰ Internal (set of packages) or
    open-source framework

    View Slide

  26. JS or TS?

    View Slide

  27. View Slide

  28. Codestyle:
    ▰ .editorconfig
    ▰ prettier
    ▰ eslint
    ▰ custom eslint rules
    ▰ IDEA settings
    ▰ git hooks with husky
    and lint-staged

    View Slide

  29. View Slide

  30. Setup environments:
    ▰ Follow 12 factor manifest
    ▰ DevOps Engineer with IoC
    setup environment
    ▰ Local env setup with
    docker-compose
    and npm install

    View Slide

  31. Typical 12 factor manifest
    mistakes:
    ▰ EventEmitter for business logic
    ▰ Hardcoded or default config
    values
    ▰ Bootstrap without graceful
    shutdown

    View Slide

  32. Human or/add computer readable
    API specification:
    ▰ Swagger
    ▰ gRPC
    ▰ GraphQL
    How will it evolve?

    View Slide

  33. Day 1:
    Setup CI/CD

    View Slide

  34. Artefact
    Repo

    View Slide

  35. View Slide

  36. Day 2:
    Going life

    View Slide

  37. Day 2 activities:
    ▰ Setup logging
    ▰ Monitoring and alerting
    ▰ Business metrics collection
    and reports creation
    ▰ Admin panel creation

    View Slide

  38. Logging:
    ▰ Use JSON for production and
    human readable for local
    ▰ Use LOG_LEVEL
    ▰ Logging manifest
    ▰ Only stdout
    and stderr

    View Slide

  39. stdout stderr

    View Slide

  40. stdout stderr

    View Slide

  41. Monitoring and alerting:
    ▰ Node.js metrics (event-loop, http
    response time)
    ▰ Infrastructure state and metrics
    ▰ Business metrics
    ▰ Some services (Pingdom,
    GCP alerting, Pager Duty, etc)

    View Slide

  42. Day 2:
    Business metrics
    collection and
    reports creation

    View Slide

  43. View Slide

  44. Day 2:
    Admin panel

    View Slide

  45. Admin panel creation:
    ▰ Limit DB and 3rd party access
    ▰ Integration with BI tools
    ▰ Specific solutions like
    ▻ Admin bro
    ▻ React Admin
    ▻ cube.dev

    View Slide

  46. MAIN IDEA

    View Slide

  47. Understand Software
    Development Life Cycle
    and know what to do
    at every phase

    View Slide

  48. QUESTIONS TIME!
    Waiting for you
    at Speakers' Corner
    and
    at the channel ➡

    View Slide