Women in Technology

Hear us Roar



Article:
  Building Highly Scalable Servers with Java NIO
Subject:   Event Dispatch Threads
Date:   2005-10-28 00:47:35
From:   nuno.santos
Response to: Event Dispatch Threads

Hi.


You are right in that the sample code is single threaded. It was a simplification I've made to post the code online, as I wanted to make the code as clear as possible. The original source code, uses a round robin strategy with around 3 to 4 threads. Implementing that is really a trivial extension, it should be no problem for anyone willing to spend an afternoon tweaking the code.


Cheers,
Nuno

Full Threads Newest First

Showing messages 1 through 2 of 2.

  • Event Dispatch Threads
    2005-12-31 19:47:23  Khiraly [View]

    After testing the code, I run into trouble.

    I want to create a server which is available to serve 6000+ client (6300-6500 average with 7000 peak). Now we use an C++ program which is really complicated and its easier to recreate in java.

    The problems are:

    * The server must maintain a string of each client, and send all the string to the newly connected clients, and remove the string from the table, if one client disconnect must notified all the other client (send a "Logout clientname" string).

    The problem is, that the string of one client consume 140bytes. So sending all the information collacted to one client is about 1MB.

    The bigger problem is, that just collecting the data to send to the clients, and iterating over 2700 clients consume about 40-45 sec, so its a big task. If one client does not obtain any data from the server after 40sec, it disconnect. So the scenario is the following:
    Connects the clients, about 2700 connection begin all client disconnect, and the connections fall about 600 connection. So Im unable to have more than 3000 connection simoultanously. The C++ program on this machine is able to handle 7000 clients.
    Here is an graph about it:
    http://khiraly.4242.hu/tmp/java-nio.png

    So my questions:

    * How I implement a thread, that just sends continously the information to the sockets? (does not need to block on select(), it must work on low priority, so sending data when there are cpu cycles available)

    * Where implement I the round-robin algoritm to create the SelectorThreads?

    Any help would be really appreciate!

    Best regards,
    Khiraly
  • Event Dispatch Threads
    2009-02-05 16:38:15  Rainman4500 [View]

    Am I to understand that Socket/port can have multiple Selectors in seperate Threads?

    Did you have multiple Selectors within the SelectorThread class with a round robin dispatcher or Mutliple Selector Threads?

    Thanks