10

I would like to have an advice regarding my problem.

We are creating a multi-player internet chess game having these features:

  1. Game will support a very huge amount of concurrent users
  2. We will be saving each game move physically on disk (e.g. using SQL Server Database)
  3. We will utilize the same SQL Server for Sessions too
  4. Multiple Game Servers will be utilized for load balancing / scalability
  5. All the Game Servers will be connected to each other
  6. All the Game Servers will also be connection to that SQL Server
  7. Since this is a chess game therefore only 2 users can play game but
  8. Unlimited number of users can view this game in real-time as audience (broadcasting)
  9. Audience / Game Users will have an option to send and receive chat messages, privately or publicly.
  10. We will maintain our own User List in Database. Therefore we will be requiring a custom authentication system.

The client will be a desktop windows forms / wpf application. We are also thinking for an online browser based version too but we have put it for future, currently we are focusing on desktop version.

Now my questions are?

  1. Which technology we should use, Sockets or WCF?
  2. What is the preferred way of serialization, XML or Binary or Custom Binary?

Any other advice/suggestion/direction is also welcome.

Thanks

Aaronaught
  • 120,909
  • 25
  • 266
  • 342
sallushan
  • 1,134
  • 8
  • 16

2 Answers2

8

Here my opinion.

Sockets

  • (+++) faster than WCF(especially if you use UDP)
  • (+) you will spend less on hardware in the future, since app with sockets will have better scalability
  • (-) you will spend more time on development
  • (-) you will spend more money on development
  • (-) you will need to design your own protocol or use close enough suitable protocol
  • (-) difficult to exted API
  • (-) it will be difficult for third-party developers

WCF

  • (+) avoid any issues with transport level
  • (+) easy to extend API
  • (+) it will save you time on development
  • (+) easy to provide third-party API
  • (+) you will spend less money on development
  • (-) it's slower than sockets
  • (-) you will spend more money on hardware, since app with WCF will have worse scalability

Doesn't matter what kind of serialization you're going to use, WCF will be slower than sockets.

Anyway you're not going to use "HipHop for PHP". I think, the answer is, create simplified client and server applications using WCF. Load it on maximum(as you suppose it will) using different bindings, serializations, etc. If WCF can handle the load and has a good reserve, then I assume, you can use it. If it's not - use sockets.

Maybe the best way to use the both technology. Sockets where performance is critical(e.g. connect game servers to each other), WCF for other parts(e.g. send and receive chat messages).

I believe there's a lot of other arguments for both technologies. But I think the question is: Do you want get it faster or get it easier to maintain. Is it an application where features are being added often, or is it an application where the load will grow in geometric progression. etc. etc.

jgauffin
  • 99,844
  • 45
  • 235
  • 372
Daniil Novikov
  • 440
  • 4
  • 8
  • nothing is difficult if its well documented, with sample code. – gbjbaanb Aug 17 '11 at 11:59
  • Yes, sure. But why do I have to make developer use custom socket protocol, if I can let him/her just add a service reference? – Daniil Novikov Aug 17 '11 at 12:12
  • Thanks Daniil, for you time. Actually the only thing on which we are confused about WCF is scalability. Will WCF work on multiple connected servers? This is the main issue. At-least we will be having 4 to 5 physical machines for game servers. And we want system to be flexible enough that we can add further nodes easily as load increases. – sallushan Aug 17 '11 at 17:51
  • There no difference with sockets, related to your issue. The "Will WCF work on multiple connected servers?" question doesn't have a sense, but the answer is yes. Anyway in both case, scalability and all other application properties, depends not only on technology, but it's about how it's designed also. So, I belive, that the best way is to use the right technology in the right place. Design your project. Decide where you should use sockets and where you can use WCF. Proof your concept by some tests and checks. – Daniil Novikov Aug 18 '11 at 02:39
  • well, WCF is a http-based protocol, so its quite a bit slower than a binary payload sent over a raw socket (for example, there are alternatives that add less overhead with similar ease of use), also if you want a web service to connect to multiple servers you'll have to introduce a load balancer. You'll also (I've found) want to use WCF on both ends of the comms channel as WCF web sockets are slightly incompatible with Java and PHP web services! And - the big deal, if you use WCF, you can use a socket connection anyway, just change the binding. – gbjbaanb Aug 22 '11 at 21:37
3

In addition to Daniil's answer: Abstract your communication-code and start with WCF. If it is to slow in the end (I don't think it will) you can still switch to sockets with relative ease.

Random Dev
  • 51,810
  • 9
  • 92
  • 119