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

micro-http-server

v0.1.1

Published

http sever for micro service

Downloads

6

Readme

micro-http-server

build status GitHub license node version

NPM

在使用 Node 来构建微服务程序时,发现性能比较差。当时我们的程序是基于 Express 框架开发的,为了做对比测试,我们使用纯 Node 开发了一个 Hello World 程序,然后跟 Express 的 Hello World 做对比,发现 Express 对于性能的损耗确实比较大。但是脱离 Express 来构建我们的服务代码,还是比较不方便的,为此我们开发了这个项目,力求在实现简单的 GET / POST 请求处理能力的基础上保持程序的高性能。

适合什么

本项目适合基于 HTTP 的微服务程序开发,项目中的请求包体简单,请求者只需要传递普通 query string 或者 表单数据 来完成和服务器端的通信。

不适合什么

本项目的 POST 数据仅仅支持表单,不支持 JSON 格式,其他除表单外 POST 类型,比如说上传文件也不支持;本项目支持 GET / POST 两种 HTTP Method,如果你需要使用 RESTFull 类型的请求方式,比如说 DELETE PUT 之类的 Method,则本项目不支持。

安装

yarn add micro-http-server

使用

const http = require('http');
const Server = require('micro-http-server');

const server = new Server({routers: {
    '/': function(req, res) {
        res.send(req.query);
    },
}});
http.createServer(function(req, res) {
    server.handleRequest(req, res);
}).listen(3333);

性能测试

由于 github 自带的免费的 github action 的 runner 机器配置过低,只有 2C2G,所以我只能采用自建自己的模式来运行性能测试。目前我自己购买了一台北美的虚拟机,配置为 4C8G,CPU 型号为 Intel/CascadeLakeR。CPU 详细配置如下:

processor	: 3
vendor_id	: GenuineIntel
cpu family	: 6
model		: 85
model name	: Intel Xeon Processor (Cascadelake)
stepping	: 6
microcode	: 0x1
cpu MHz		: 2992.968
cache size	: 16384 KB
physical id	: 0
siblings	: 4
core id		: 1
cpu cores	: 2
apicid		: 3
initial apicid	: 3
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single ssbd ibrs ibpb fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 arat pku ospke avx512_vnni
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit
bogomips	: 5985.93
clflush size	: 64
cache_alignment	: 64
address sizes	: 46 bits physical, 48 bits virtual
power management:

出于基准测试的目的,当前所有的应用启动的时候,都只分配一个核的 CPU。

本项目使用 jmeter 对原生js、micro-http-server 、koa、express 进行打压,压测报告分别如下:

协议

MIT