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 full-size 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 full-size slide

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

    View full-size slide

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

    View full-size slide

  5. SDLC and
    Day 0, 1, 2

    View full-size slide

  6. very general and
    therefore useless

    View full-size slide

  7. Day 0:
    Design

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  10. 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 full-size slide

  11. 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 full-size slide

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

    View full-size slide

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

    View full-size slide

  14. Day 1:
    Start
    development

    View full-size slide

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

    View full-size slide

  16. 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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  21. Day 1:
    Setup CI/CD

    View full-size slide

  22. Artefact
    Repo

    View full-size slide

  23. Day 2:
    Going life

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  26. stdout stderr

    View full-size slide

  27. stdout stderr

    View full-size slide

  28. 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 full-size slide

  29. Day 2:
    Business metrics
    collection and
    reports creation

    View full-size slide

  30. Day 2:
    Admin panel

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide