Node.js Async: How to Use ES6 Promises

Introduction Promises are an alternative to callbacks for delivering the results of an asynchronous computation. They require more effort from implementors of asynchronous functions, but provide several benefits for users of those functions. Promises are a pattern that helps with one particular kind of asynchronous programming: a function (or method) that returns a single result …

Continue reading

[note] Nodejs Blocking vs Non-Blocking

Blocking Blocking is when the execution of additional JavaScript in the Node.js process must wait until a non-JavaScript operation completes. This happens because the event loop is unable to continue running JavaScript while a blocking operation is occurring. In Node.js, JavaScript that exhibits poor performance due to being CPU intensive rather than waiting on a non-JavaScript operation, such …

Continue reading

PHP & Nginx & Apache

Nginx Nginx works differently than Apache, mainly with regard to how it handles threads. Nginx does not create new processes for each web request, instead the administrator configures how many worker processes to create for the main Nginx process. (One rule of thumb is to have one worker process for each CPU.) Each of these …

Continue reading

Top Packages/API for Node.js

nodemon nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.   express express.js is a Node.js web application server framework, designed for building single-page, multi-page, and hybrid web applications. It is the standard server framework for node.js.   body-parser It Parses …

Continue reading

Useful commands for Linux

  netstat -tunap | grep 9000 pkill -9 php-fpm df -h du -sh file_path Explanation du (disc usage) command estimates file_path space usage The options -sh are (from man du):

To check more than one directory and see the total, use du -sch:

Continue reading