It turns out that the problem does not seem to be on the network side...

I tried to make a simple example client and server which uses more or
less the same network code as my game with a very simple Swing GUI
client. This example worked well without delays up to even 9 clients.

As I tried to compare the running behaviour with my actual game it
turned out that with 4 local clients running at the same time, and all
graphically displaying on my machine, the CPU usage often peeks at
100%. With only 3 clients it never uses all the CPU and under these
circumstances there also occur no network delays.
Still it is somewhat strange. Even with a profiler run on one of the
clients I cannot see, which threads use so much CPU. But I think it
must be something on the graphic side.

So I suppose the delays which I experienced on the server seem to be
caused by clients which do not read the message right away but only
after some delay.

Is it really the case that the server only actually sends the message
after a write on a session when the Mina session on the client side
actually reads the buffer?

On Mon, Nov 30, 2009 at 10:12 PM, Emmanuel Lecharny
<[email protected]> wrote:
> Very strange...
>
> Some code could help at this point, it's very difficult to know what's
> going on without a minimal version we can test.
>
> On Mon, Nov 30, 2009 at 10:06 PM, Daniel Egger <[email protected]> wrote:
>> Hello all
>>
>> I am trying to program a simple network game with the help of Mina.
>> I am using version 2.0 RC1 of Mina right now.
>> For the moment my game is very simple. I have a simple server which
>> writes any incoming message in its messageReceived method out to any
>> connected client.
>> I use the ObjectSerializationCodecFactory as a protocol codec filter
>> and my messages are very small only having a small number of fields.
>>
>> So much for the setup. This system seems to work rather well for only
>> two connected clients and I even tested it successfully in a
>> distributed manner.
>>
>> But in the last few days I tried to setup a server on my local machine
>> with four local clients connected. With these setup a few strange
>> delays occur. It often happens that messages don't get written right
>> away to the client but only a considerable number of seconds later.
>> (about 5 seconds up until 20 seconds...).
>> Here is a simple example: Rhe server receives an incoming message in
>> the messageReceived method and writes this message immediately to
>> every of its four connected clients. Then the server sends the message
>> right away out to three out of the four connected clients. I can see
>> that by logging the calls to the messageSent method. But the server
>> calls the messageSent for the fourth client only about 5 seconds later
>> and sometimes even later.
>> This behaviour happens quite often at about 25% of every incoming
>> message event. At other times all the four clients get the message
>> right away.
>>
>> I don't know much about the inner workings of NIO and/or buffers so
>> this could be trivial. I am not very sure if this is an expected
>> behaviour (maybe a buffering problem?), or if I could do something
>> against that. But I am very surprised that in this simple setting with
>> only local clients and a local server a delay of several seconds can
>> even occur.
>>
>> Any suggestions on how I could solve this issue are very welcome.
>> Thanks
>> Daniel
>>
>
>
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>

Reply via email to