Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced ping-based healthcheck with net.createConnection #351

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mutantcornholio
Copy link

Older ping-based healthcheck had a bunch of problems:

  • Doesn't work in ipv6-only environment (because of calling ping, not
    ping6).
  • Doesn't work if ICMP is blocked, but TCP is not
  • Doesn't work as expected if TCP on this exact port is firewalled out.
  • Uses a lot of CPU on process spawning, may cause DoS in clusters with
    large number of worker processes.

Healthcheck with net.createConnection seems to be a much simpler and
more robust alternative

Two test were needed changing:

  • One was implicitly tied to ping interval; ECONNREFUSED was thrown faster,
    I've tuned reconnect timeout in test
  • Another one actually relied upon one of aforementioned problems:
    setting up server at 127.0.0.1:1234 would mean server is available to
    ping, but not to TCP connection. In that test, I've used
    net.listen to actually listen for connections on socket

Older ping-based healthcheck had a bunch of problems:
* Doesn't work in ipv6-only environment (because of calling `ping`, not
`ping6`)
* Doesn't work if ICMP is blocked, but TCP is not
* Doesn't work as expected if TCP on this exact port is firewalled out
* Uses a lot of CPU on process spawning, may cause DoS in clusters with
large number of worker processes

Healthcheck with net.createConnection seems to be a much simpler and
more robust alternative

Two test were needed changing:
* One was implicitly tied to ping interval; ECONNREFUSED was thrown faster,
I've tuned reconnect timeout in test
* Another one actually relied upon one of aforementioned problems:
setting up server at 127.0.0.1:1234 would mean server is available to
ping, but not to TCP connection. In that test, I've used
net.listen to actually listen for connections on socket
@mutantcornholio
Copy link
Author

Test are faililng on nodejs 4/5 because mocha@^4 uses object destructuring, which isn't supported by those versions of node.

Downgrading to mocha@^3 helps

@mutantcornholio
Copy link
Author

@3rd-Eden what do you think?

@mutantcornholio
Copy link
Author

@mapleeit, @kevin-greene-ck, looks like you are maintainers now?

@mutantcornholio
Copy link
Author

Anyone? @3rd-Eden @mapleeit @kevin-greene-ck ?

@aakarsh
Copy link

aakarsh commented Nov 18, 2019

@mutantcornholio @3rd-Eden Any one working to integrate this, we are in environment without ping command, this will help us.

@mutantcornholio
Copy link
Author

I've published fork here:
https://www.npmjs.com/package/memecached
https://github.com/mutantcornholio/memcached

This PR is the only difference in code now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants