Reputation: 1858
Hypothetical question to solve a dispute. Let's say I had a server and 1000 active users. The server is to respond with push notifications when something interesting happens (this depends on each user.)
Each user can subscribe to other users so when they update something, all subscribed users get a push notification.
Push notifications would be implemented by a user sending a VERY long time-out message and then sit and wait as long as it needs until the server replies. Server will only reply if something interesting happens.
Now lets assume that it's infeasible to have a 1000 objects and have events firing between them. When a user makes a request he gets his own thread, that thread does one loop to check for anything interesting and then waits until an appropriate WaitHandle signals it to wake up and do another loop.
The key here is that it would be infeasible to have each thread loop indefinitely until something happens so we put it to sleep and wait for a signal.
If only about 2-5% of the time something interesting happens - 20-50 active threads at any time waking up to do a single loop. Would having all those sleeping threads there cause any major performance issues. Or in another words, would the program scale linearly or exponentially (in terms of computation)?
Upvotes: 0
Views: 59