3

My project is a HTTP chat using some Jquery, PHP and Mysql.

Jquery infact polls the database every N seconds to check if I have receieved new messages (polling form a mysql table).

Since chat has now >100 connections, mysql gets now 100 requests within N seconds.

What are the best practices, database choice to optimize it ? (it must remain an HTTP chat without using some server sockets)

regards

PS. Maybe MYSQL is not the good choice

4

3 回答 3

3

MySQL 作为数据库很好,但您对它的轮询使用并不是最佳实践。
RDBMS 是该工作的错误工具。

查看消息队列解决方案。以下是一些资源:

于 2012-12-13T00:46:49.433 回答
2

我会选择 MySql,因为它的重量很轻。PHP 和 MySql 相处得很好。由于您将对数据库进行多次更新和多次读取,因此 InnoDB 引擎将最适合这种情况。如果您选择 MyIsam,您可能会遇到问题,因为它一次只适合一项工作(更新或阅读)。

于 2012-12-13T00:17:02.567 回答
1

Look into in-memory databases. Chats are normally not something people persist; so a transient database might be just the ticket. For instance, SQLite can do it.

However, I'd be much more worried about your web server, I think. :)

Any particular reason not to use sockets? This scenario is what they're created for. (Probably inflexible hosting service?)

于 2012-12-13T00:16:25.327 回答