GithubHelp home page GithubHelp logo

fastest-server's Introduction

fastest-server

Build Status Dependency Status npm

Library used to get fastest server using ICMP (Internet Control Message Protocol).

Table of Contents

About

This library is used to get the fastest server from the list of servers (IP’s or host names). Many times same services are running in different regions to serve clients better. And this library will try to ping the list of servers using ICMP (Internet Control Message Protocol). Based on response time it will find the fastest server which is mostly nearest server.

Installation

npm install fastest-server

Usage

const FastestServer = require('fastest-server');

const { fastest, stats } = await FastestServer.get(['172.217.19.14', 'google.com'])

// fastest - will have fastest host.
// stats - will be more information about response time and respose type.
// {
//   fastest: 'google.com',
//   stats: [
//     { host: '172.217.19.14', response: 'REPLY', timeElapsed: 9 },
//     { host: 'google.com', response: 'REPLY', timeElapsed: 2 }
//   ]
// }

Methods Exposed

(static) FastestServer.get( hosts: Array< String >, [timeout: number]): Promise<{ fastest: string, stats: Array<{ host: string, response: string , timeElapsed: numer }>}>

const { fastest, stats } = await FastestServer.get(['172.217.19.14', 'google.com'], 5000);

console.log(fastest); // google.com
console.log(stats);
// [
//   { host: '172.217.19.14', response: 'REPLY', timeElapsed: 9 },
//   { host: 'google.com', response: 'REPLY', timeElapsed: 2 }
// ]

response will be one of the value from array: ['REPLY', 'NA', 'DESTINATION_UNREACHABLE', 'SOURCE_QUENCH', 'REDIRECT', 'UNKNOWN']

timeElapsed will be in milliseconds (ms)

fastest-server's People

Contributors

dhineshpandiyan avatar

Stargazers

Ted Munsch avatar

Watchers

 avatar

Forkers

boreperfection

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.