3

I started noticing that post requests sent to our application server are getting stalled for around 7 seconds on the browser side for no discernible reason.

Environment :

  • Angular 1.4
  • Play Framework
  • Chrome 64.*
  • Server sent events (SSE)
  • POST request

The number of TCP connections, as seen from the Chrome console, are around 3-4 at the time of stalling as seen in Network -> Connection Id

If the user rapidly does around 4 UI operations that create a SSE subscription, followed by the POST, stalling is observed consistently.

I'm not really a UI dev so any help debugging is helpful.

212
  • 915
  • 3
  • 9
  • 19
  • 1
    I have isolated this to an upgrade from Chrome version 63 to 64 – 212 Mar 10 '18 at 21:56
  • Random idea: Try parallelizing the connections across different hostnames. This is fairly unnecessary for modern browsers, but I wonder if you'll notice any effect: https://stackoverflow.com/questions/34404336/how-to-parallelize-downloads-across-hostnames-on-wordpress – Jimmie Tyrrell Mar 13 '18 at 22:34

3 Answers3

1

I have seen this too, using Angular 1.4 with Chrome (not sure which version). In our case it seemed to be caused by too many parallel requests. We therefore bundled requests into batches. You can use this function if you like to give it a go and see if it helps in your case:

function _batchRequests(requests, batchSize) {
    function doBatch(batches, batchIndex, numBatches, deferred) {
        if (batchIndex === numBatches) {
            deferred.resolve();
            return null;
        }
        console.log('Doing batch ' + batchIndex);
        let p = [];
        let batch = batches[batchIndex];
        _.forEach(batch, (f) => {
            p.push(f());
        });
        return $q.all(p).then(() => {
            doBatch(batches, ++batchIndex, numBatches, deferred);
        }, (err) => {
            deferred.reject(err);
        });
    }
    let deferred = $q.defer();
    let b = batchSize || 3;
    let batches = _.chunk(requests, b);
    doBatch(batches, 0, batches.length, deferred);
    return deferred.promise;
}

Note that the above function depends on lodash for _.chunk and _.forEach.

see sharper
  • 11,505
  • 8
  • 46
  • 65
  • You may also throttle requests using a library like axios, eg: https://stackoverflow.com/questions/43482639/throttling-axios-requests OR https://medium.com/@matthew_1129/axios-js-maximum-concurrent-requests-b15045eb69d0 – Bobz May 24 '21 at 03:46
1

This is very similar to

Chrome stalls when making multiple requests to same resource?

You can try to make post unique, like adding some random number to the query or try to add a header to the response on a play side Cache-Control: no-store

Andriy Kuba
  • 8,093
  • 2
  • 29
  • 46
  • The linked case is different since it's dealing with a GET with the same resources. It's unlikely in this case that the POSTs will benefit from the cache-control header change. – Robert C Dec 18 '19 at 21:01
0

This issue was resolved in Chrome 66 and later. Went thorough a lot of the release docs but could not pin-point what caused or resolved it.

212
  • 915
  • 3
  • 9
  • 19
  • 1
    Using Chrome 90, the problem still exists! Chrome freezes when ajax calls limit (6) exceeded and never recovers! – Bobz May 24 '21 at 03:48