高频Ajax和MySQL的睡眠超载 [英] High Frequency Ajax and MySQL Sleep Overload

查看:139
本文介绍了高频Ajax和MySQL的睡眠超载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前工作的一个光PHP框架,一些高要求的AJAX我的网站使用,已经运行到有我彻底难倒一个有趣的问题。阿贾克斯是一系列通知,这样的JavaScript将关闭一个Ajax请求新的信息每隔30秒。这AJAX是活跃在整个网站的每个页面上,所以我知道它有很多的要求,为上百个用户在任何给定时刻浏览该网站,多用几个窗口打开。

I am currently working on a light php framework to use with some high request ajax for my site, and have run into an interesting problem that has me completely stumped. The ajax is for a series of notifications, so the javascript sends off an ajax request for new information every 30 seconds. This ajax is active on every page of the entire site, so I realize its a lot of requests as several hundred users are browsing the site at any given moment, many with several windows open.

语法明智的一切都是完美的。问题是,当我启动了AJAX为我的社区,有30的堆积 - 40 SLEEP命令在MySQL数据库中。所有这些似乎忽略10秒的设定超时。它会影响整个网站的表现结果。

Syntax wise everything is perfect. The problem is, when I activated the ajax for my community, there is a build up of 30 - 40 SLEEP commands in the MySQL database. All of which seem to ignore the set timeout of 10 seconds. It effects the entire site's performance as a result.

我的理解是,剩下的睡眠命令尚未关闭的连接的结果。我用的MySQLi面向对象的类,并扩展了它与我自己的一些功能。一切都是通过课本和双重核对的文件,我已经确信,每个小片的MySQLi类被关闭并释放。

My understanding is that left over sleep commands are the result of a connection that hasn't been closed. I am use the MySQLi object oriented class and have extended it with a few functions of my own. Everything is by the text book and double checked against the documentation, and I've made sure that every little piece of the MySQLi class is closed and released.

如果任何人有任何的智慧和经验,这种类型的效果,我将不胜感激的任何建议。

If anyone has any wisdom or experience with this type of effect, I would be most grateful for any advice.

推荐答案

您是否尝试过推的方式与您当前的拉/轮询方法?看看彗星:

Have you tried a push approach versus your current pull/polling approach? Take a look at Comet:

  • Comet a new approach to AJAX applications
  • Comet (wikipedia)
  • Comet programming: Using AJAX to simulate server push
  • Ajax Push Engine

然而,也有一些缺点,主要的一个是你必须要保持一个开放的连接,以及一些浏览器限制连接可以保持数。下面这篇文章谈论使用彗星的利弊,并提出了一个混合轮询方法:

However, there are some downsides, the main one being you have to maintain an open connection, and some browsers limit the number of connections you can maintain. The following article talks about the pros and cons of using Comet and suggests a hybrid-polling approach:

  • <一个href="http://www.ibm.com/developerworks/websphere/techjournal/0711_col_burckart/0711_col_burckart.html"相对=nofollow>彗星的诱惑

下面是谈彗星也是一个计算器问题:

Here is a stackoverflow question that talks about comet also:

  • <一个href="http://stackoverflow.com/questions/523546/compatibility-of-comet-with-current-technology">Compatibility彗星以目前的技术

这篇关于高频Ajax和MySQL的睡眠超载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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