从数据库获取更改/插入通知的标准方法 [英] standard method to get notfication from database on change/insertion

查看:42
本文介绍了从数据库获取更改/插入通知的标准方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试制作一个面向 1000-1500 个用户的聊天应用程序.当前发生的情况是,一旦我的网页加载完毕,我每秒都会发出一个 ajax 请求,以检查数据库中是否有任何新内容.我想知道这是否是标准做法,或者是否有更有效的方式在发生插入时以某种方式由服务器通知.

I am curently trying to make a chat application aimed at 1000-1500 users. What currently happens is once my webpage loads I make an ajax request every second to check if there is anything new in the database. I want to know if this is the standard practise or if there is a more efficient way to be notified by the server somehow when an insertion occurs.

推荐答案

使用 WebSockets.或者至少是 AJAX 轮询.每秒从 1500 个客户端发出一个请求很可能会杀死您的服务器.

Use WebSockets. Or at the very least AJAX polling. Firing a request every second from 1500 clients will most likely kill your server.

查看 http://socket.io/ 如果您愿意向您的堆栈引入新的东西.但是,如果您只使用 PHP,则可以使用 PHP websocket 解决方案.

Look at http://socket.io/ if you are open to introduce something new to your stack. But there are PHP websocket solutions out there if you are limited to PHP.

这篇关于从数据库获取更改/插入通知的标准方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆