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

Not seeing improvements when using with request-promise #66

Open
rvillane opened this issue Aug 7, 2020 · 0 comments
Open

Not seeing improvements when using with request-promise #66

rvillane opened this issue Aug 7, 2020 · 0 comments

Comments

@rvillane
Copy link

rvillane commented Aug 7, 2020

Hi, I have multiple apps written in node 10, multiple apps talk to the same target apps, then I was hoping to gain a performance improvement by caching DNS lookup, however in my case, those lookups are not executed explicitly, instead uses request-promise NPM module and tried the example below making multiple calls to the same target URL, however when is executed without dns-lookup-cache, got comparable results.

Am I using the library incorrectly ?

const rp = require('request-promise');
const {lookup} = require('dns-lookup-cache');

function querySite() { 
    return new Promise((resolve, reject) => {
        rp({
            url: 'https://en.wikipedia.org/wiki/Costa_Rica',
            method: 'GET',
            lookup: lookup
        })
        .then(response => {
            resolve(response);
        })
        .catch(error => {
            reject(error);
        });              
    });            
}

const init = async () => {
    querySite().then(res => { console.log('Success'); }).catch(err => { console.log(`Error ${err}`); });
    querySite().then(res => { console.log('Success'); }).catch(err => { console.log(`Error ${err}`); });
    querySite().then(res => { console.log('Success'); }).catch(err => { console.log(`Error ${err}`); });
    querySite().then(res => { console.log('Success'); }).catch(err => { console.log(`Error ${err}`); });
    querySite().then(res => { console.log('Success'); }).catch(err => { console.log(`Error ${err}`); });
    querySite().then(res => { console.log('Success'); }).catch(err => { console.log(`Error ${err}`); });
    querySite().then(res => { console.log('Success'); }).catch(err => { console.log(`Error ${err}`); });
    querySite().then(res => { console.log('Success'); }).catch(err => { console.log(`Error ${err}`); });
    querySite().then(res => { console.log('Success'); }).catch(err => { console.log(`Error ${err}`); });
    querySite().then(res => { console.log('Success'); }).catch(err => { console.log(`Error ${err}`); });
    querySite().then(res => { console.log('Success'); }).catch(err => { console.log(`Error ${err}`); });
    querySite().then(res => { console.log('Success'); }).catch(err => { console.log(`Error ${err}`); });
}
init();
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

No branches or pull requests

1 participant