Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[server] increase getToken bucket size #20398

Merged
merged 1 commit into from
Nov 28, 2024
Merged

Conversation

filiptronicek
Copy link
Member

@filiptronicek filiptronicek commented Nov 28, 2024

Description

It seems like the rate limits we put in place with #20391 were not enough. This PR bumps the rate limits further to 500 reqs / minute. At this point, you'd have to be querying for the token 8 times per second to get rate limited.

Related Issue(s)

Fixes https://gitpod.slack.com/archives/C083C24UMHN

How to test

  1. Join my org
  2. Auth against our self-hosted bitbucket
  3. Start a workspace from https://ft-bump-gec41629acd9.preview.gitpod-dev.com/orgs/join?inviteId=5c4119ff-c3e2-48fc-adac-e47a814e23b9

Here are a few scripts that helped me with testing this:

For trying out git clones:

#!/bin/bash

mkdir -p ~/workspace/test-repos
cd ~/workspace/test-repos

for i in {0..1000}
do
REPO_URL="https://bitbucket.gitpod-dev.com/scm/tes/2k-repos-$i.git"
echo "Cloning repository $i: $REPO_URL"
git clone $REPO_URL
if [ $? -ne 0 ]; then
    echo "Failed to clone repository $i"
    # Continue with the next repository even if one fails
    continue
fi
done

echo "Finished cloning repositories"

For directly calling supervisor to get a token:

#!/bin/bash

# Initialize counters
total_time=0
success_count=0
fail_count=0
start_time=$(date +%s.%N)

for i in {0..1000}
do
    # Time each individual call
    iter_start=$(date +%s.%N)
    
    # Run the credential helper
    echo "host=github.com" | gp credential-helper get | grep "password" > /dev/null
    
    # Capture the exit status
    status=$?
    iter_end=$(date +%s.%N)
    
    # Calculate iteration time
    iter_time=$(echo "$iter_end - $iter_start" | bc)
    total_time=$(echo "$total_time + $iter_time" | bc)
    
    if [ $status -ne 0 ]; then
        echo "❌ iteration $i (took ${iter_time}s)"
        ((fail_count++))
    else
        echo "✅ iteration $i (took ${iter_time}s)"
        ((success_count++))
        # Uncomment next line if you want to see successful iterations too
        # echo "Success iteration $i (took ${iter_time}s)"
    fi
done

end_time=$(date +%s.%N)
total_runtime=$(echo "$end_time - $start_time" | bc)

# Calculate statistics
avg_time=$(echo "scale=3; $total_time / 1001" | bc)

echo "----------------------------------------"
echo "Execution Statistics:"
echo "Total Runtime: ${total_runtime}s"
echo "Average Time per Call: ${avg_time}s"
echo "Successful Calls: $success_count"
echo "Failed Calls: $fail_count"
echo "----------------------------------------"

@filiptronicek
Copy link
Member Author

On the linked preview env, I was able to clone 363 repos before being rate limited

@filiptronicek filiptronicek self-assigned this Nov 28, 2024
@filiptronicek
Copy link
Member Author

And for the credential helper calls:

✅ iteration 495 (took .022262539s)
✅ iteration 496 (took .020367080s)
✅ iteration 497 (took .017887390s)
✅ iteration 498 (took .020238330s)
✅ iteration 499 (took .020113700s)
❌ iteration 500 (took .017011259s)
❌ iteration 501 (took .017615850s)

@geropl
Copy link
Member

geropl commented Nov 28, 2024

Did not test, but change LGTM 👍

@roboquat roboquat merged commit fc65cf1 into main Nov 28, 2024
46 checks passed
@roboquat roboquat deleted the ft/bump-gettoken-rate-limits branch November 28, 2024 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants