Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

10,000 users or 10,000 setInterval()?

I'm using APE-Project,

Is it better to have 10,000 connected users or 10,000 pages that use a setInterval() to send each N milliseconds a request to a PHP page?

Thanks

like image 266
Dal Avatar asked Jun 16 '11 11:06

Dal


People also ask

Why you should not use setInterval?

In case of time intensive synchronous operations, setTimeInterval may break the rhythm. Also, if any error occurs in setInterval code block, it will not stop execution but keeps on running faulty code. Not to mention they need a clearInterval function to stop it.

Should I use setInterval or setTimeout?

Usage notes. The setInterval() function is commonly used to set a delay for functions that are executed again and again, such as animations. You can cancel the interval using clearInterval() . If you wish to have your function called once after the specified delay, use setTimeout() .

Does setInterval affect performance?

Not appreciably. You'd have to be doing something extremely heavy in each interval for it to affect performance, and that would be true without setInterval involved at all.

How many times does setInterval run?

setInterval will run the function sendMessage every second (1000 ms).


1 Answers

APE claims it can scale upto 100k connections per machine. It's using proper evented I/O so it just scales becuase it doesn't have one thread/process per connection.

Just use 10000 connected clients with web sockets.

like image 115
Raynos Avatar answered Oct 12 '22 22:10

Raynos