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

microfrontier

v1.0.2

Published

A web crawler frontier implementation in TypeScript backed by Redis. MicroFrontier is a scalable and distributed frontier implemented through Redis Queues.

Downloads

6

Readme

MicroFrontier · npm npm version Docker Pulls Docker Image Size (tag)

A web crawler frontier implementation in TypeScript backed by Redis. MicroFrontier is a scalable and distributed frontier implemented through Redis Queues.

  • [x] Fast Ingestion & High throughput
  • [x] Multiple priority queues
  • [x] Custom priority strategy
  • [x] Per-Hostname crawl rate limit or default delay fallback
  • [x] Easy to use HTTP Microservice
  • [x] Multi-processing support

Example of Mercator Frontier1

Queue

Usage

MicroFrontier can be used both as a Javascript library SDK, from the command line or with a Docker deploy.

Command Line

Install microfrontier with:

npm i -g microfrontier

Run microfrontier

microfrontier --port 3035 --redis:host localhost #see configuration for other parameters

As a package

Npm:

npm i microfrontier

Yarn:

yarn add microfrontier

Docker

docker pull adileo/microfrontier

Configuration

| ENV VAR | CLI PARAMS | Description | | ------------- | --- |------------- | | host | --host | Host name to start the microservice http server. Default value: 127.0.0.1
| port | --port| Port to start the microservice http server. Default value: 8090 | | redis_host | --redis:host | Redis server host. Default value: 127.0.0.1 | | redis_port | --redis:port | Redis server port. Default value: 6379 | | redis_* | --redis:* | Parameters are interpreted by nconf and passed to ioredis as the client config.
| config_frontierName | --config:frontierName | Prefix used for Redis keys. | | config_* | --config:* | Parameters are interpreted by nconf, default value below. |

{
    frontierName: 'frontier',
    priorities: {
        'high':     {probability: 0.6},
        'normal':   {probability: 0.3},
        'low':      {probability: 0.1},
    },
    defaultCrawlDelay: 1000
}

How to

Adding an URL to the frontier

Via HTTP

curl --location --request POST 'http://127.0.0.1:8090/frontier' \
--header 'Content-Type: application/json' \
--data-raw '{
    "url": "http://www.example.com",
    "priority": "normal",
    "meta": {
        "foo": "bar"
    }
}'

Via SDK

import { URLFrontier } from "microfrontier"

const frontier = new URLFrontier(config)

frontier.add("http://www.example.com", "normal", {"foo": "bar"}).then(() => {
    console.log('URL added')
})

Getting an URL from the frontier

curl --location --request GET 'http://127.0.0.1:8090/frontier'
import { URLFrontier } from "microfrontier"

const frontier = new URLFrontier(config)

frontier.get().then((item) => {
    // {url: "http://www.example.com", meta: {"foo":"bar"}}
})

Citations

[1]: High-Performance Web Crawling - Marc Najork, Allan Heydon