https://github.com/emanuelcasco/http-packages-benchmark
🌎 HTTP clients research for TypeScript Node.js applications
https://github.com/emanuelcasco/http-packages-benchmark
Last synced: 4 months ago
JSON representation
🌎 HTTP clients research for TypeScript Node.js applications
- Host: GitHub
- URL: https://github.com/emanuelcasco/http-packages-benchmark
- Owner: emanuelcasco
- Created: 2019-12-03T17:25:50.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-11T15:50:40.000Z (almost 3 years ago)
- Last Synced: 2025-03-17T10:42:55.747Z (8 months ago)
- Language: TypeScript
- Homepage:
- Size: 623 KB
- Stars: 17
- Watchers: 1
- Forks: 5
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🌎 HTTP Clients benchmark
## Libraries
- [got](https://github.com/sindresorhus/got): Human-friendly and powerful HTTP request library for Node.js.
- [request-promise](https://github.com/request/request-promise): Simplified HTTP request client 'request' with Promise support. Powered by Bluebird. _DEPRECATED_.
- [node-fetch](https://github.com/bitinn/node-fetch): A light-weight module that brings window.fetch to Node.js.
- [axios](https://github.com/axios/axios): Promise based HTTP client for the browser and Node.js.
- [bent](https://github.com/mikeal/bent): Functional HTTP client for Node.js and Browsers w/ async/await.
- [apisauce](https://github.com/infinitered/apisauce): Axios + standardized errors + request/response transforms.
## Packages comparison
request-promise
node-fetch
axios
got
bent
apisauce
Downloads
2M/month
11M/month
6M/month
34M/month
5K/month
54K/month
Dependencies
7
0
3
15
3
2
Minzipped size
246.4KB *
282B
4.3KB
18.4KB
805B
9.5KB
Created at
Oct 4, 2013
Jan 26, 2015
Aug 18, 2014
Mar 27, 2014
Nov 7, 2017
Apr 9, 2016
_* **Note:** request-promise has [request](https://github.com/request/request) as peer dependency. So this is the summatory of both packages sizes: 179.8KB + 66.6KB_
## Features
request-promise
node-fetch
axios
got
bent
apisauce
HTTP/2 support
❌
❌
❌
❌
❌
❌
Instances creation
❌
❌
✅
✅
✅
✅
Promise API
✅
✅
✅
✅
✅
✅
Stream API
✅
✅
✅
✅
✅
✅
Request cancelation
❌
✅
❌
✅
❌
❌
RFC compliant caching
❌
❌
❌
✅
❌
❌
Cookies (out-of-box)
✅
❌
❌
✅
❌
❌
Follows redirects
✅
✅
✅
✅
✅
✅
Retries on failure
❌
❌
❌
✅
❌
❌
Handles gzip/deflate
✅
✅
✅
✅
✅
✅
Advanced timeouts
❌
❌
❌
✅
❌
❌
JSON mode
✅
✅
✅
✅
✅
✅
Composable
❌
❌
❌
✅
✅
❌
Hooks
❌
❌
✅
✅
❌
❌
* _Based on table from [got repository](https://github.com/sindresorhus/got#comparison)._
## Performance
Use autocannon for stress tests:
```bash
autocannon -c 100 -d 20 -m \"GET\" --json 'localhost:8080/'
```
You can also run several tests using:
```bash
for i in {1..10}; do t -- 'localhost:8080/axios' >> ./benchmark_results/axios.json; sleep 5; done \
for i in {1..10}; do t -- 'localhost:8080/apisauce' >> ./benchmark_results/apisauce.json; sleep 5; done \
&& for i in {1..10}; do t -- 'localhost:8080/fetch' >> ./benchmark_results/fetch.json; sleep 5; done \
&& for i in {1..10}; do t -- 'localhost:8080/got' >> ./benchmark_results/got.json; sleep 5; done \
&& for i in {1..10}; do t -- 'localhost:8080/rp' >> ./benchmark_results/rp.json; sleep 5; done \
&& for i in {1..10}; do t -- 'localhost:8080/bent' >> ./benchmark_results/bent.json; sleep 5; done
```
### Requests
Package
AVG Req/Sec
MIN Req/Sec
MAX Req/Sec
Total Req
BENT
356.26
150.45
531.73
7125.09
AXIOS
245.76
162.18
318.18
4915.27
FETCH
333.62
134.27
524.18
6672.45
GOT
328.77
156.09
475.73
6575.36
RP
266.63
197.27
319.27
5332.64
APISAUCE
253.05
167.55
321.55
5061.09

### Latency
Package
Latency AVG (ms)
Latency MIN (ms)
Latency MAX (ms)
BENT
291.89
21.45
5386.92
AXIOS
401.57
23.09
7887.79
FETCH
305.73
21.45
6512.33
GOT
314.17
28.45
6127.15
RP
355.15
26.45
7946.91
APISAUCE
371.74
24.64
7714.74

### Throughput
Package
Throughput AVG (bytes/sec)
Throughput MIN (bytes/sec)
Throughput MAX (bytes/sec)
Throughput total (bytes)
BENT
2546458.76
1075449.09
3800786.55
50930149.82
AXIOS
1756666.76
1159275.64
2274363.64
35134369.45
FETCH
2384680.15
959781.45
3746851.64
47694705.09
GOT
2350034.62
1115737.82
3400498.55
47000699.27
RP
1905893.82
1410105.45
2282161.45
38117684.73
APISAUCE
1808838.69
1197614.91
2298406.91
36176677.82