You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-13Lines changed: 35 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,26 +1,40 @@
1
-
**µWebSockets.js** is a JavaScript platform, runtime and web server built on [µWebSockets](https://github.com/uNetworking/uWebSockets) v0.15 and V8.
1
+
<divalign="center">
2
+
<imgsrc="misc/logo.svg"height="180" />
2
3
3
-
There are two modes; compiled as a stand-alone JavaScript runtime or as a Node.js native addon.
4
+
*µWebSockets™ (it's "[micro](https://en.wikipedia.org/wiki/Micro-)") is simple, secure & standards compliant web I/O for the most demanding*<sup>[[1]](benchmarks)</sup> *of applications.*
4
5
5
-
For the most common Node.js systems are available precompiled binaries:
6
+
• [Read more](misc/READMORE.md)
7
+
8
+
</div>
9
+
10
+
11
+
### NPM install
12
+
While not physically hosted by NPM, it's still possible to install using NPM tools like so (or any such version):
Every other week a new "web framework" pops up for Node.js. Fastify, Restana, Aero, Micro and so on. Most aim to improve I/O performance, but fall flat. You can't fix an inherent design flaw of an entire stack just by slapping a few lines of JavaScript on top.
12
20
13
-
```javascript
14
-
/* The stand-alone runtime has uWS namespace already loaded. */
15
-
var uWS = uWS ? uWS :require('../dist/uws.js');
21
+
µWS.js is a 100% C/C++ web platform completely bypassing the entire Node.js I/O stack. JavaScript-exposed functions and objects are entirely backed by native code all the way down to the OS kernel. This makes it possible to reach unprecedented I/O performance from within Node.js (or any stand-alone V8 build). Scroll down for benchmarks.
16
22
17
-
constworld='Strings are slower than ArrayBuffer but who cares for demo purose!';
23
+
##### In a nutshell
24
+
```javascript
25
+
constuWS=require('uWebSockets.js');
18
26
constport=3000;
19
27
20
-
uWS.App().get('/hello', (res, req) => {
21
-
res.end(world);
28
+
uWS.SSLApp({
29
+
/* cert, key and such specified here, or use uWS.App */
30
+
}).get('/whatsmyuseragent', (res, req) => {
31
+
res.writeHeader(
32
+
'content-type', 'text/html; charset= utf-8'
33
+
).end(
34
+
'Your user agent is: '+req.getHeader('user-agent')
35
+
);
22
36
}).get('/*', (res, req) => {
23
-
res.writeHeader('content-type', 'text/html; charset= utf-8').end(req.getHeader('user-agent') +' är din user agent, biatch!');
Proper streaming of huge data is supported over Http/Https and demonstrated with examples. Here's a shot of me watching real-time streamed HD video from Node.js while simultaneously scoring a 115k req/sec with wrk. For my computer, that's about 5x that of vanilla Node.js (without any HD video streaming/playing).
49
+
50
+

51
+
33
52
### Benchmarks
34
-
Performance retention is up to 75% of native C++ [µWebSockets](https://github.com/uNetworking/uWebSockets) v0.15. That puts it some 20x as fast as Deno and even faster than most C++-only servers, all from within a JavaScript VM.
Performance retention is about 65% that of the native C++ [µWebSockets](https://github.com/uNetworking/uWebSockets) v0.15. That makes it some 20x as fast as Deno and even faster than most C++-only servers, all from within a JavaScript VM.
0 commit comments