0

I haven't worked with servers in a while, so this is probably a really obvious question.

I'm using WeBRick on Heroku to host a Rails application (I know I should use a better server, but it's still very early). When the user clicks a button on my application, it starts about 100 Ajax calls at once to the server, each of which is going to call a method on the server side that accesses a URL, gets some data from it, and returns that. All the responses are put together into something cohesive once the client determines that all the Ajax calls have finished (using a counter).

It's slow in the first place, and I wasn't expecting my free Heroku app to be able to handle a lot of people using it at once gracefully. I was expecting it to run really slowly once a lot of people started using it.

I opened up two tabs in my Chrome and had them both make requests at the same time to Heroku. What happened there was that one person got to use it normally, but the other had to wait until the first person's requests had completely finished before starting.

Then I opened up one tab in Chrome and the other in Safari, except this time I used localhost instead of Heroku. Chrome went first and ran normally, and then I clicked the button in Safari. Safari didn't do anything for a while, and then eventually it started and they both seemed to be going more slowly.

What happened in the first case, and what are my options for improving this situation? I would also appreciate someone pointing to a resource or filling me in on the basics of what I don't know in this case.

Andrew Latham
  • 5,982
  • 14
  • 47
  • 87
  • It's possible Chrome executed the calls on the active tab only, rather than everything at once. – Ioannis Karadimas Sep 24 '12 at 04:38
  • 2
    Having one client execute 100 simultaneous AJAX requests is generally bad design - 10 concurrent users could generate 1000 requests to your server. I would suggest rewriting it to load all the data in one request and delegate within the javascript that handles the response. – doublesharp Sep 24 '12 at 04:46
  • I originally had that, but it would time out. It's scraping from 100 URLs - I don't know of a good way to do it, although I'd like to learn one! – Andrew Latham Sep 24 '12 at 04:49
  • Any point in asking what you are trying to scrape / make API calls to so that one might suggest a better setup? – Thomas Klemm Sep 24 '12 at 16:15
  • The player and tournament pages at www.uschess.org. – Andrew Latham Sep 24 '12 at 18:46

0 Answers0