1330316 AJAX请求可以崩溃我的服务器吗?

I'm building a small PHP/Javascript app which will do some processing for all cities in all US states. This rounds up to a total of (52 x 25583) = 1330316 or less items that will need to be processed.

The processing of each item will take about 2-3 seconds, so its possible that the user could have to stare at this page for 1-2 hours (or at least keep it minimized while he did other stuff).

In order to give the user the maximum feedback, I was thinking of controlling the processing of the page via javascript, basically something like this:

var current = 1;
var max = userItems.length; // 1330316 or less


function process()
  if (current >= max)

  $.post("http://example.com/process", {id: current}, function()
        current ++;

In the html i will have the following status message which will be updated whenever the process() function is called:

<div id="progress">
   Please wait while items are processed.
   <span id="current">0</span> / <span id="max">1330316</span> items have been processed.

Hopefully you can all see how I want this to work.

My only concern is that, if those 1330316 requests are made simultaneously to the server, is there a possibility that this crashes/brings down the server? If so, if I put in an extra wait of 2 seconds per request using sleep(3); in the server-side PHP code, will that make things better?

Or is there a different mechanism for showing the user the rapid feedback such as polling which doesn't require me to mess with apache or the server?

2010/02/14 22:36
  • codeigniter
  • php
  • ajax
  • jquery
  • javascript
  • 点赞
  • 收藏
  • 回答