Thread: Choosing the Best Networking Solution for a Server Project

Page 2 of 9 FirstFirst 1234 ... LastLast
Results 11 to 20 of 85
  1. #11  
    Banned

    Join Date
    Jun 2010
    Age
    33
    Posts
    4,337
    Thanks given
    4
    Thanks received
    274
    Rep Power
    0
    Thank's, I mostly use Netty.
    Reply With Quote  
     

  2. #12  
    Renown Programmer
    veer's Avatar
    Join Date
    Nov 2007
    Posts
    3,747
    Thanks given
    354
    Thanks received
    1,368
    Rep Power
    3032
    becareful with ReplayingDecoder; the way it is implemented it makes it costly
    Reply With Quote  
     

  3. Thankful users:


  4. #13  
    Renown Programmer and Respected Member
    Maxi's Avatar
    Join Date
    Jun 2008
    Posts
    3,201
    Thanks given
    281
    Thanks received
    1,093
    Rep Power
    1366
    Quote Originally Posted by super_ View Post
    becareful with ReplayingDecoder; the way it is implemented it makes it costly
    Although using state management increases it performance by a lot again.
    Reply With Quote  
     

  5. #14  
    Renown Programmer
    veer's Avatar
    Join Date
    Nov 2007
    Posts
    3,747
    Thanks given
    354
    Thanks received
    1,368
    Rep Power
    3032
    Quote Originally Posted by Maxi View Post
    Although using state management increases it performance by a lot again.
    perhaps a bit... but the fact it relies on the exception handling mechanism is a huge detriment
    Reply With Quote  
     

  6. Thankful users:


  7. #15  
    Community Veteran


    Join Date
    Jan 2008
    Posts
    2,664
    Thanks given
    493
    Thanks received
    627
    Rep Power
    980
    Quote Originally Posted by super_ View Post
    perhaps a bit... but the fact it relies on the exception handling mechanism is a huge detriment
    ReplayingDecoder throws an Error rather than an Exception and reuses the same instance, right? Is it still all that slow?
    ~iKilem
    Reply With Quote  
     

  8. Thankful user:


  9. #16  
    Registered Member DestriX's Avatar
    Join Date
    Nov 2008
    Posts
    1,329
    Thanks given
    490
    Thanks received
    152
    Rep Power
    257
    Shit I am learning quite a bit
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  10. #17  
    Chemist

    Advocatus's Avatar
    Join Date
    Dec 2009
    Age
    28
    Posts
    2,549
    Thanks given
    192
    Thanks received
    761
    Discord
    View profile
    Rep Power
    1332
    I originally used mina, however, after reading through some articles, I realized that iobuffer was being scrapped (it was always handy and easy to use imo). I was faced with the dilemma that after mina3 came out I would be forced to redo most of my networking related code to keep updating my api. I did a very large amount of looking into it, and was kind of midway between netty and nio. However, the complexity and overhead of netty was a major turnoff for me. I ended up choosing nio and then implementing the reactor design pattern using both twisted and netty as guidance. After I finished, I have never looked back on my decision although it was possibly one of the most time consuming tasks that I have ever done.
    Quote Originally Posted by blakeman8192 View Post
    Quitting is the only true failure.
    Reply With Quote  
     

  11. Thankful user:


  12. #18  
    Renown Programmer and Respected Member
    Maxi's Avatar
    Join Date
    Jun 2008
    Posts
    3,201
    Thanks given
    281
    Thanks received
    1,093
    Rep Power
    1366
    Quote Originally Posted by super_ View Post
    perhaps a bit... but the fact it relies on the exception handling mechanism is a huge detriment
    I remember doing tests with it and using state management improved like 75% on a low amount of packets per minute and when packets per minute became higher the difference became less. It's a very usefull decoder if there is a lot of continuous traffic and the state management will lower the overhead in any situation and is very usefull to handle broken packets.

    I can try and see if I still have it somewhere, I remember I send packets with a size of 16 bytes, varying from sending 1/minute upto like 15000/minute.

    I used it for breaking up packets into frames and I really like it :

    Code:
    @ChannelPipelineCoverage("one")
    public class GPPStreamMultiplexer extends ReplayingDecoder<DecoderState> {
    
    	public GPPStreamMultiplexer() {
    		super(DecoderState.READ_OPCODE);
    	}
    	
    	@Override
    	protected Object decode(ChannelHandlerContext ctx, Channel channel,
    			ChannelBuffer buffer, DecoderState state) throws Exception {
    		ChannelBuffer b = ChannelBuffers.dynamicBuffer(256);
    		int opcode = 0;
    		int length = 0;
    		switch (state) {
    		case READ_OPCODE:
    			opcode = buffer.readUnsignedByte();
    			b.writeByte((byte) opcode);
    			checkpoint(DecoderState.READ_BODY);
    		case READ_BODY:
    			length = PacketHandlingExecutor.GPP_PACKET_LENGTHS[opcode];
    			switch (length) {
    			case -3:
    				length = actualReadableBytes();
    				Logger.log("Unframed packet with opcode " + opcode 
    						+ " and estimated length: " 
    						+ (length - 1));
    				buffer.skipBytes(length);
    				break;
    			case -2:
    				length = buffer.readUnsignedShort();
    				b.writeShort((short) length);
    				b.writeBytes(buffer, length);
    				break;
    			case -1:
    				length = buffer.readUnsignedByte();
    				b.writeShort((short) length);
    				b.writeBytes(buffer, length);
    				break;
    			case 0:
    				b.writeShort((short) length);
    				break;
    				default:
    					b.writeShort((short) length);
    					b.writeBytes(buffer, length);
    					break;
    			}
    			checkpoint(DecoderState.READ_OPCODE);
    			return b;
    			default:
    				throw new Exception("GPPStreamMultiplexer failed");
    		}
    	}
    
    }
    Reply With Quote  
     

  13. #19  
    Programmer, Contributor, RM and Veteran




    Join Date
    Mar 2007
    Posts
    5,074
    Thanks given
    2,625
    Thanks received
    3,578
    Discord
    View profile
    Rep Power
    5000
    The problem with it Maxi is that a slow client could cause it to decode parts of the message multiple times and each time it fails to decode something due to not enough data being present it'll throw an exception.

    A FrameDecoder isn't really that much harder to understand - but it doesn't use any of the exception trickery behind your back and if you have a slow client you'll end up with better performance.

    Now, you might think this is a bit of premature optimization. Perhaps it is. But if you are designing your server to support 2000 players, this is some code that is going to be called tens of thousands or maybe even hundreds of thousands time per second and you really want it to execute as quickly as possible so you don't get packets queueing up (which could ultimately lead to an OutOfMemoryError).

    Quote Originally Posted by Advocatus Diaboli View Post
    However, the complexity and overhead of netty was a major turnoff for me.
    Netty, in my opinion, is less complicated and easier to understand than MINA. And also various benchmarks (that I've seen and perform myself) seem to indicate that in most situations Netty has less overhead than MINA.

    The thing I do like about Netty is it tries to force you to decouple message decoding/encoding, message representation and message handling which from a design perspective is really good.
    .
    Reply With Quote  
     

  14. Thankful user:


  15. #20  
    Community Veteran


    Join Date
    Jan 2008
    Posts
    2,664
    Thanks given
    493
    Thanks received
    627
    Rep Power
    980
    Quote Originally Posted by Graham View Post
    Now, you might think this is a bit of premature optimization.
    Nah, because what you said to Maxi is valid and should be a concern. You could probably help it by having more "states", but there's really no point if your code gets too complicated, and you'll lose the advantage of ReplayingDecoder anyway. Perhaps use ReplayingDecoder for debugging purposes and then FrameDecoder for the real deal.
    ~iKilem
    Reply With Quote  
     

Page 2 of 9 FirstFirst 1234 ... LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Client/Server Networking
    By Vegito in forum Help
    Replies: 3
    Last Post: 12-19-2010, 02:22 PM
  2. Replies: 0
    Last Post: 11-16-2010, 02:08 PM
  3. Need help choosing VPS !
    By Henkkaah in forum Hosting
    Replies: 6
    Last Post: 08-07-2010, 05:32 AM
  4. Replies: 15
    Last Post: 04-27-2010, 07:35 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •