fetchai / ledger-subquery

This is the Fetch Ledger SubQuery project, an indexer for the Fetch network.
MIT License
2 stars 10 forks source link

Craft load testing GQL queries / fixture data #126

Closed bryanchriswhite closed 1 year ago

bryanchriswhite commented 2 years ago

Proposal

To get a sense of how "stressed" both the graphql API server and the DB server are, I think we can measure CPU & memory usage over time and query response time.

bryanchriswhite commented 2 years ago

Post #147, I hypothesize that a query that traverses a path like AuthzExec -> AuthzExecMessage -> Message -> Transaction -> Event is likely to be one of (if not) the deepest paths available

bryanchriswhite commented 2 years ago

Here's the backbone of that query in GQL:

query deepQuery {
  authzExecs (first: 100) {
    nodes {
      message {
        transaction {
          events {
            nodes {
              id
            }
          }
        }
      }
      subMessages {
        nodes {
          message {
            transaction {
              messages {
                nodes {
                  id
                }
              }
              events {
                nodes {
                  id
                }
              }
            }
          }
        }
      }
    }
  }
}
bryanchriswhite commented 2 years ago

Counting all records in a table causes a sequential scan over that table which is a costly operation. Including totalCounts at each edge maximizes this cost with respect to a given query. Additionally, as load should also scale with the amount of data requested, we can fill out this backbone by asking for all fields on all nodes:

query deepQuery {
  authzExecs (first: 100) {
    totalCount
    nodes {
      id
      grantee
      message {
        id
        typeUrl
        json
        transaction {
          id
          gasUsed
          gasWanted
          signerAddress
          events {
            totalCount
            nodes {
              id
              type
              attributes
              log
            }
          }
        }
      }
      subMessages {
        totalCount
        nodes {
          message {
            id
            typeUrl
            json
            transaction {
              id
              gasUsed
              gasWanted
              signerAddress
              messages {
                totalCount
                nodes {
                  id
                  typeUrl
                  json
                }
              }
              events {
                totalCount
                nodes {
                  id
                  type
                  attributes
                  log
                }
              }
            }
          }
        }
      }
    }
  }
}
bryanchriswhite commented 1 year ago

Closing this as the GQL query should be sufficient for now. This may change if the graphql api turns out to be a bottleneck to DB performance.