Jira REST API concurrent requests fail

I am having issues with the Jira API. The code I have below works for the public Altassian Jira. If I change the $versions, $options, and $urls specifically for my Jira installation, then I end up getting a maximum of only 10 successful responses.

For my Jira installation:

- I change $versions to be specific to my installation

- I change $options to use port 80 and to use an 'Authentication: Basic ...' header

- I change $urls to use my installations url and to use http instead of https

My questions are:

- Is there a setting for Apache that limits the number of concurrent basic authentication requests for each user?

- Is there a setting for Jira that limits the number of concurrent API requests for each client?

Any help is appreciated.

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>ghi</title>
    </head>
    <body>
        <?php
            $versions = array(
                "JRA" => array("6.1","6.0","5.2","5.0","4.4","4.3"),
            );
            $jqls = array(
                "one"   => "project='%s' AND fixVersion='%s'",
                "two"   => "project='%s' AND fixVersion='%s'",
                "three" => "project='%s' AND fixVersion='%s'",
                "four"  => "project='%s' AND fixVersion='%s'",
                "five"  => "project='%s' AND fixVersion='%s'",
                "six"   => "project='%s' AND fixVersion='%s'",
                "seven" => "project='%s' AND fixVersion='%s'",
                "eight" => "project='%s' AND fixVersion='%s'",
                "nine"  => "project='%s' AND fixVersion='%s'"
            );
            $options = array(
                CURLOPT_RETURNTRANSFER => 1,
                CURLOPT_PORT => 443,
                CURLOPT_HTTPHEADER => array(
                    'Content-Type: application/json'
                )
            );
            foreach ($versions['JRA'] as $ver) {
                foreach ($jqls as $id => $query) {
                    $urls[$ver][$id] = 'https://jira.atlassian.com/rest/api/latest/search?startAt=0&maxResults=0&jql=' . rawurlencode(sprintf($query, 'JRA', $ver));
                }
            }
            set_time_limit(0);
            echo "<pre>";
            foreach ($urls as $ver => $group) {
                foreach ($group as $id => $u) {
                    $ch = curl_init($u);
                    curl_setopt_array($ch, $options);
                    $curls[$ver][$id] = $ch;
                }
            }
            $mh = curl_multi_init();
            foreach ($curls as $ver => $group) {
                foreach ($group as $id => $ch) {
                    curl_multi_add_handle($mh, $ch);
                }
            }
            $running = null;
            $failures = 0;
            do {
                $mrc = curl_multi_exec($mh, $running);
                $info = curl_multi_info_read($mh);
                if (false !== $info && $info['result'] != 0) {
                    $failures++;
                }
            } while ($running > 0);
            echo 'failed requests: ' . $failures . "\n\n";
            foreach ($curls as $ver => $group) {
                foreach ($group as $id => $ch) {
                    $resp = json_decode(curl_multi_getcontent($ch));
                    if (gettype($resp) == 'object') {
                        $results[$ver][$id] = $resp->total;
                    } else {
                        $results[$ver][$id] = gettype($resp);
                    }
                    curl_multi_remove_handle($mh, $ch);
                }
            }
            curl_multi_close($mh);
            print_r($results);
            print_r($urls);
            echo "</pre>";
        ?>
    </body>
</html>

1 answer

1 accepted

Hello,

I am not aware of any limit in Jira or apache by default. So its probably a module installed in their Apache.

Here, we actually have a QOS in place on our Jira instance because we had user that were spammimg it.

We installed mod_QOS a module for apache : http://opensource.adnovum.ch/mod_qos/

before installing this, we could hit up to 80/sec by 1 ip of requests easily which was spamming our server. We limited it at 3/sec

Martin

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

809 views 2 19
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you