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

@conorpai/tilestrata-balancer

v0.2.11

Published

Elastic, metatile-aware load lalancer for TileStrata

Downloads

32

Readme

TileStrata Balancer

NPM version Build Status Coverage Status

An elastic metatile-aware load balancer to sit in front of multiple TileStrata servers (must be >= 2.0.0).

$ npm install tilestrata-balancer -g

$ tilestrata-balancer \
	--hostname=127.0.0.1 \ # bind address
	--port=8080 \ # for connections from the outside world
	--private-port=8081 \ # for connections from tilestrata tile servers
	--check-interval=5000 \ # how often to ping child nodes
	--unhealthy-count=1 # consecutive unhealty pings needed to determine a host is unhealthy

Configuration

First and foremost, whatever --private-port is set to needs to not be accessible to the outside world. This is crucial so that outside connections can't maliciously insert a random node into the pool.

On the servers upstream, use the balancer option to set where to find the load balancer. When TileStrata starts up, it will check-in with the load balancer, informing it that its ready to be routed to. After that, the balancer will periodically check /health to ensure the node is healthy.

var strata = tilestrata({
	balancer: {
		/* the port should match --private-port */
		host: '192.168.0.1:8081',
		/* the magnitude is relative to other servers (default: 1) */
		node_weight: 3
	}
});

If using metatiles, set the metatile option on the layer to have it recognized by the balancer. Note: this will likely be redundant with plugin settings.

strata.layer('mylayer', {metatile, 4})
	.use(mapnik({metatile: 4, /* ... */}))

Additional Notes

One cool thing to note is that TileStrata Balancer allows layers to be non-homogenously spread about your cluster. The balancer keeps track of what layers exist on each host. This property is great if you have multiple maps that are tough to squeeze on a single server.

The Contract

  1. TileStrata should start up and send periodic POSTs to /nodes until it receives a 201 Created. The request body should contain a unique id, node_weight and a layers array with various parameters about each (minZoom, maxZoom, metatile). The successful response body (JSON) will contain a "token" property that is later sent as the X-TileStrataBalancer-Token header on health checks.
  2. TileStrata Balancer will send periodic requests to /health on the TileStrata node to ensure it's healthy. If unhealthy, the node is dropped from the pool. TileStrata should detect the lack of incoming health checks from the balancer (indicated by X-TileStrataBalancer-Token) and attempt to re-register (1).
    • If TileStrata is shutting down, it should call DELETE /nodes/:id on the balancer.

License

Copyright © 2015 Natural Atlas, Inc. & Contributors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.