1

Here is the issue:

Many ajax call going on , so i click a button to make a ticket which should be done instantly instead it stays there until all others before it are complete ! why is that?

How can i make it run with highest priority?

Image attached to understand it better:

enter image description here

Struggling with it for 2 days now so really need help on this one!

madth3
  • 7,275
  • 12
  • 50
  • 74
confusedMind
  • 2,573
  • 7
  • 33
  • 74
  • Different browsers have a different number of connections available for ajax requests to a single host name. http://www.browserscope.org/?category=network – Sethcran Jul 25 '13 at 22:21
  • @Sethcran oh and i run 12 so it must be until 5 are left so it make it 6 by running the ticket now i see. But is there no way to prioritize? or pause and rerun the calls? – confusedMind Jul 25 '13 at 22:27
  • http://stackoverflow.com/questions/8126777/can-you-add-priorities-to-ajax-calls can show you how to add a priority if you want, but you'll still be forced to wait for a request to complete before your next highest priority will fire. http://stackoverflow.com/questions/446594/abort-ajax-requests-using-jquery shows how you could abort a current request. – Sethcran Jul 25 '13 at 22:31

1 Answers1

0

I would look at what is really needed. Do you really need 12 concurrent ajax calls per user/session? Your going to incur serious server issues processing that many requests. I see a lot of requests go to the same URI; does it make sense to wait until one of those requests are finished before processing the next? Is there a way to "bundle" your requests into one? or fewer? Chatty interfaces tend to lead to issues down the road.

You could keep a tally of how many concurrent requests you have going and never let it go above a threshold, queuing requests that do, unless one is "High priority".

But seriously rethink making that many requests at a time.

Update

Since you are making requests to multiple outside locations, based on one use action. Have the one user action make a single request to your web server. Then have your web server make the requests on behalf of the user, bundle the results all together and return them in one response to the user. This will also help you maintain your external connections, and your user has a unified experience with your website.

Update 2

If you combine your requests of the six into one you can have your webserver forward those requests on separate threads by making them async as explained here. The user will not see any results until all are completed, which may seem slow. But multiply that by 1000 concurrent users and it will be faster.

Jay
  • 6,224
  • 4
  • 20
  • 23
  • 6 of them bring back data from 6 airline websites, (6for depart flight and 6 for return flights ) and this way its fast what do you suggest how do i solve it in such a way its speedy and less load? – confusedMind Jul 25 '13 at 22:35
  • @confusedMind See Updates. – Jay Jul 25 '13 at 22:37
  • Can you please explain "Then have your web server make the requests on behalf of the user, bundle the results all together and return them in one response to the user" a link to article would be highly appreciated – confusedMind Jul 25 '13 at 22:39
  • Looking at your screenshot you may already be doing this. Basically your website acts as a proxy, so the web user doesn't go directly to your external airline websites. My suggestion from here would be to bundle the requests so all 6 are in one. It may seem slower now, but when in production having 1000s of users make these requests will kill your server. – Jay Jul 25 '13 at 22:43
  • but in that case, the result will be one after another :| will make the searching slow wont it? – confusedMind Jul 25 '13 at 22:45
  • So i am thinking now of combining all the functions in 1 , call but after each function update the page so what would i do for that? How to update literal or div with results during the function/ – confusedMind Jul 25 '13 at 22:51
  • The other option, if you async the calls is to have the response return immediately, then poll the server for updates. Each poll should be delayed and will reduce the number of concurrent requests you have going. - But how to update, is a different question. I'd be happy to chat with you if you jump into the c# room – Jay Jul 25 '13 at 22:51
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/34197/discussion-between-confusedmind-and-jay) – confusedMind Jul 25 '13 at 23:02
  • I solved it using your suggestion :) i do one ajax call now and it use curl to to do parallel Get request takes likes 3-8 seconds max perfect for what i needed. Thank you – confusedMind Jul 27 '13 at 21:49