i just converted a graphql-java service to kotlin,...
# graphql-kotlin
l
i just converted a graphql-java service to kotlin, then rewrote it to use graphql-kotlin. i ran load tests before and after. the final version has a significant performance regression … average latency rose from 200-ish ms to over 1000ms. this is using 3.0.0-rc5. i’ll dig in more but if anyone has guidance on where to look i could use the help!
s
What operations are you running to test performance? Query, Mutation, Subscription? Are you using coroutines or any async wrapper?
l
queries only, and i’m not really using coroutines yet but i am using dataloader
d
well there is a big difference in behavior whether you use regular blocking query vs coroutine based one
checking if we have it documented
TLDR if you don’t use any of the async models, by default you will be blocking the threads
are you using
graphql-kotlin-spring-server
?
l
i’m not, we have our own java framework 😞
i think this codepath is using completable futures, but maybe i’m blocking things elsewhere … i’m experimenting with a couple of things
this is the resolver i’m using:
Copy code
class Query {
  fun plan(id: ID, env: DataFetchingEnvironment): CompletableFuture<Plan?> {
    return env.getDataLoader<String, Plan>("plan").load(id.value)
  }
}
and i’m calling it multiple times in the same operation, like
Copy code
{
  a: plan(id: 1) {id}
  b: plan(id: 2) {id}
  c: plan(id: 3) {id}
}
d
what execution strategy are you using?
i.e. completable future will eventually run on some thread
you might need to create custom strategy with thread pools (or custom data fetcher that does it)
l
Copy code
.executeAsync()
if that’s what you mean
l
hm interesting … i haven’t needed that api when i was using graphql-java directly
i can give it a shot
d
i believe those are the defaults
and then its up to
graphql-java
execution strategy to actually execute the futures
l
yeah that was my impression too
d
If you could share some code that repro the issue that would be great
But such a big difference seems suspicious
l
yeah i agree … i’ll spend some time trying to create a minimal reproduction
thanks for the responses so far!
sighh false alarm — i don’t know java and made a mistake structuring my app. i was recreating the schema on every request. which makes wayyyy more sense than a problem with graphql-kotlin!
👍 1
d
👍