Page 1 of 1
How do chess servers store ongoing games?
Posted: Thu Sep 20, 2012 2:02 am
by kevinfat
Do chess servers typically keep games in progress as something in a SQL database or do they store games all in memory?
Re: How do chess servers store ongoing games?
Posted: Wed Dec 05, 2012 3:28 pm
by Don
I have to assume you are building a chess server? This is something I have considered myself but it's a lot of work. I have already build a server strictly for go programs called CGOS.
I believe the standard practice is to use a sql database as it has the important ACID properties needed.
However, sql can be quite slow. If you are indeed building your own server you might consider using some of the no-sql alternatives. In the past few years there has been an explosion of these.
It isn't out of the question to use some hybrid approach. I know this because my server is backed by sqlite3 but I don't use it for everything. I also built a distributed autotester and it was not capable of playing multiple games per second until I scrapped the sql approach. In Linux you can use flat files which is what I did, you can atomically update flat files if you know what you are doing. In Windows I am less sure because I do not understand the gory details of how the file system works and I understand that rename is not necessary atomic.
There is a superbly fast database called redis that I really like and I have played around with. It is a pure in memory database so you need a lot of memory which can limit it's use in tiny hosted servers - but it has a mode where only the keys are kept in memory and the data on disk. There are many other no-sql alternatives you could look at. You give up the flexibility to construct arbitrary queries on the spot, but you gain a lot of performance and unless you have a need for many tables sql might be overkill - and thus the explosion in no-sql alternatives.
Don
Re: How do chess servers store ongoing games?
Posted: Wed Dec 05, 2012 10:20 pm
by User923005
There are some SQL database systems that are superbly fast, such as MonetDB.
monetdb.org/Home
There are also some systems like FastDB and Gigabase that hold data primarily in memory (fastdb as memory mapped and gigabase as demand paging) that also use a disk based backing store.
garret.ru/fastdb.html
garret.ru/gigabase.html
Redis is indeed quite nice, as are many similar alternatives like Mongodb and Hypertable
redis.io
mongodb.org
hypertable.org/
SQLite is a very nice SQL database that is simple to use and maintain.
sqlite.org/
The huge advantage of SQL interfaces is that they have standards based access (ODBC, JDBC, OLEDB, .net, etc.) which makes it easy to write code for them and also makes it easy to change sources.
I guess that SQLite will be fast enough for any chess server. It also has memory based tables if you want to use them, or you can use memcached with it (or other database systems) to get more speed too.
memcached.org/
Example of using memcached to speed up SQLite:
larryullman.com/2010/06/28/caching-the-database-schema-using-memcached-with-yii/
This is a good link for NoSQL database systems:
nosql-database.org/
This is a good link for comparing SQL database systems:
en.wikipedia.org/wiki/Comparison_of_relational_database_management_systems
If you want to use any database system, it is good to find out what operating systems the database system will run on. That way, it becomes a lot more flexible if you decide you want to use a Windows server or a Linux server or a BSD server, etc.
For several of them, they will run on Windows, but it is definitely a second class citizen in that regard.
Keep in mind that most memory based alternatives have a downside. If something goes wrong, data might be lost. Often, this is immaterial. But sometimes it matters a lot.
I took the http and www off of the front of all my URLs because the idiot software says I can only have five URLs in a post.