Skip to content

Commit eb03bb9

Browse files
committed
Update README and multi_bench
1 parent a2ebe4f commit eb03bb9

File tree

2 files changed

+148
-100
lines changed

2 files changed

+148
-100
lines changed

README.md

+106-44
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
11
redis - a node.js redis client
22
===========================
33

4-
This is a complete Redis client for node.js. It supports all Redis commands, including many recently added commands like EVAL from
5-
experimental Redis server branches.
6-
4+
This is a complete Redis client for node.js. It supports all Redis commands,
5+
including many recently added commands like EVAL from experimental Redis server
6+
branches.
77

88
Install with:
99

1010
npm install redis
1111

12-
Pieter Noordhuis has provided a binding to the official `hiredis` C library, which is non-blocking and fast. To use `hiredis`, do:
13-
14-
npm install hiredis redis
15-
16-
If `hiredis` is installed, `node_redis` will use it by default. Otherwise, a pure JavaScript parser will be used.
17-
18-
If you use `hiredis`, be sure to rebuild it whenever you upgrade your version of node. There are mysterious failures that can
19-
happen between node and native code modules after a node upgrade.
20-
21-
2212
## Usage
2313

2414
Simple example, included as `examples/simple.js`:
@@ -57,34 +47,9 @@ This will display:
5747
1: hashtest 2
5848
mjr:~/work/node_redis (master)$
5949

60-
61-
## Performance
62-
63-
Here are typical results of `multi_bench.js` which is similar to `redis-benchmark` from the Redis distribution.
64-
It uses 50 concurrent connections with no pipelining.
65-
66-
JavaScript parser:
67-
68-
PING: 20000 ops 42283.30 ops/sec 0/5/1.182
69-
SET: 20000 ops 32948.93 ops/sec 1/7/1.515
70-
GET: 20000 ops 28694.40 ops/sec 0/9/1.740
71-
INCR: 20000 ops 39370.08 ops/sec 0/8/1.269
72-
LPUSH: 20000 ops 36429.87 ops/sec 0/8/1.370
73-
LRANGE (10 elements): 20000 ops 9891.20 ops/sec 1/9/5.048
74-
LRANGE (100 elements): 20000 ops 1384.56 ops/sec 10/91/36.072
75-
76-
hiredis parser:
77-
78-
PING: 20000 ops 46189.38 ops/sec 1/4/1.082
79-
SET: 20000 ops 41237.11 ops/sec 0/6/1.210
80-
GET: 20000 ops 39682.54 ops/sec 1/7/1.257
81-
INCR: 20000 ops 40080.16 ops/sec 0/8/1.242
82-
LPUSH: 20000 ops 41152.26 ops/sec 0/3/1.212
83-
LRANGE (10 elements): 20000 ops 36563.07 ops/sec 1/8/1.363
84-
LRANGE (100 elements): 20000 ops 21834.06 ops/sec 0/9/2.287
85-
86-
The performance of `node_redis` improves dramatically with pipelining, which happens automatically in most normal programs.
87-
50+
Note that the API is entire asynchronous. To get data back from the server,
51+
you'll need to use a callback. The return value from most of the API is a
52+
backpressure indicator.
8853

8954
### Sending Commands
9055

@@ -658,6 +623,105 @@ client.zadd(args, function (err, response) {
658623
});
659624
```
660625

626+
## Performance
627+
628+
Much effort has been spent to make `node_redis` as fast as possible for common
629+
operations. As pipelining happens naturally from shared connections, overall
630+
efficiency goes up.
631+
632+
Here are typical results of `multi_bench.js` which is similar to
633+
`redis-benchmark` from the Redis distribution. It uses 5 concurrent connections
634+
and shows the difference between pipelines of 1 and 50.
635+
636+
JavaScript parser:
637+
638+
Client count: 5, node version: 0.10.32, server version: 2.8.18, parser: javascript
639+
PING, 1/5 min/max/avg/p95: 0/ 3/ 0.05/ 1.00 1103ms total, 18132.37 ops/sec
640+
PING, 50/5 min/max/avg/p95: 0/ 4/ 0.81/ 2.00 327ms total, 61162.08 ops/sec
641+
SET 4B str, 1/5 min/max/avg/p95: 0/ 2/ 0.05/ 0.00 1104ms total, 18115.94 ops/sec
642+
SET 4B str, 50/5 min/max/avg/p95: 0/ 3/ 0.83/ 2.00 333ms total, 60060.06 ops/sec
643+
SET 4B buf, 1/5 min/max/avg/p95: 0/ 2/ 0.09/ 1.00 1876ms total, 10660.98 ops/sec
644+
SET 4B buf, 50/5 min/max/avg/p95: 0/ 11/ 2.55/ 4.00 1025ms total, 19512.20 ops/sec
645+
GET 4B str, 1/5 min/max/avg/p95: 0/ 1/ 0.05/ 1.00 1117ms total, 17905.10 ops/sec
646+
GET 4B str, 50/5 min/max/avg/p95: 0/ 3/ 0.87/ 2.00 347ms total, 57636.89 ops/sec
647+
GET 4B buf, 1/5 min/max/avg/p95: 0/ 1/ 0.05/ 1.00 1110ms total, 18018.02 ops/sec
648+
GET 4B buf, 50/5 min/max/avg/p95: 0/ 2/ 0.85/ 2.00 342ms total, 58479.53 ops/sec
649+
SET 4KiB str, 1/5 min/max/avg/p95: 0/ 1/ 0.05/ 1.00 1119ms total, 17873.10 ops/sec
650+
SET 4KiB str, 50/5 min/max/avg/p95: 0/ 3/ 0.89/ 2.00 358ms total, 55865.92 ops/sec
651+
SET 4KiB buf, 1/5 min/max/avg/p95: 0/ 1/ 0.09/ 1.00 1894ms total, 10559.66 ops/sec
652+
SET 4KiB buf, 50/5 min/max/avg/p95: 0/ 7/ 2.57/ 4.00 1031ms total, 19398.64 ops/sec
653+
GET 4KiB str, 1/5 min/max/avg/p95: 0/ 6/ 0.06/ 1.00 1248ms total, 16025.64 ops/sec
654+
GET 4KiB str, 50/5 min/max/avg/p95: 0/ 3/ 1.03/ 2.00 415ms total, 48192.77 ops/sec
655+
GET 4KiB buf, 1/5 min/max/avg/p95: 0/ 1/ 0.06/ 1.00 1177ms total, 16992.35 ops/sec
656+
GET 4KiB buf, 50/5 min/max/avg/p95: 0/ 10/ 1.02/ 2.00 409ms total, 48899.76 ops/sec
657+
INCR, 1/5 min/max/avg/p95: 0/ 2/ 0.05/ 0.55 1137ms total, 17590.15 ops/sec
658+
INCR, 50/5 min/max/avg/p95: 0/ 2/ 0.85/ 2.00 343ms total, 58309.04 ops/sec
659+
LPUSH, 1/5 min/max/avg/p95: 0/ 1/ 0.06/ 1.00 1143ms total, 17497.81 ops/sec
660+
LPUSH, 50/5 min/max/avg/p95: 0/ 3/ 0.87/ 2.00 350ms total, 57142.86 ops/sec
661+
LRANGE 10, 1/5 min/max/avg/p95: 0/ 2/ 0.06/ 1.00 1283ms total, 15588.46 ops/sec
662+
LRANGE 10, 50/5 min/max/avg/p95: 0/ 3/ 1.12/ 2.00 449ms total, 44543.43 ops/sec
663+
LRANGE 100, 1/5 min/max/avg/p95: 0/ 1/ 0.09/ 1.00 1932ms total, 10351.97 ops/sec
664+
LRANGE 100, 50/5 min/max/avg/p95: 0/ 5/ 2.46/ 4.00 985ms total, 20304.57 ops/sec
665+
SET 4MiB buf, 1/5 min/max/avg/p95: 1/ 4/ 1.37/ 2.00 691ms total, 723.59 ops/sec
666+
SET 4MiB buf, 50/5 min/max/avg/p95: 3/ 166/ 57.66/ 116.00 601ms total, 831.95 ops/sec
667+
GET 4MiB str, 1/5 min/max/avg/p95: 84/ 110/ 93.18/ 106.95 9320ms total, 10.73 ops/sec
668+
GET 4MiB str, 50/5 min/max/avg/p95: 156/7375/3400.10/6840.40 8928ms total, 11.20 ops/sec
669+
GET 4MiB buf, 1/5 min/max/avg/p95: 84/ 105/ 91.21/ 99.00 9129ms total, 10.95 ops/sec
670+
GET 4MiB buf, 50/5 min/max/avg/p95: 424/5704/3518.94/5626.65 9145ms total, 10.93 ops/sec
671+
672+
If you use very large responses in your application, the JavaScript parser
673+
performs badly. Until the JS parser is fixed, you can use the C-based `hiredis`
674+
parser bound to the official `hiredis` C library. To use `hiredis`, do:
675+
676+
npm install hiredis redis
677+
678+
If the `hiredis` npm module is installed, `node_redis` will use it by default.
679+
Otherwise, the pure JavaScript parser will be used.
680+
681+
If you use `hiredis`, be sure to rebuild it whenever you upgrade your version of
682+
node. There are mysterious failures that can happen between node and native
683+
code modules after a node upgrade.
684+
685+
Most users find that the JS parser is faster than the `hiredis` parser. Because
686+
of the pain associated with upgrading native code modules, you should only use
687+
`hiredis` if your application needs it.
688+
689+
hiredis parser:
690+
691+
Client count: 5, node version: 0.10.32, server version: 2.8.18, parser: hiredis
692+
PING, 1/5 min/max/avg/p95: 0/ 3/ 0.05/ 1.00 1092ms total, 18315.02 ops/sec
693+
PING, 50/5 min/max/avg/p95: 0/ 5/ 0.87/ 2.00 347ms total, 57636.89 ops/sec
694+
SET 4B str, 1/5 min/max/avg/p95: 0/ 2/ 0.06/ 1.00 1151ms total, 17376.19 ops/sec
695+
SET 4B str, 50/5 min/max/avg/p95: 0/ 3/ 0.83/ 2.00 334ms total, 59880.24 ops/sec
696+
SET 4B buf, 1/5 min/max/avg/p95: 0/ 3/ 0.09/ 1.00 1932ms total, 10351.97 ops/sec
697+
SET 4B buf, 50/5 min/max/avg/p95: 0/ 9/ 2.64/ 4.00 1059ms total, 18885.74 ops/sec
698+
GET 4B str, 1/5 min/max/avg/p95: 0/ 1/ 0.06/ 0.00 1185ms total, 16877.64 ops/sec
699+
GET 4B str, 50/5 min/max/avg/p95: 0/ 3/ 0.85/ 2.00 341ms total, 58651.03 ops/sec
700+
GET 4B buf, 1/5 min/max/avg/p95: 0/ 1/ 0.06/ 0.00 1179ms total, 16963.53 ops/sec
701+
GET 4B buf, 50/5 min/max/avg/p95: 0/ 3/ 0.85/ 2.00 340ms total, 58823.53 ops/sec
702+
SET 4KiB str, 1/5 min/max/avg/p95: 0/ 1/ 0.06/ 1.00 1210ms total, 16528.93 ops/sec
703+
SET 4KiB str, 50/5 min/max/avg/p95: 0/ 3/ 0.93/ 2.00 372ms total, 53763.44 ops/sec
704+
SET 4KiB buf, 1/5 min/max/avg/p95: 0/ 1/ 0.10/ 1.00 1967ms total, 10167.77 ops/sec
705+
SET 4KiB buf, 50/5 min/max/avg/p95: 0/ 6/ 2.63/ 4.00 1053ms total, 18993.35 ops/sec
706+
GET 4KiB str, 1/5 min/max/avg/p95: 0/ 6/ 0.06/ 1.00 1176ms total, 17006.80 ops/sec
707+
GET 4KiB str, 50/5 min/max/avg/p95: 0/ 4/ 1.00/ 2.00 399ms total, 50125.31 ops/sec
708+
GET 4KiB buf, 1/5 min/max/avg/p95: 0/ 1/ 0.06/ 1.00 1158ms total, 17271.16 ops/sec
709+
GET 4KiB buf, 50/5 min/max/avg/p95: 0/ 3/ 0.99/ 2.00 398ms total, 50251.26 ops/sec
710+
INCR, 1/5 min/max/avg/p95: 0/ 1/ 0.05/ 0.00 1112ms total, 17985.61 ops/sec
711+
INCR, 50/5 min/max/avg/p95: 0/ 3/ 0.84/ 2.00 339ms total, 58997.05 ops/sec
712+
LPUSH, 1/5 min/max/avg/p95: 0/ 1/ 0.05/ 1.00 1131ms total, 17683.47 ops/sec
713+
LPUSH, 50/5 min/max/avg/p95: 0/ 3/ 0.86/ 2.00 345ms total, 57971.01 ops/sec
714+
LRANGE 10, 1/5 min/max/avg/p95: 0/ 1/ 0.06/ 1.00 1228ms total, 16286.64 ops/sec
715+
LRANGE 10, 50/5 min/max/avg/p95: 0/ 3/ 0.95/ 2.00 382ms total, 52356.02 ops/sec
716+
LRANGE 100, 1/5 min/max/avg/p95: 0/ 1/ 0.08/ 1.00 1567ms total, 12763.24 ops/sec
717+
LRANGE 100, 50/5 min/max/avg/p95: 0/ 6/ 1.68/ 3.00 675ms total, 29629.63 ops/sec
718+
SET 4MiB buf, 1/5 min/max/avg/p95: 1/ 4/ 1.37/ 2.00 692ms total, 722.54 ops/sec
719+
SET 4MiB buf, 50/5 min/max/avg/p95: 3/ 183/ 57.79/ 125.00 605ms total, 826.45 ops/sec
720+
GET 4MiB str, 1/5 min/max/avg/p95: 5/ 16/ 8.14/ 12.95 816ms total, 122.55 ops/sec
721+
GET 4MiB str, 50/5 min/max/avg/p95: 24/ 323/ 202.98/ 309.00 519ms total, 192.68 ops/sec
722+
GET 4MiB buf, 1/5 min/max/avg/p95: 6/ 13/ 8.01/ 11.95 802ms total, 124.69 ops/sec
723+
GET 4MiB buf, 50/5 min/max/avg/p95: 16/ 480/ 203.85/ 435.70 531ms total, 188.32 ops/sec
724+
661725
## TODO
662726

663727
Better tests for auth, disconnect/reconnect, and all combinations thereof.
@@ -674,7 +738,7 @@ I think there are more performance improvements left in there for smaller values
674738
comment again with indignation!)
675739

676740
## Contributors
677-
Some people have have added features and fixed bugs in `node_redis` other than me.
741+
Many people have have added features and fixed bugs in `node_redis`.
678742

679743
Ordered by date of first contribution.
680744
[Auto-generated](http://github.com/dtrejo/node-authors) on Wed Jul 25 2012 19:14:59 GMT-0700 (PDT).
@@ -740,5 +804,3 @@ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
740804
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
741805
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
742806
OTHER DEALINGS IN THE SOFTWARE.
743-
744-
![spacer](http://ranney.com/1px.gif)

0 commit comments

Comments
 (0)