|
So this is basically a discussion about the best networking system to use in a RuneScape server project.
For simplicity sake, I ask that this discussion is limited to discussing Java implementations of networking only.
The Options
As far as I can tell, here are the most popular options:
Let's get a good discussion going, weighing the pros and cons of all of these options - and hopefully we'll answer a lot of our own questions, clear any misconceptions, and learn a lot along the way. This thread is pointless and I look like a dumb optimist if nobody else hops in and joins the discussion, but I have faith that you guys will be a part of this. I'm asking everyone to not troll this topic, and instead contribute to a good discussion that'll teach a lot of people a lot of things.
Java IO
The very first communication system that Java has. It only supports blocking operations, which means that in order to support multiple clients simultaneously, concurrency needs to be used. This is what Winterlove uses, the "thread per client" approach that doesn't work out too well for performance. Many people choose to use Java IO for simplicity, even the RuneScape client uses Java IO. I believe that Java IO is only a reasonable approach when networking performance is not important in an application.
Pros
- Simple, for the most part.
- Many guides/examples online, it's old and has been used a lot.
Cons
- Not scalable, needs concurrency to support multiple clients.
- Restricted to using byte arrays which adds complexity to the packet system.
Java NIO
My personal favorite. Implemented with the reactor design pattern, it is by far the fastest networking system you can implement with Java, as long as you implement it properly. Faster than all of the other options, the only problems it has is the complexity of its' backing concepts and infinite variability with possible implementations. It can be very difficult to figure out when you first learn it, as you must first learn the underlying design of the reactor design pattern. Java NIO can also be very difficult to debug, due to its' inverted multiplexing flow of execution. And when it's implemented in a concurrent environment (for performance reasons), the complexity of the system increases a huge amount.
Pros
- Efficiency, stability, and speed. It's the most high-performance networking solution in the Java world when implemented properly.
- ByteBuffers - a much better alternative to byte arrays. They're easier to use, and have support to read/write directly to/from memory natively in a seamless manner.
Cons
- Complicated, it's often viewed as some arcane art that most Java programmers never bother to learn.
- It's inverted flow of execution makes it hard to debug problems that arise.
- Has had a history of bugs in the Java API.
- Gets ridiculously complicated when implemented in a concurrent environment.
Mina, Netty, and XSocket
I'll leave these topics for you guys. Go ahead and voice your opinions of the networking systems, this isn't a tutorial thread but is instead a discussion thread. Rune-Server today rarely has good discussions, and instead is filled up with flaming shitposts and ideas to monetize RuneScape Private Servers. RSPS is about technology, concepts, and a playground in which to test new programming ideas in a familiar game that I love. So what do you think of Mina, of Netty, and of XSocket?
We haven't had a good discussion like this in a long time, so let's do it motherfuckers.
I like both Netty and MINA, but they can both be costly since it uses a good amount of OOP, but I don't think it's well suited for RSPS. Think about it, update server consumes bandwith and requests over 10k files which means a shitload of operations per request, but I don't think it affects anything much since event's are just discarded after usage, but eh.
Edit:
I also hate the fact that you can't edit the networking library yourself to your preferences unless you add the src to your server itself.
i think this post is useless since it makes obvious comparisons
Netty can actually be used with NIO or the old-style blocking IO:
org.jboss.netty.channel.socket.nio (The Netty Project API Reference (3.2.4.Final))
org.jboss.netty.channel.socket.oio (The Netty Project API Reference (3.2.4.Final))
Netty is my favourite out of those three APIs. MINA is alright but using the API feels a bit more cumbersome than with Netty. xSocket is really something I'd use to hack up a quick demonstration and I wouldn't use it for a large application.
Mina isn't bad either, testing my simple webserver earlier took 30,000 requests in 20-30 seconds (150% cpu on 4x 2.2ghz cores, didn't freeze or even cause a delay), but I've never really tried just plain java NIO, as you stated, I never got into looking into it.
Honestly, any implementation works for a simple server, it's up to the user, but if you wish to take less time off networking and put more time into the server itself, mina or netty would be a good place to start..
Mina also includes some useful utilities, such as throughput and other functions in it's core class.
Overall, there's pros and cons of everything, you just have to find one that meets most if not all your requirements.
I've used xSocket in the past, but the API can be pretty clunky at times. The only exception to this, I feel, is xLightweb written by the same person which is really really nice for dealing with HTTP. I prefer it over the Apache equivalent.
Netty is supposed to be the successor to MINA and I learned Netty first so I have no plans on messing with MINA. I've heard mixed things about it.
One thing I like about Netty is the ReplayingDecoder which makes writing protocol shit trivial. With xSocket they don't really have anything like that, so you have to keep checking whether there are bytes to read.
Raw NIO, of course.
You learn a lot of stuff along the way (you know what I mean Blake), and you can fit it to your needs, and it can provide some amazing performance.
I think being able to make your own stuff without the help of external libraries is important because I would hate to be dependent on a library to do the networking for me (like I'm sure quite a few people are).
But I guess I'm a bit biased because ever since I've been talking to Blake, he's always been helping me up with that kind of stuff, so really that is the only thing I am accustomed with.
I cannot comment on the coding side of it, only the effect that it had on my server from changing from Winterlove IO to mina. We made the change due to IO taking 2-3 minutes to log everyone in, after changing to mina we could log everyone in after 5 seconds, this is with about 250 players. However the main downside that we experienced was that CPU usage increased 2 fold. From what I have heard, I think it would of been best if we had used netty but it is now not worthwhile changing. Therefore I believe that IO is fine for smaller servers, but once a server gets big it requires more advanced networking to handle the strain.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |