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 🙏

© 2026 – Pkg Stats / Ryan Hefner

p2p-k6

v0.0.5

Published

### Yêu cầu

Readme

K6 testing

Yêu cầu

Cài đặt GitDocker & Docker-compose

Sử dụng

Bạn cần copy file example.config.js (trong thư mục scripts/config) và đổi tên thành config.js. Bạn có thể thay đổi các tùy chọn trong file config.js.

Mở Terminal (hoặc Command Prompt trên Window), chuyển đến thư mục này (k6)

cd stress-test/k6

Chạy InfluxDB + Grafana Docker containers bằng lệnh sau:

docker-compose up -d influxdb grafana

Bây giờ có thể chạy stress test bằng lệnh:

docker-compose run k6 run ./scripts/<FILE_NAME>.js

Cấu hình kịch bản test

Có thể cấu hình kịch bản test trong file config.js.

Ví dụ:

stages: [
    { duration: '10s', target: 100 }, // below normal load
    { duration: '1m', target: 100 },
    { duration: '10s', target: 1400 }, // spike to 1400 users
    { duration: '3m', target: 1400 }, // stay at 1400 for 3 minutes
    { duration: '10s', target: 100 }, // scale down. Recovery stage.
    { duration: '2m', target: 100 },
    { duration: '10s', target: 0 },
  ]

Ghi chú:

  • duration: thời gian
  • target: số lượng user ảo (Virtual User)
  • VUs: Số lượng Vus đồng thời

Kịch bản test trên bắt đầu với khoảng thời gian 1 phút và 100 user ảo, tăng đột biến nhanh đến 1400 user ảo duy trì trong 3 phút, sau đó trở lại 100 user ảo để kiểm tra khả năng phục hồi của server.

Xem kết quả test

Truy cập http://localhost:3000 (đường dẫn của Grafana) từ trình duyệt.

Trên thanh menu bên trái, chọn Dashboards >> Manage >> chọn k6 Load Testing Results.

Bạn nên chọn thời gian bắt đầu và kết thúc test (Absolute time range) ở góc trên bên phải để xem kết quả chính xác hơn.


Bạn có thể thay đổi cấu hình cho Grafana trong file docker-compose.yml

grafana:
    ...
    ports:
      - "3088:3000"

Test scripts

I. POST /api/invoice

Thực hiện việc gửi Invoice API về team-server

Short script:

docker-compose run k6 run ./scripts/addInvoicesAPIStressTest.js -e BASE_URL=testURL -e ACCESS_TOKEN=token

Kịch bản test trên bắt đầu với 5000 invoice một lúc sau đó tắt và kết nối lại database để kiểm tra số lượng invoice có thể đợi ở Queues và insert đầy đủ vào database

Environment variables

  • BASE_URL (default: "http://host.docker.internal:3000")

Tham khảo