Showing posts from June, 2019

On Node.js, Go and concurrency

On Node.js, Go and concurrencyRyan Dahl, the creator of Node.js, said the following while he was talking about Node's concurrency model: [...] I think Node is not the best system to build a massive server web. I would use Go for that. And honestly, that’s the reason why I left Node. It was the realization that: oh, actually, this is not the best server-side system ever. That was strong. Why Dahl, who worked so hard to build and advocate Node.js back then, would just give up his creation and promote something else? What does that mean to Node.js and its huge community? Let's first do a quick recap.

Node.js historyNode.js was inspired on NGINX event-driven architecture non-blocking I/O. Basically it means that instead of relying on threads for concurrency (be it OS, green or coroutines), we have only one thread coordinating asynchronous work through an event loop. Dahl then built Node.js to make it happen, mixing together other facilities like a simplified web server API, V8 and Ja…

How to ...

1. How to nginx are designed and work ?
- NGINX uses an asynchronous, event‑driven approach to handling connections. - One worker process per CPU core - When an NGINX server is active, only the worker processes are busy. Each worker process handles multiple connections in a nonblocking fashion, reducing the number of context switches
- Command: ps axw -o pid,ppid,user,%cpu,vsz,wchan,command | egrep '(nginx|PID)'
- worker_processes – The number of NGINX worker processes (the default is 1). In most cases, running one worker process per CPU core works well, and we recommend setting this directive to auto to achieve that. There are times when you may want to increase this number, such as when the worker processes have to do a lot of disk I/O. - worker_connections – The maximum number of connections that each worker process can handle simultaneously. The default is 512, …

Node.js Summarization

1. What is node js

-Node.js is a javascript runtime built on Chrome's V8 javascript engine

- Js on server
global process
- Js on the browser( Chrome )

window  document

2. Why should use node js

- Node js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient
- Nodejs' package ecosystem npm is the largest ecosystem of open source libraries in the world