Javascript runtime build on Chrome's V8 Javascript engine
Javascript running on the server
Used to build powerful, fast & scalable web applications.
Uses an event-driven, non-blocking I/O model
You can build a lot with node.js like:
- REST APIs & Backend Applications
- Real-Time Services (Chat, Games, etc) -> funktioniert gut mit socket.io,
- Blogs, CMS, Social Applications
- Utilities & Tools
- Anything that is not CPU intensive
Beispiel Apache Server und PHP jeder Request mach einen neuen Thread, was System Memory braucht. Kann dazu führen, dass das Memory irgendwann voll ist. jeder Prozess muss zuerst beendet werden bevor ein neuer gestartet wird.
Node arbeitet mit einem einzelnen Thread und erlaubt uns so mit den Non-blocking I/O unzählige Verbindungen und Request gleichzeitig laufen zu lassen. Diese werden in einem Event Loop gehandelt / verwaltet -> Deswegen heisst es Event Driven System
Works on a single thread using non-blocking I/O calls
Supports tens of thousands concurrent connections
Optimizes throughput and saclability in web applications with many I/O operations
This makes Node.js apps extremly fast and efficent
Single-threaded Supports concurrency via events and callbacks EventEmitter class is used to bind events and event listeners
Beispiel Apache und PHP können nur eine Verbindung/ Request gleichzeitig haben -> synchron Node.js kann unzählige Verbindungen gleichzeitig haben -> asynchron
Stands for Node.js Package Manager Used to install node programs/ modules Easy to specify and link dependencies
Modules get installed into the node_modules folder, will be created if no one exists.
npm install express
Modules get installed into your system (global). can be used not only in our module
npm install -g express
Traversy Media - https://www.youtube.com/watch?v=U8XF6AFGqlc