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

@hp4k1h5/bucket_queue

v0.0.4

Published

typescript bucket queue

Downloads

11

Readme

bucket_queue

purpose

This library facilitates the maintenance of n concurrent processes.

It is best suited for cases where the number of processes to execute is potentially unlimited. For example, web crawlers may have an infinite number of webpages to crawl. Maintaining a steady number of concurrent requests allows for smooth overall request distribution and can prevent very long requests from halting the overall program flow.

usage

The primary export supervise accepts an array of async functions, or a function returning an array of async functions. supervise will execute these concurrently up to the max concurrency limit, replenishing the active execution queue sequentially from the array of requests provided to the asynchronous queue manager, an async generator function.

await supervise(queue, 20)

The process underneath is roughly:

  1. The queue provides an array or series of arrays to the queue manager
  2. the queue manager feeds them, one-by-one to the bucket supervisor`
  3. the bucket supervisor maintains up to the max number of simultaneous processes

See src/example.js

Finding the right max for concurrent processes will be system and workload dependent. In cpu intensive workloads, it might be best to limit max concurrent to the number of cores available to the program. In request based workloads, the network latency might allow for thousands of concurrent requests on relatively modest architectures.

For example, these tests demonstrate the relative potential of various workloads.

Observational Results of random sleeps

100 "requests" / 10 workers * Math.random() * 50ms sleep
 ~= 250ms total runtime
1,000 "requests" / 100 workers * Math.random() * 50 ms sleep
 ~= 250ms total runtime

You can theoretically execute 1,000 calls as fast as 100, provided you also increase the concurrent worker pool to 100 concurrent workers. Also, you can limit overall resource usage.

Usage

Run a demonstration example.js:

yarn example

Caveats

Actual usage with network latency type response time distribution would likely show different results.

The test examples are void of any real work being done, and as such, the tests are not indicative of what actual results would show in a live environment under load. In general, if this package is used

I have not experimented with it much beyond the examples in the test cases and example.js.