PHP 驱动的详尽统计数据 - 服务器端文本文件或 MySQL 表?
我有一个拥有 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数据库是否真的是一个问题?
如果您能提供任何建议,我将不胜感激! :-)
I've got a gaming-oriented website with 200+ users. The site has a large database tracking user plays, and one of the motivations for continued participation is the extensive statistics and rankings (S&R) with which the site provides the user.
As the list of S&Rs tracked has grown, some of the more intricate calculations have been moved to tables within the database, rather than be generated on-the-fly in order to improve page loading speed.
However, I plan to move from extensive to exhaustive S&Rs by the end of the year, increasing the overall number of datapoints available to the user by a factor of 10. I've already decided to stop doing on-the-fly queries and to move all the calculations to a cron job, but I'm unsure where to store the data.
Given a user base <1000, would it make more sense to place this data within the database or read/write a text file for each user's stats?
These are the main pros and cons in my mind:
Storing S&Rs in the Database
+ 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
Storing S&Rs in Text Files
+ 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
But I've never done something of this magnitude before, so I'm not really sure (for example) if a 200+ table MySQL database is even really a problem?
I'd appreciate any suggestions you can provide! :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
任何流行的数据库软件都应该能够处理数百万个条目,拥有 200 多个表在这方面不是问题。
损坏的可能性不大,但在这种性质的站点上,您应该相当频繁地进行备份,并且最好在服务器外部存储副本 - 使用单个文件进行分发并减少一般故障的可能性,但也有很小的可能性发生问题。
数据库软件擅长对其数据执行任务,使用平面文件可能会迫使您编写自己的方法来处理它们,这很容易被证明是一项主要任务,但与使用平面文件相比,会损失速度的额外成本数据库(我只是假设这一点,我可能是非常错误的)。
Any popular database software should be able to handle millions of entries, having 200+ tables is not an issue on that end.
Corruption is unlikely, but on a site of that nature you should be doing backups fairly frequently, and preferable storing a copy outside the server - using individual files distributes and decreases the likelihood of a general failure, but there's also a small chance of problems ocurring.
Database software excels at performing tasks on it's data, using flat files would probably force you to write your own method to process them, and this could easily prove to be a major task, at the extra cost of a loss of speed compared to using a database (I'm just assuming this, I might be very wrong).