Skip to content

Degradation of GraphQL and Rest API query performance #18120

Open
@TheLastochka

Description

Deployment Type

Self-hosted

Triage priority

I'm a NetBox Labs customer

NetBox Version

v4.1.6

Python Version

3.11

Steps to Reproduce

  1. Netbox version >= 4.0.0
  2. The database contains about 27k ip addresses
  3. Send the following Graphql query:
query getIpAddresses {
  resp:ip_address_list {
    id
    address
    status
    description
    dns_name
    tenant {
      id
      name
    }
    assigned_object {
      __typename
      ... on InterfaceType {
        id
        name
      }
      ... on VMInterfaceType {
        id
        name
      }
    }
    custom_fields
  }
}

After switching to the Strawberry library (netbox v4.0.0), there has been a significant degradation in the performance of API requests, including Graphql.
When executing a request to get custom fields or an assigned objects, Graphql performs additional queries to the database in large numbers.

Expected Behavior

It works in Netbox v3.7.8:

  1. This query produced 5k database queries (execution time: 14 seconds).
  2. If you remove assigned_object's and custom_fields from this Graphql query, the execution time does not change (slightly).

Observed Behavior

Netbox v4.0.0 (Strawberry) and after:

  1. The same query produces 87k database queries (execution time: 7.6 minutes).
  2. If you remove assigned_object's and custom_fields from this Graphql query, the execution time drops to the expected values (execution time is 8 seconds).

Previously, there was a similar problem on the netbox v3.4 version #11291
However, it was fixed in version v3.5 by writing optimizers.

After switching to Strawberry, the optimizers remained in the old code. And the problem is back.

Originally posted by @TheLastochka in #18107

Metadata

Assignees

No one assigned

    Labels

    severity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: needs ownerThis issue is tentatively accepted pending a volunteer committed to its implementationtopic: GraphQLtype: bugA confirmed report of unexpected behavior in the application

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions