npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kore/http

v0.3.1

Published

Blazing fast low level http server

Downloads

1

Readme

turbo-http


This is a fork that can be installed via @kore/http. It brings the SO_REUSEPORT cluster hack for Linux, resulting in up to 2x more r/s numbers in benchmarks (can't be tested properly with autocannon in some cases, might need to use wrk).

build status


A low level http library for Node.js based on turbo-net

npm i turbo-http

WIP, this module is already really fast but there are some HTTP features missing and easy performance gains to be had. :D :D :D

On my laptop I can serve simple hello world payloads at around 100k requests/seconds compared to 10k requests/second using node core.

Usage

const turbo = require('turbo-http')

const server = turbo.createServer(function (req, res) {
  res.setHeader('Content-Length', '11')
  res.write(Buffer.from('hello world'))
})

server.listen(8080)

API

server = turbo.createServer([onrequest])

Create a new http server. Inherits from the turbo-net tcp server

server.on('request', req, res)

Emitted when a new http request is received.

res.statusCode = code

Set the http status

res.setHeader(name, value)

Set a http header

res.write(buf, [length], [callback])

Write a buffer. When the callback is called, the buffer has been completely flushed to the underlying socket and is safe to reuse for other purposes

res.writev(buffers, [lengths], [callback])

Write more that one buffer at once.

res.end([buf], [length], [callback])

End the request. Only needed if you do not provide a Content-Length.

req.url

Request url

req.method

Request method

req.socket

Request turbo-net socket

value = req.getHeader(name)

Get a request header.

headers = req.getAllHeaders()

Get all request headers as a map.

req.ondata(buffer, start, length)

Called when there is data read. If you use the buffer outside of this function you should copy it.

req.onend()

Called when the request is fully read.

Benchmarks

Comparing turbo-http to other frameworks is like comparing oranges to apples. turbo-http could be thought of as a replacement of Node's native http module, while all available frameworks actually use it.

Benchmark it:

  • clone this repo,
  • npm i
  • npm run bench

Benchmark averages are taken after one warm-up round.

  | Requests/s | Latency | Throughput/Mb ------------- | ---------- | ------- | -------------- turbo-http.js | 32592 | 3.03 | 2.43 bare-node.js | 18396 | 5.32 | 1.98 rayo.js | 16249.6 | 6.03 | 1.77 polka.js | 15802.4 | 6.2 | 1.71 fastify.js | 15141.6 | 6.47 | 2.26 express.js | 13408.8 | 7.31 | 1.46 hapi.js | 9675.6 | 10.15 | 1.42

Note: Nevermind these numbers, this benchmark was run on a slow computer and the above table is for illustrative purposes only.

Optionally, you may also define your test's parameters:

$> npm run bench -- -u http://localhost:5050 -c 100 -p 10 -d 5
  • -u (url) -Defaults to http://localhost:5050
  • -c (connections) -Defaults to 100
  • -p (pipelines) -Defaults to 10
  • -d (duration) -Defaults to 5 (seconds)

Acknowledgements

This project was kindly sponsored by nearForm.

License

MIT