javascript - Correct way to do node long polling -


seems there's lot of discussion how haven't found concrete examples. node application accessing restful api going pass through database. initial solution

function getrecord() {     var req = https.request(options, function(res){         res.on('data', function(data) {             var record = json.parse(data.tostring('utf-8'));             //do database things on             getrecord();         });     });     req.write(querystring);     req.end(); } 

this accomplishes want. i'm going keep getting new records api, i'm not sure if best approach doing want.

one (especially favorable) alternative switch bus architecture message server such rabbitmq.

you need either control api or have api can register callbacks with.

long polling strategy can degrade performance , bloat logs quite quickly. event driven methods, i've listed above, preferred if possibility. and, unlike long polling, event driven strategies don't introduce latency. if latency concern, more frequent poll, more degrade performance , bloat logs.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -