Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Network Library for server side of a mmorpg (libuv/boost::asio?)

I am currently rewriting the server side of a very old mmorpg, and I was looking for a good opensource network library to use with C/C++.

As the client already exists, I can't use any library that enforces some kind of packet structure or communication (as, for example, RakNet).

The server will use mainly UDP, on three different ports.

After searching on the internet, I found out about boost::asio and libuv.

boost::asio seems like a mature option, as I will already be using boost, but I read that their UDP implementation is a little poor, and that it can't achieve the maximum performance of a multicore processor because of some locks when using epoll.

libuv seems great, is event-driven, supported by a big project, but currently there is no project of this kind using it, so I'm in doubt about usign it.

What do you people think? Can I use libuv in a project like that, or will I have to go with boost::asio? I am open to other suggestions too (they need to be cross-platform, and I already discarded enet, libevent and libev).

like image 477
RenatoUtsch Avatar asked Apr 28 '13 23:04

RenatoUtsch


2 Answers

Either libuv or Boost.Asio should be fine. I have observed similar results between the libraries in both real-time and near-real-time applications.

If you do use Boost.Asio, be aware of:

  • How to minimize the amount of handler memory allocation.
  • io_service locking can be eliminated by providing a concurrency_hint of 1 to the io_service constructor. However, this will not prevent locking within the reactor.

From my experience with game development:

  • If the network capabilities are provided to the game code through either an interface or queue, then it is fairly trivial to swap between one event-based library to another event-based library, such as Boost.Asio and libuv.
  • The server architecture has far more of an impact than the network code itself. Both Boost.Asio and libuv provide IPC functionality that may be useful for multi-daemon server architectures.

While there is some overlap between the two libraries, it may be worthwhile to read this comparison.

like image 60
Tanner Sansbury Avatar answered Oct 04 '22 00:10

Tanner Sansbury


libevent is excellent and it surprises me that you have discarded it. ZeroMQ is pretty good but Windows support is slightly limited. RabbitMQ is being by a fiend of mine in SF.

Boost.asio is also very good. Since it seems that you are limited to c++, then libevent is what I am using and it should far outstrip other MMO titles on which I have worked in terms of network latency and responsive networking, but it does require tcp.

like image 23
Mickey Kawick Avatar answered Oct 04 '22 01:10

Mickey Kawick