Reputation: 87
Friends !!!
I am working on GPS device tracking software. We have almost 3000 devices which is communicates with our server via Java TCP listener. I am creating a separate thread for each device, since once connection establish with device, i don't want to loose connection with device, since it takes time to again create connection.
Once i run my TCP listener, CPU utilization increases 99% and system become unstable. Please help me to find a solution : A. to write TCP listener in java which can handle more than 3000 thread connection for 3000 devices B. To minimize CPU utilization.
Thanks in advance.
Upvotes: 0
Views: 162
Reputation: 4381
A is the wrong way and it implicates B. Unless your server runs on a sort of endlessly scalable host farm, you should not create a thread to process every incoming request. You do not mention what kind of connection you exactly have in mind, but in general: the right way is to design a server which uses certain (small) constant amount of threads (for your scale one would probably do) to listen to incoming connections, and serve them by I/O-bound asynchronous operations which do not consume CPU time at all.
Upvotes: 1
Reputation: 59623
Give The C10K Problem a read. Look here and here for some Java specific notes.
You want to use Java's non-blocking IO layer to handle large connection loads. The docs from JDK 1.4.2 are a good starting point.
Upvotes: 0