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

mongodb-bridge

v0.1.0

Published

a tiny tcp proxy for network simulation (same as mongobridge.cpp)

Downloads

16

Readme

mongodb-bridge

build status

Make weird network stuff reproducable, particularly handy when testing and distributed system that needs to handle these kinds of things.

Example

# Start a mongod in terminal 1
mongod --port 27018;

# Start a bridge in terminal 2
mongodb-bridge --from localhost:27017 --to localhost:27018

# Open mongo shell in terminal 3
mongo localhost:27017

# When you run `show dbs` everything looks fine.
# Let's simulate the some delay though.
# Open terminal 4.
# What if you're connecting to another ec2 instance in the same availability zone? ~1ms
curl http://localhost:27019/delay/1

# Not a realy noticable difference.
# How about from ec2 east -> west? ~40ms
curl http://localhost:27019/delay/40

# How about ec2 east (virginia) -> EU (dublin)? ~100ms
curl http://localhost:27019/delay/100

# Now we're starting to notice.
# How about from ec2 west (oregon) -> EU (dublin)? ~180ms
curl http://localhost:27019/delay/180

# Ok starting to hurt.
# How about ec2 west -> tokyo? ~1100ms
curl http://localhost:27019/delay/1100

# Zoinks.  How about some weirdness.
# mongodb running on a satellite ~2200ms
curl http://localhost:27019/delay/2200

# Even at that, not so bad.  Lots of people can do that.
# What about mars, tough guy? ~9 minutes and 30 seconds
curl http://localhost:27019/delay/570000

# Let's go back to no delay.
curl http://localhost:27019/delay/0

# How about another common scenario: someone screwed up the iptables config.
# Hmm I can send but I never get anything back from mongo...
curl http://localhost:27019/drop/outgoing

# Whew!  Ok that's fixed.
curl http://localhost:27019/drop/none;

# Now let's update the app servers...
curl http://localhost:27019/drop/incoming;

# Nards!  Let me see that thing.  I remember how to ip all the tables...
curl http://localhost:27019/drop/all;

# Oi... we forgot to run chef-client.
curl http://localhost:27019/drop/none;

Scenarios

Say you are trying to test a system over time. You can use a pretty simple grammar to have bridge replay a scenario.

cat > one_minute_slowdown.txt << EOF
set the delay to 0
and after 100ms, set the delay to 100
and after 1 minute, set the delay to 0
EOF

cat one_minute_slowdown.txt | mongodb-bridge run-scenario
cat > drop_outgoing_then_lose_some_incoming.txt << EOF
set the delay to 0
and after 10 seconds, drop outgoing
and after 30 seconds, drop none
and set the delay to 0
and after 1 minute, drop all
and then wait 1 minute
and then stop
EOF

cat drop_outgoing_then_lose_some_incoming.txt | mongodb-bridge run-scenario

Real World

This is the workflow I imagine would help folks to the most: put some scenarios in your integration tests directory so you can test and observe:

cat > prepare_slight_slow_down.txt << EOF
wait 100ms
and then set the delay to 100
EOF

cat prepare_slight_slow_down.txt | mongodb-bridge run-scenario

# you go observe the system...
# hmm everything looks ok...

cat > shit_hits_the_fan.txt << EOF
set the delay to 500
and then wait 1 minute
and set the delay to 1000
and then wait 1 minute
and then drop all
EOF

cat shit_hits_the_fan.txt | mongodb-bridge run-scenario

# you go and check your system handled it correctly...
cat > restore_order.txt << EOF
set the delay to 0
and after 100ms, drop none
EOF

cat restore_order.txt | mongodb-bridge run-scenario

# you check everything is ok while self-fiving your way to the kitchen.

REST Client

var bridge = require('bridge').client('localhost:27019');
bridge.delay(1);

bridge.delay(100);

bridge.delay(0);

bridge.drop('incoming');

bridge.drop('outgoing');

bridge.drop('all');

bridge.drop('none');

bridge.stop();

license

MIT