简体   繁体   English

PHP mysql为统计数据选择引擎类型

[英]PHP mysql choosing engine type for stats

I am trying to develop a interface for a networking system. 我正在尝试为网络系统开发接口。 Basically, a software puts all traffic datada through UDP and an other software collects, and inserts data into mysql (clients doesnt have mysql server, only server which has user interface access has mysql server). 基本上,一个软件通过UDP和其他软件收集所有流量数据,并将数据插入mysql(客户端没有mysql服务器,只有具有用户界面访问权限的服务器有mysql服务器)。 there are about 50 clients has really high traffic and insert operation on mysql server is really fast. 有大约50个客户端具有非常高的流量,并且在mysql服务器上的插入操作非常快。 but i am wondering about performance issues couse i am planing to print stats in realtime with push server or something, also, these traffic stats must be saved for a long time, so what kind of database engine i should use? 但我想知道性能问题,我计划用推送服务器或其他东西实时打印统计数据,这些流量统计数据必须保存很长时间,所以我应该使用什么样的数据库引擎? myisamm, innodb, archive? myisamm,innodb,存档? anybody can explain to me please? 有人可以向我解释一下吗? also i am open for suggestions too 我也愿意接受建议

I think the most important thing you need to do is set up an environment where you can do some testing and profile different approaches. 我认为您需要做的最重要的事情是建立一个环境,您可以在其中进行一些测试并分析不同的方法。

MyISAM can be wicked fast for the sort of thing you're talking about where you're only adding rows onto the end of the table and running selects against it - no deletes or updates. 对于你正在讨论的事情,MyISAM可能很快就会变坏,你只是在表的末尾添加行并运行选择它 - 没有删除或更新。

You'll need to archive older rows at regular intervals and I believe the archive storage engine might be a good fit for this, but I have never had occasion to use it and do not speak from experience there. 您需要定期存档较旧的行,我相信存档存储引擎可能非常适合这种情况,但我从来没有机会使用它,也没有根据那里的经验说话。 I doubt it would be usable as the main table for the app, though. 我怀疑它可以作为应用程序的主表使用。 You could consider some sort of partitioning eg where you store results in different tables by month. 您可以考虑某种分区,例如,按月将结果存储在不同的表中。

The book High Performance MySQL should probably be your first port of call. 高性能MySQL这本书应该是你的第一个停靠点。

Sounds like an imposing project - good luck with it. 听起来像一个宏伟的项目 - 祝你好运。

Here are the details of innodb and myisam 以下是innodb和myisam的详细信息

  • myisam is better for high read volumes, innodb for high update volumes due to table vs row locking. 对于高读取卷,myisam更好,因为表与行锁定,因此更新卷的innodb。

  • innodb is journaled, and can recover from crashes where myisam can't, much like NTFS vs FAT file systems. innodb是记录的,可以从myisam不能的崩溃中恢复,就像NTFS与FAT文件系统一样。

  • myisam has full-text indexing, innodb doesn't. myisam有全文索引,innodb没有。

  • innodb has transaction support, commits and rollbacks, myisam lacks these. innodb有事务支持,提交和回滚,myisam缺少这些。

so if you don't really care about updating and recovering tables, and don't need transaction support you can use MyISAM. 因此,如果您不关心更新和恢复表,并且不需要事务支持,则可以使用MyISAM。 To solve problem with large amount of data you can consider using MySQL partitions and then periodically archive older entries in backup tables with archive engine. 要解决大量数据的问题,您可以考虑使用MySQL分区,然后使用归档引擎定期归档备份表中的旧条目。
Also you can consider delayed inserts if you are really concerned about reading speed. 如果您真的担心阅读速度,也可以考虑延迟插入。

UPDATE : 更新:
For MyISAM tables, if there are no free blocks in the middle of the data file, concurrent SELECT and INSERT statements are supported. 对于MyISAM表,如果数据文件中间没有空闲块,则支持并发SELECT和INSERT语句。 Under these circumstances, you very seldom need to use INSERT DELAYED with MyISAM. 在这种情况下,您很少需要在MyISAM中使用INSERT DELAYED。 insert-delayed 插入延迟

您应该构建每天更新的统计表,您可以查询所需的统计信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM