Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a large game engine which serves mobile phone clients and a web site. The DB is MSSQL2008 and the engine is written using C#.

The web site is built with ASP.NET MVC and the web service for the mobile phones is also built on ASP.NET MVC (probably will be migrated to WCF or pure socket server).

The web site and the web service are located on an IIS 7 server and the DB is located on a dedicated server. Both are connected on a local fast LAN.

The game requires real-time response (under 1 sec) for each user. When I did some load testing on the service - it seemed that on ~250 users it reached 1 second response (at 50 it was about 200ms). It should support well over 10000 users connected. (Server replication I guess).

I thought about adding one more layer - a dedicated real-time server for the game web service. I've heard that Python could be used to build very high performance services - would that be a clever idea to add this layer? (the layer should have in-memory temporary database to serve the real time players and then dump it all to the back-end DB every X seconds).

Is my architecture any good? How could that be improved?

share|improve this question
You need to determine where the bottleneck is and adjust accordingly. – gravyface Apr 19 '11 at 23:52
up vote 2 down vote accepted

I can speak to the SQL Server part.

What is the hardware specs you have for this? What's the SQL Server edition you are using? While you can add more memory to the box and keep the data in memory but that solution won't scale after a while. You need to use lot of good practices here if you want to scale for many users.

The usual bottlenecks are Memory, IO, CPU.

  1. Having more memory helps.
  2. Having good disk system [RAID 10] really helps. Separating data and transaction logs onto separate spindles is a good practice. Depending on the amount of IO, move tempdb onto its own spindles and look for bottlenecks. Is it bound by IO or allocation bottleneck. using Trace Flag TF 1118 and many tempdb data files helps.
  3. Pre-allocate data and log files so that it won't auto grow during normal business operations.
  4. Start with good schema + good code after doing some due diligence. Crappy code is crappy code and garbage in is garbage out irrespective of what platform you use.
  5. Understand Index structures very well and have a good index maintenance plan ( update stats)
  6. Load test your sql code with large amounts of data.
  7. Look at identifying the bottlenecks and performance problems in SQL Server. Wait statistics and virtual file stats are very important here. Identify which procedures are expensive based on cu, logical IO & high execution count. Look at missing indexes DMV. Learn to read data from SQL Server Plan Cache.
  8. Look at Instant File Initialization
  9. And there are so many other things here and its hard to list them all. This is a good starting point but its NOT an exhaustive list though.


share|improve this answer
This was very helpful! Thank you! – Bob Apr 20 '11 at 7:35

It seams to me that you should ask yourself where the bottleneck is first.

  • Most of the time SQL server is a hard consumer of disk IO; By itself this is a whole topic of optimization (Database Schema, SQL Query vs StoreProc etc.). You may want to use the SQL profiler.
  • Are you using any state mechanism using the Web Service if so are you using SQL server to preserve that state this maybe a performance issue.
  • Have you tried to profile your .Net code and your SQL Query code?
  • Are you sending binary chunk over SOAP, binary content need to be encoded in base64 this may cause some overhead (Network and Bandwith) same as for SSL;
  • Have you ask you’re self about using a less verbal protocol other than WebService/SOAP; maybe an HTTP/JSON protocol or even a custom binary one.
  • Building a python proxy is an interesting thing but I’m pretty sure you could achieve a similar concept using .Net and Windows service but you may also ask yourself at what price since, if you ever need to cluster the whole thing you will need to put more synchronisation and robustness (crash proof) feature on that.
share|improve this answer
Thanks. good points :) – Bob Apr 20 '11 at 7:34

The game requires real-time response (under 1 sec) for each user.

And these are mobile phone users, with varying qualities of service (3G/3Gs/4G/wi-fi), reception, latency, jitter, fragmentation, etc. and you're expecting < 1s response time? Have you tested this with one phone let alone hundreds?

share|improve this answer
I'm talking about response time from the server and not the RTT of course :) I can't really control the RTT time. – Bob Apr 20 '11 at 7:32
BTW - I did test it on 3G/Wi-fi and I get about 1sec response. pretty awesome :) – Bob Apr 20 '11 at 7:33
Well done, that's pretty impressive. – gravyface Apr 20 '11 at 12:42
  1. Game servers usually work on custom protocol based on UDP protocol
  2. There is need to make this server for this protocol from the low levels, as far as I know there is no public framework or something to help
  3. For storing state use memory or some cache, not SQL DB
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.