我有一个拥有 200 多个用户的面向游戏的网站。该网站有一个大型数据库跟踪用户游戏,继续参与的动机之一是该网站为用户提供的广泛的统计数据和排名 ( S&R )。
随着跟踪的 S&R 列表的增长,一些更复杂的计算已移至数据库中的表中,而不是动态生成以提高页面加载速度。
但是,我计划在今年年底前从广泛的 S&R 转变为详尽的 S&R,将用户可用的数据点总数增加 10 倍。我已经决定停止进行动态查询,并将所有计算移至 cron 作业,但我不确定将数据存储在哪里。
给定用户群<1000,将这些数据放在数据库中或为每个用户的统计数据读/写一个文本文件是否更有意义?
这些是我认为的主要优点和缺点:
在数据库中存储 S&R
+ cross-user comparisons are easy and fast
+ faster cron jobs because there's no need to write to many, many files
- database table count will jump from ~50 to 200+ (at least)
- one point of failure (database corruption) for all site data
- modifying S&R structure requires modifying database as well
在文本文件中存储 S&R
+ neatly organized and distributes data corruption risk
+ database is easier to navigate
+ redesigning S&R structure is done by simply modifying script and
overwriting all text files, rather than adjusting database tables
- cron job will have to read/update XXX files each time
- cross-user comparisons are difficult and time-consuming
但是我以前从来没有做过这么大的事情,所以我不确定(例如)一个 200 多个表的 MySQL 数据库是否真的是一个问题?
我很感激你能提供的任何建议!:-)