Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: How can I reduce network utilization?

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How can I reduce network utilization?

    Hi I'm trying to reduce the network utilization of a server program, for each connected client. I am monitoring the network utilization in the windows task manager's networking tab. When I start up the server and wait for connections the utilization is at 0.00% when one client connects to the server and logs into the game I get 0.13% utilization while the client is idle. When the client is running around and playing the game it goes up to 0.25% and varies by a few hundredths of a point. I'm trying to squeeze as many available connections into my server computer as possible

    When I tested out my server program on my new computer the idle network utilization per client was 0.30% and the playing utilization was 0.90%. After tinkering with the client and server's connection thread(where all the tcp socket communcation happens) I found out that having the client's connection thread sleep for 25ms was as long as it could sleep for without losing performance and "lagging". Anything faster than that would dramatically increase the network utilization on the server computer. Also having the server's connection thread sleep for 15ms was best for performance(anything more would also cause the client to "lag"), anything less would increase the network utilization.

    I tried shortening some of the strings the server sends the client, by replacing the identifying first part of the string ex. "MonsterData" with "6" and I did that for everything the server sent. That did not lessen the network utilization either.

    I rewrote some of the server code to have some "lastSent" variables with different data stored in the connection thread for variables like hitpoints, strength, experience points, etc. Instead of always sending all of the variables(around 15 variables) I had it send them only if they had changed since the last sending of the variable. That did not decrease network utilization.

    I also added another thread.sleep(5) to the server connection, right after it sends the monster data, if it sends no data then it sleeps, that decreased network utilization by 0.03% while the client is idle. If i put more of the thread.sleep() after the sending of different data it does not decrease network utilization.

    I also tinkered with setReceiveBufferSize() and setSendBufferSize() on the client and server, that also did not help.

    I've been researching on Google but I have not found any valuable information over the past few days.

    I'm at a standstill on my project and I'll keep messing around with the code but I'm not making much progress alone with this roadblock.

    EDIT*** I just commented out setTCPNoDelay(true); to see if that would have an impact....sure enough it took a single connection's network utilization down to 0.01% idle and up to 0.07% while playing...but the client is very laggy now. I'll lower the two connection's thread.sleep() although that will probably just increase network utilization again. One thing, I enabled setTCPNoDelay() because the game was very laggy without it out a couple months back. I'm not sure if I'll be able to use Nagle's alrorith for that reason.

    EDIT2*** With Nagle's alrorith enabled, nomatter what I set those connection's thread.sleep() to, even .sleep(1) It fails to improve performance like when Nagle's alrorith is disabled. NPCs moving nearly 1 tile at a time instead of a couple of pixels, same thing with the fireball spell the player can cast, it jumps away from you in large steps, instead of smoothly. If there was a way to use Nagle's alrorithm for the huge improvement in network utilization but still be able to increase or decrease those thread.sleep() with their improvements i'd be on the right track.

    If anyone can shed some insight on this topic for me I'd greatly appreciate it. I'll also answer almost any questions you might have. Thanks for reading.
    Last edited by Drakenmul; June 15th, 2010 at 06:39 AM. Reason: Currently experimenting with my code...


Similar Threads

  1. Replies: 0
    Last Post: April 11th, 2010, 08:56 AM
  2. Network problem
    By subash in forum Java Networking
    Replies: 0
    Last Post: March 9th, 2010, 07:07 AM
  3. network scanner
    By vivek494818 in forum Java Networking
    Replies: 0
    Last Post: August 17th, 2009, 11:07 PM
  4. Problem on sending vectors from Java server to C# client
    By MS_Dark in forum Java Networking
    Replies: 2
    Last Post: July 7th, 2009, 02:35 PM
  5. Java program to encrypt an image using crypto package
    By vikas in forum Java Networking
    Replies: 1
    Last Post: July 7th, 2009, 11:00 AM