low-http-server

    2.1.3 • Public • Published

    low-http-server

    Build Status NPM version
    HTTP server implementation for Node.js based on uWebSockets.js!

    Formerly part of the 0http project!

    Introduction

    low-http-server is a Node.js wrapper around the great uWebSockets.js library. Here, I/O throughput is maximized at the cost of API compatibility, when we compare it to the standard Node.js HTTP server interface.

    As far as for Node.js stands, uWebSockets.js brings the best I/O performance in terms of HTTP servers.

    const server = require('low-http-server')({})
    server.on('request', (req, res) => {
      res.end('Hello World!')
    })
    
    server.listen(3000, () => {
      console.log('Server listening on http://0.0.0.0:3000')
    })

    Or with SSL:

    const server = require('low-http-server')({
      cert_file_name: './demos/test.crt',
      key_file_name: './demos/test.key',
      passphrase: 'test'
    })
    
    server.on('request', (req, res) => {
      res.end('Hello World!')
    })
    
    server.listen(3000, () => {
      console.log('Server listening on http://0.0.0.0:3000')
    })

    Benchmarks

    Machine: MacBook Pro (13-inch, 2020), 1,4 GHz Quad-Core Intel Core i5
    Node.js version: 12.18.3

    wrk -t8 -c40 -d5s http://127.0.0.1:3000

    Take note that low-http-server does not clusterize on anything besides reasonably recent versions of Linux kernel.

    Known limitations

    • Limited compatibility with Node.js standard interface.

    Integrations

    0http framework

    const low = require('low-http-server')
    const cero = require('0http')
    
    const { router, server } = cero({
      server: low()
    })
    
    router.get('/hi', (req, res) => {
      res.end('Hello World!')
    })
    
    server.listen(3000, (socket) => {
      if (socket) {
        console.log('HTTP server ready!')
      }
    })

    Install

    npm i low-http-server

    DownloadsWeekly Downloads

    7

    Version

    2.1.3

    License

    MIT

    Unpacked Size

    10.8 kB

    Total Files

    7

    Last publish

    Collaborators

    • jkyberneees
    • schamberg97