How to Make a High Quality Node.js Application at Sigma JS Meetup
In this talk we discuss about quality of Node.js application as a collection of seven attributes: portability, reliability, efficiency, usability (human engineering), testability, understandability, and modifiability.
Docker, AWS ▰ How to split monolith into microservices 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 Last Talks: ▰ Docker for Node.js developer ▰ 5 production Node.js stories ▰ Testing in Node.js World ▰ TypeScript for Node.js applications ▰ Spec driven development in Microservices Links: Site GitHub Twitter Facebook 2
LTS version for production ▰ Use node.green for checking ECMAScript feature support in node.js version ▰ Read and reread Node.js native modules official documentation Node.js 6
for description ▰ Use .env file for local development ▰ Use environment variables for any other environment ▰ Don’t use default config values in your code ▰ Break your start process if any value is missed ▰ Use dotenv-safe
are a lot changed files ▰ File naming convention is camelCase instead of snake-case ▰ Mac OS and Ubuntu were used during development ▰ Mac OS has case insensitive filesystem ▰ Ubuntu has case sensitive filesystem
on signals 2. Log start of graceful shutdown 3. Close incoming business logic flow 4. Set a forced timeout 5. Notify consumers about shutdown 6. Correctly disconnect from all connections or mark them unref 7. Clean all timeout and intervals 8. Node.js will finish work
port ${settings.port}`); }); function stopHandler(){ logger.info(`Stopping server on port ${settings.port}`); const timeout = setTimeout(() => { logger.info(`Server on port ${settings.port} stop forcefully, not all connection was closed`); process.exit(1); }, settings.stopTimeout); server.close(() => { logger.info(`Server on port ${settings.port} stopped`); clearTimeout(timeout); }); }; process.on('exit', (code) => logger.info(`Exit with code: ${code}`)); process.on('SIGTERM', stopHandler); Graceful Shutdown Example 33
▰ response time ▰ and again response time What affects the response time: ▰ network latency ▰ Node.js event loop delay ▰ application load (so be ready to scale) ▰ processing type (use streams when they are required)