Is node.js suitable for long polling which requires an open connection at all times? -


i have online feature requires me set field in database have integrated getting notification updates. such being done via long polling (since short polling isn't better , results in less connections server).

i used on php of know php understand, php lose it's available connections quite quickly, under fpm.

so turned node.js supposed able handle thousands, if not millions, of concurrent connections more seems node.js handles these via event based programming. of course event based programming has massive benefits.

this fine chat apps , not if have online feature have integrated long polling mark user still online?

would node.js still saturated or able handle these open connections still?

long polling node.js

long polling eat of connection pool, sure set ulimit high if using linux or unix variety.

ideally you'll maintain state in memcached or redis. prefered approach use redis. you'll subscribe pub/sub channel, , everytime user state updates you'll publish event. trigger handler cause long-poll respond updated status/s. typically prefered scheduling , cleaner, long you're not looping or otherwise blocking node's thread of execution shouldn't see problems.

short polling php

as you're using php stack might prefered not move away that. php's(more php-fpm) paradigm starts process per connection, , these processes set timeout. long polling isn't option.

short polling on intervals can update state on front-end. specified using cronjob, might cleaner hold state in memory on front-end , update periodically.

this should work, might increase need scale earlier, each user sending n more requests. however, might easiest approach, , you're not adding unnecessary complexity stack.

websockets

adding websockets such simple feature overkill, , websockets can have limited amount of connections(depending on host , configurations) you're not solving of issues long polling presents. if don't plan use websockets more maintaining user state you're adding technology stack solve simple problem.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -