Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

port traffic...  RSS feed

 
Sathish Babu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
iam developing a chat app which has a threaded chat server. iam creating threads for each and every client connections. and my chat server listens to a single port say 1234. if the no.of clients increases by a large number say in thousands,will the port hold that much of traffic? or is there any other alternative?
thanx in adv.
sathish
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The thread-per-connection model is a good start, especially with a decently coded thread pool so there is not a lot of creation/garbage-collection of threads, but it does not scale well to very high loads. Most current JVMs allocate quite a lot of system resource for a thread, on the assumption that there will be relatively few, and each will do a lot of work. In a chat server, each thread is mostly waiting to send or receive characters, which doesn't need much CPU.
The most performant (but more complex) very-high-load servers map several connections to a thread or process, and cycle between them to serve data. Unfortunately this is neither easy nor particularly efficient in Java, which lacks the "wake-me-up-when-data-arrives" select function.
Good luck.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!