goose

repository·main·Indexed 21 days ago

https://github.com/tag1consulting/goose

A high-performance load testing framework built in Rust, inspired by Locust. It allows developers to simulate realistic user behaviors to identify performance bottlenecks in web applications. The ecosystem includes the goose-eggs helper crate for HTTP response validation and GooseBot, an AI-driven code review integration for GitHub Actions.

Tokens
63.8K
Snippets
160
Records
280
Agent score
75%

What's inside goose

  1. Overview of Goose load testing capabilities

    main

    Goose is a load testing framework designed for simulating complex, stateful user behaviors rather than just high-volume HTTP requests. It is particularly effective for:

    • Complex User Workflows: Testing multi-step processes like checkout flows, user registration, or content management.
    • API Load Testing: Validating REST APIs, GraphQL endpoints, or microservice interactions.
    • Performance Regression Testing: Integrating into CI/CD pipelines to catch regressions.
    • Capacity Planning: Identifying infrastructure scaling limits and bottlenecks.
    • Coordinated Omission Detection: Identifying when server slowdowns affect more users than simple metrics suggest.

    Key differentiators include support for Stateful Testing (maintaining sessions, cookies, and authentication), Realistic Load Patterns (simulating actual user behavior), and high Flexibility through custom logic and data-driven tests.

  2. Overview of Goose Load Testing Framework

    main
    Goose is a high-performance load testing framework built in Rust, inspired by Locust. It is designed to simulate realistic user behaviors on web applications with high scalability and speed. Unlike Python-based alternatives, Goose leverages Rust's async programming to provide significant performance advantages and efficient resource usage. It is specifically designed to mitigate the 'coordinated omission' problem, ensuring that performance metrics remain accurate even under heavy load.
  3. Core capabilities of Goose Load Testing Framework

    main

    Goose is a load testing framework that supports the following core functionalities:

    Load Testing & User Simulation

    • Basic Load Testing: Creating and executing simple load tests.
    • User Simulation: Spawning and managing simulated users.
    • Scenarios & Transactions: Defining and executing user workflows.
    • Weighted Selection: Controlling the frequency of scenarios and transactions.
    • Transaction Sequencing: Ordered execution of transactions.
    • Request Throttling: Limiting request rates to prevent overwhelming targets.

    Protocol & Request Management

    • HTTP Requests: Support for GET, POST, HEAD, DELETE, and other HTTP methods.
    • Session Management: Maintaining state across requests.
    • Cookie Management: Automatic cookie handling across requests.
    • Header Management: Custom HTTP headers for requests.
    • TLS Support: Support for rustls.
    • Request Customization: Configuration for timeouts, redirects, and other options.

    Metrics & Reporting

    • Metrics Collection: Gathering and reporting performance data.
    • Coordinated Omission Mitigation: Statistical corrections for accurate metrics.
    • HTML Reports: Graphical representation of test results.
    • Test Plans: Complex load patterns with controlled scaling.
  4. Understand Umami load test user behaviors

    main

    The Umami load test simulates three distinct user profiles with different weights and transaction patterns:

    User TypeWeightPause DurationKey Transactions
    Anonymous English400-3sFront page, basic page, article/recipe listings, random nodes, term filtering, search, and contact form feedback.
    Anonymous Spanish90-3sSame as English, but using Spanish language paths/content.
    Admin User13-10sLogs in (English), loads front page, article listing, and performs an 'edit and save' on an article to flush caches.

    All users also load static elements on every page they visit to simulate realistic browser behavior.

  5. Analyze GraphQL load test metrics

    main

    When performing load tests on GraphQL endpoints, Goose provides specialized reporting that helps distinguish between different GraphQL operations even though they all use the same HTTP method and endpoint.

    Key aspects of the GraphQL metrics output include:

    • Named Operations: Instead of seeing generic POST requests, the report displays custom names for each GraphQL operation (e.g., get all users, create user).
    • Request Grouping: All GraphQL requests are identified as POST requests to the configured GraphQL endpoint.
    • Transaction Timing: Metrics show the duration of complete GraphQL transactions, which may involve multiple steps.
    • Weighted Distribution: If you have configured weights for your transactions (e.g., a 3:2:1:1 ratio), the # times run and trans/s metrics will reflect this distribution.
    • Status Codes: Note that GraphQL often returns an HTTP 200 status code even when the response body contains GraphQL-level errors. Goose reports the HTTP status code (e.g., [200]) in the final summary.
  6. How GooseUser and ramp-up/down work

    main

    A GooseUser is a thread that repeatedly runs a single Scenario for the duration of the load test. You can control the lifecycle of these users using the following parameters:

    • User Count: The total number of users to simulate (e.g., via the --users flag).
    • Increase Rate: The rate at which new users are launched during the ramp-up phase (users per second), configured via --increase-rate.
    • Decrease Rate: The rate at which users are removed during the ramp-down phase (users per second), configured via --decrease-rate. If not configured, Goose shuts down all users immediately when the test completes.
    • Throttle: A mechanism to limit the request rate of individual users by introducing delays between requests, simulating more realistic behavior.
  7. Manage LLM costs and token usage in GooseBot

    main

    To control API usage costs, implement the following strategies:

    • Usage Monitoring: Track token usage per PR and set daily/monthly limits.
    • Optimization: Chunk large PRs, filter out generated code, and cache LLM responses.
    • Budget Controls: Implement token caps per PR and prioritize reviews based on PR importance.

    Implementation Pattern: Use a TokenUsageTracker to check if a review can proceed based on an estimated token count against a defined budget limit.

    class TokenUsageTracker:
        def __init__(self, budget_limit):
            self.budget_limit = budget_limit
            self.current_usage = 0
            
        def can_process(self, estimated_tokens):
            return self.current_usage + estimated_tokens <= self.budget_limit
            
        def record_usage(self, prompt_tokens, completion_tokens):
            usage = prompt_tokens + completion_tokens
            self.current_usage += usage
            return self.current_usage
  8. Understand Goose response time measurements (TTFB)

    main

    By default, Goose measures Time to First Byte (TTFB). This is the time from when a request is sent until response headers are received, as measured by reqwest::Client::execute().

    What TTFB includes:

    • Network latency to establish connection
    • Server processing time to generate response
    • Time to receive response headers and status code
    • Redirect handling time (when following redirects)

    What is NOT measured:

    • Time to download complete response body
    • Time to process response content
    • Client-side rendering or parsing time

    Goose uses TTFB because it focuses on server performance and resource efficiency, allowing for higher load generation by not downloading complete response bodies.

  9. How Goose mitigates Coordinated Omission

    main

    Goose prevents misleading performance data by implementing three specific mitigation strategies:

    1. Detects Missing Requests: When Goose encounters an abnormally long response time, it calculates how many requests should have been initiated during that period based on the expected load.
    2. Synthetic Request Injection: Goose injects "synthetic requests" into the dataset. These represent the requests that would have been made if the server had not frozen, ensuring the total request count reflects the true intended load.
    3. Clear Reporting: Goose provides specific metrics to distinguish between actual and synthetic requests, allowing you to see the true percentage of traffic affected by a freeze.

    Coordinated Omission Metrics Example:

    === COORDINATED OMISSION METRICS ===
    Total CO Events: 1
    Actual requests: 4  
    Synthetic requests: 29 (87.9%)
    Severity: 1 Critical event detected

    In this example, the report accurately shows that 87.9% of expected traffic was affected by the server problem, rather than just reporting on the 4 actual requests.

    === COORDINATED OMISSION METRICS ===
    Total CO Events: 1
    Actual requests: 4  
    Synthetic requests: 29 (87.9%)
    Severity: 1 Critical event detected
  10. Interpret Coordinated Omission (CO) metrics

    main

    When running tests with CO mitigation enabled, Goose outputs a === COORDINATED OMISSION METRICS === section. Use these metrics to assess system health:

    Key Metrics

    • Events per minute: The rate of CO events.
    • Synthetic requests %: The percentage of total requests that were synthetic (injected to detect omission). A low percentage (e.g., < 1%) indicates the system is meeting timing expectations.
    • Severity Distribution: Categorizes events into Minor, Moderate, Severe, and Critical.

    Health Thresholds

    StatusEvents per minuteSynthetic %SeverityAction
    Healthy< 2< 1%Mostly MinorNone
    ⚠️ Monitor2 - 101% - 5%Some ModerateInvestigate dips
    🚨 Red Flag> 10> 5%Severe/CriticalImmediate action required

    Common Scenarios

    • Microservice SLA: High synthetic % or frequent CO events indicate the service is struggling to meet latency requirements.
    • Connection Pool Exhaustion: A sudden spike in CO events and a high synthetic % (e.g., > 9%) often indicates database connection pool exhaustion.
    • CDN Issues: High moderate/severe events can indicate CDN latency or unavailability affecting user experience.
  11. Understanding Coordinated Omission in Load Testing

    main

    Coordinated Omission is a measurement error where load testing tools fail to account for requests that should have been sent during a server slowdown.

    In traditional load testing, if a thread is waiting for a response from a frozen server, it cannot send the next request. This creates a 'Race Timer Problem' where the tool only measures the requests that actually completed, effectively ignoring the backlog of users who would have been impacted during the delay. This leads to 'dangerously optimistic' reports that hide the true impact of outages.

    Example of the problem: If a server freezes for 30 seconds, a traditional tool might record only 1 failed request. However, in reality, 30 additional requests should have been attempted during that window. Goose identifies this gap to provide an accurate view of system impact.