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

Research and prep for API outage drill #3965

Closed
3 tasks done
lbeaufort opened this issue Sep 19, 2019 · 3 comments
Closed
3 tasks done

Research and prep for API outage drill #3965

lbeaufort opened this issue Sep 19, 2019 · 3 comments
Assignees
Milestone

Comments

@lbeaufort
Copy link
Member

lbeaufort commented Sep 19, 2019

@lbeaufort lbeaufort added this to the Sprint 10.2 milestone Sep 19, 2019
@patphongs patphongs changed the title Research for outage drill Research and prep for outage drill Sep 19, 2019
@lbeaufort lbeaufort removed their assignment Sep 27, 2019
@patphongs patphongs modified the milestones: Sprint 10.2, Sprint 10.3 Oct 4, 2019
@patphongs patphongs changed the title Research and prep for outage drill Research and prep for API outage drill Oct 8, 2019
@lbeaufort lbeaufort self-assigned this Oct 16, 2019
@lbeaufort
Copy link
Member Author

lbeaufort commented Oct 18, 2019

WIP PR with queries and additional locust testing: https://github.com/fecgov/openFEC/pull/4031/files

    """Extract API query from Kibana log file"""
    import csv
    import json

    with open("/Users/lbeaufort/Documents/FEC-LB-big-queries.csv", "r") as file:
        reader = csv.reader(file, delimiter=',')
        # Endpoint/uery lookup
        queries = {}
        for row in reader:
            # Column 4 has the queries. Throw out some bad data
            if 'GET' in row[3] and 'maxRedirects' not in row[3]:
                # Get the endpoint- everything after the first '/' to the first '?'
                endpoint = row[3].partition("/")[2].partition("?")[0]
                # Get the query param string - everything between the ? and the ' '
                query_parameters = row[3].partition("?")[2].partition(" ")[0]
                # Split each query pair out into a list
                parameter_groups = query_parameters.split("&")
                # Make a dictionary of the parameters (this is how locust needs them)
                query_dict = {}
                for result in parameter_groups:
                    # Split the parameters from the values
                    parameters_split = result.split("=")
                    query_dict[parameters_split[0]] = parameters_split[1]
                # Add to the endpoint/query lookup
                if not queries.get(endpoint):
                    queries[endpoint] = [query_dict]
                else:
                    queries[endpoint].append(query_dict)

        print(json.dumps(queries, indent=1))

@lbeaufort
Copy link
Member Author

lbeaufort commented Oct 18, 2019

I tested these queries in stage with Locust and was able to create an outage.

We will want to look at the API umbrella logs to see what kind of load we're trying to replicate

August 7: 3,030,072 hits
Peak hour: 277,015 hits = 4616/minute = 77/second

Screen Shot 2019-10-18 at 1.16.43 PM.png

@lbeaufort
Copy link
Member Author

lbeaufort commented Jan 13, 2020

query_dict[parameters_split[0]] = parameters_split[1] this didn't properly handle multiples, IE multiple contributor names. It would have overwritten any previous value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants