Liking cljdoc? Tell your friends :D

Performance of Phrag

Load Test

Tests are performed with k6.

Objectives

Load tests were performed to:

  • Get reference numbers of performance for simple resource setups. (Stringent JVM/OS/DB tuning is excluded from the scope.)

  • Verify performance improves linear with additional resources, which means there's no obvious bottleneck.

  • Compare performance of resolver models between bucket queue model vs recursion model.

Measurement

How many users can be served under request duration of 500ms while each user is constantly sending a request every 2s?

  • Duration: 60s with 2 stages:
    • 30s of ramping up to a target number of users.
    • 30s of staying at a target number of users.
  • Metrics used is http_req_duration for p95.
  • HTTP error & response error rate must be less than 1%.

Tests

  • 3 queries with different nest levels were tested to see performance difference of additional queries and serialization (1 nest = 1 SQL).

  • Each test was performed with limit: 50 and limit: 100 to see performance difference of overall serialization workload.

  • All tables had 100,000+ pre-generated records as performance tests in small number of records often do not represent performance accurately.

  • Parameters of $offset and $id_gt were randomized between 0 to 100,000 for each request.

Query without nest: simple object listing

query queryVenues($limit: Int!, $offset: Int!, $id_gt: Int!) {
  venues(limit: $limit, offset: $offset, where: { id: { gt: $id_gt } }) {
    id
    name
    postal_code
  }
}

Query with 1 nest: has-many

query queryVenueMeetups($limit: Int!, $offset: Int!, $id_gt: Int!) {
  venues(limit: $limit, offset: $offset, where: { id: { gt: $id_gt } }) {
    id
    name
    postal_code
    meetups(limit: $limit, sort: { id: desc }) {
      id
      title
    }
  }
}

Query with 2 nests: has-many and has-one (often referred as many-to-many)

query queryMeetupsWithMembers($limit: Int!, $offset: Int!, $id_gt: Int!) {
  meetups(limit: $limit, offset: $offset, where: { id: { gt: $id_gt } }) {
    id
    title
    meetups_members(limit: $limit) {
      member {
        id
        email
      }
    }
  }
}

Results

  • Platform: AWS ECS Single Task Container
  • Database: AWS RDS PostgreSQL 2vCPU + 1GB RAM (Free-tier db.t3.micro)

1vCPU + 4GB RAM

Limit: 50

QueryMAX VUsp(95)MinMaxReqsReqs/s
No nest1300427ms7ms845ms27510442
1 nest700461ms9ms860ms14750237
2 nests500326ms8ms758ms10919175

Limit: 100

QueryMAX VUsp(95)MinMaxReqsReqs/s
No nest900395ms8ms895ms19515313
1 nest400257ms10ms703ms8872143
2 nests300274ms10ms599ms6602106

2vCPU + 8GB RAM

Limit: 50

QueryMAX VUsp(95)MinMaxReqsReqs/s
No nest1900353ms6ms697ms41174662
1 nest1400365ms7ms721ms29668477
2 nests1200447ms8ms1069ms25088402

Limit: 100

QueryMAX VUsp(95)MinMaxReqsReqs/s
No nest2000489ms7ms846ms41693669
1 nest900291ms10ms663ms19695316
2 nests700294ms9ms774ms15312246

Observations

  • Resource allocation: Performance seems to have increased linear with the resource allocation overall and improvement was even more significant for nested queries.

  • Nest levels: Considering additional SQL queries and serialization required per nest level, 20% to 50% less performance per nest levels seems reasonable. However, with increased resources, performance drop with nested queries seems to be smaller. It was also observed that querying nested objects for has-many relationship affects performance more than has-one relationship, which indicates serialization and validation of retrieved records as per GraphQL schema is possibly the factor for larger latency and resource consumption.

  • Resolver model: Bucket queue model with Superlifter vs recursion model were compared for more performant resolver implementation. Though results are not included in this page, recursion model was more performant in a case of Phrag which has simple resolution requirements. The overhead of adding queue and resolving them through Promise (CompletableFuture) seemed to affect performance.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close