Why does AJAX randomly take forever? - ajax

Sometimes, perhaps once every few hundred AJAX requests and/or where AJAX requests are executing in quick succession, I've seen a request hang for up to several minutes before it completes. The weird thing is that the request completes successfully AND neither my machine or the server are really doing anything either (e.g. CPU and other resources are not spiking during the "hang").
I've noticed this issue with various web services too, so it isn't just my own website. It also isn't database related as it has happened on non-database sites. It also only seems to show up in non-localhost environments.
When I personally use AJAX, I am also using jQuery, so this might also be a jQuery issue. I also mostly use Firefox, so I don't know if this is just a Firefox issue or if it is an issue any browser could have. I've run into the issue on multiple computers in multiple locations.
If you have run into this issue before and "fixed" it, I would appreciate the solution you came up with.

Use a HTTP debugger like Firebug or Fiddler to track the AJAX requests to see how much time it takes (possible timeout issue due to server setting?) & what HTTP response status code it returns when it fails. Use the HTTP response status code to troubleshoot the issue.

Related

Antivirus blocking Ajax sync requests

Out of a sudden I realized that the Ajax requests that I make synchronously work no more and the only thing left for me is to close the browser tab as it hangs forever. The problem is not with a particular request but with all synchronous Ajax requests in my web application. If I turn them to async:true, then the problem gets solved. After some digging I found out that Kaspersky antivirus was blocking them. All the computers that I test the application on use Kaspersky for "virus-fighting" purposes. I tried with all major browsers and all present the same problem. Now a few things to note:
I didn't use to have this problem just a couple hours ago.
The application server also has Kaspersky running but AJAX sync request work normally(which makes me come to a conclusion that the problem is with the response)
I've put another simple test application with AJAX sync request and they work normally
Other antivirus programs don't cause such a problem.
So do you have any ideas what the problem might be? Is it something that I need to ask in Kaspersky forum?

JMeter fails to simulate browser response time

I'm trying to simulate a connection to a website. The goal of the simulation is to collect statistics on page loading time on browser side.
I configured JMeter Flagging the option Retrieve Embedded Resources in order to simulate the real time to load the whole page. The issue is that while from a real Browser i have a response time (let's assume for the page A the response time is 10 seconds) in JMeter I found i response time 20 times higher.
It seems JMeter takes a much longer time to gather embedded resources (e.g. js, images, ...)
Do you have any suggestion for this issue?
Kind Regards
Update 31/07
I discovered some resources are not completely downloaded. Using Firebug i see some components with 0 bytes downloaded that the browsere keep trying to download (but the user do not percieve since the page is loaded). Therefore i suspect JMeter keeps trying downloading it. Is there any chance to set a timeout to overcome this kind of situation?
Update_1 31/07
I figured out that the issue is related with nested iframes. setting httpsampler.max_frame_depth=0 i get the correct time. however i would like to understand the reason of this issue. Do I have to set other paramters?
Disable browser cache and re-run your test in browser.
Jmeter will not store cache, unless otherwise specified.
Hope this will help.
Add a HTTP Cache Manager to your test plan.
Real browsers retrieve images, scripts, styles, etc. but do it only once. In order to simulate browser behavior you need to configure JMeter appropriately.
See How to make JMeter behave more like a real browser guide for more test elements which can be used for this.

Why is it taking so long for Meteor to load my data on Heroku?

I am using Meteor on Heroku (free tier) with MongoHQ. My app is very simple right now, it loads 3-4 entries from a Collection, but when I deploy it to Heroku, I am seeing ridiculous load times (1-2 minutes). The HTML is rendered immediately. When I deploy to Meteor.com's free server, load times are a lot lower but still about 15 seconds for 4 tiny pieces of data. I'm not seeing this whatsoever when I deploy locally, app pulls data from the DB right away.
It is worth noting that I don't think it's an "idling" issue for Heroku. Even if I already have one browser window with the app just opened, if I use a different browser and try again I still get 1-2 minute load times. Once the data is loaded, however, performance goes back to being great, I can read and write with no problems.
What am I missing? I'm not seeing any errors in the console, mongo shows several queries in the logs and shows that it is responding quickly with 4 documents, but apparently somewhere in the middle there's a traffic jam. Any help with this is greatly appreciated, if I can't get past this Meteor is useless for my needs right now.
UPDATE: I've been watching it closely in Firebug, and it looks like the performance is largely inconsistent. Sometimes a simple refresh will take 1 minute, sometimes it will take 10 seconds. But what I've noticed is that the times when its slow, it GETs the sockjs/info file, then right after that the sockjs POST is aborted (sometimes multiple times). When it runs fast, the POST and subsequent POSTs run smoothly
Slow:
GET http://pocleaderboard.herokuapp.com/sockjs/info 200 OK 22ms
POST http://pocleaderboard.herokuapp.com/sockjs/029/su0d77fb/xhr Aborted
GET http://pocleaderboard.herokuapp.com/sockjs/info 200 OK 27ms
POST http://pocleaderboard.herokuapp.com/sockjs/132/uljqusxd/xhr Aborted
GET http://pocleaderboard.herokuapp.com/sockjs/info 200 OK 28ms
POST http://pocleaderboard.herokuapp.com/sockjs/154/kcbr6a5p/xhr Aborted
Fast(er):
GET http://pocleaderboard.herokuapp.com/sockjs/info 200 OK 1.08s
POST http://pocleaderboard.herokuapp.com/sockjs/755/xiggb555/xhr 200 OK 1.02s
Meteor gets loaded that fast locally, because it doesn't depend on your internet connection and the files can just be read from your harddrive and don't need to be downloaded.
And once the data is loaded it's the same everywhere you host, because the client (you) perform all actions on your cached mongo database and then just wait for the server to say if the action was alright or not.
But for the Heroku loading times, I have no idea, Sorry!
UPDATE:
These are the long-pulls from SockJS that is used by Meteor.
Normally these pulls only get Aborted on a hot code push (when a file is added/changed/removed).
Either you or Heroku seem to write or change something in the directory.
Because then a hot code push may be initiated by Meteor.
Heroku may not support web-sockets, which means you're stuck with the slower polling approach. See this:
https://devcenter.heroku.com/articles/using-socket-io-with-node-js-on-heroku

Ajax submitted form takes long time to process

I am wondering where this comes from : I have a 2 field form for a site that I am building and for some reason, the post request takes up to 13 seconds to complete, according to firebug... The script literally just sends an email in plain text with the user inputs and that's it, nothing complicated.
I am wondering where that delay could come from, any idea ?
Here is a link to a dev version : http://vps-sd.com/sd2012/
I tend not to click links to sites I don't trust, but it could be either
1) Network latency. Are you on a vpn? Where is the dev server hosted? You can use traceroute or something like that to follow the request from the command line.
If both the client and the server are on your dev box this should not be an issue.
2) For really long requests, I think it is more likely something in your dev server is screwed up. It could be the code, or it could be that the dev server is having some issues. Did you log onto the dev server and look at its load? Has some process gone haywire? Has it used all its memory? Did you add some simple benchmarking code to the application server?
You need to diagnose where exactly the slowdown is.

Synchronous AJAX call fails on iPad, but not other platforms and browsers

Does anyone know why a synchronous ajax call would fail and give the following error on Safari on an iPad, but the same code works fine on all other platforms and browsers I've tested so far?
NETWORK_ERR: XMLHttpRequest Exception 101: A network error occurred in synchronous requests.
That error suggests that I'm attempting a cross-domain request, but I'm not; the requested URL is on the same host, and in fact it's a relative URL. Even in trivial tests, this fails on the iPad (and works on all other platforms and browsers, including Safari), so I'm confident I've ruled out any possibility of a time out.
Also, the same request, if made asynchronously, works perfectly on the iPad; it's only synchronous requests that give the 101 exception. It's driving me crazy!
One more bit of detail: this only happens on my production server. The synchronous ajax call actually works fine on my development server. Both servers require the same client certificate... so I don't think there's any difference there. I can't think of any difference between the two servers that could have an effect here.
Any insight into this problem would be greatly appreciated. Thanks!
It turns out the key difference between our development and production systems is the certificate requirement.
The issue turns out to be a problem with the way XMLHttpRequest.send() on the iPad version of Safari processes a synchronous request on a domain that is certificate-protected. I can't explain the internals of the method, but somehow it has a problem and throws the 101 exception, believing it--apparently--to be a cross-domain request. Again, the same request made asynchronously on the same certificate-protected server works just fine. Frustrating case, and one with no solution!

Resources