derekbrown

derekbrown

Hey everyone! New to the forum, not new to Elixir. :slight_smile:

In any case, recently had a discussion with @benwilson512 on overhead during GQL requests, and then saw a related question in the Absinthe channel on Slack, so decided to open it up here for input/guidance.

Problem

We’ve been tracing our API’s performance in Datadog and have seen some oddities that we can’t quite diagnose. Pictures are worth 1000 words, so here are some flame graphs for one request that demonstrates the issue:

The overall flame graph

1st Flame: Token Auth (in our Context)

2nd Flame: GQL Resolution

What’s happening in the gaps after auth/context and after the actual resolution?
This is just one request, but many of our requests have this shape, where the majority of the request has something unknown happening for at least 50ms or so. In some cases, we have 100ms or so unaccounted for, usually on the tail-end of the request post-resolution.


Environment

  • App is released via mix release to AWS (EC2 machine) and deployed behind an ELB (https).
  • Elixir 1.9.1, Erlang 22, Absinthe v1.5.0, Absinthe Plug v1.5.0-rc2, Absinthe Phoenix 1.5.0-rc.0
  • The app is behind a Phoenix Router, Phoenix Endpoint, but is an API server.

Is anyone else seeing things like this? Happy to answer any other questions to help figure this out!

Showing Posts 19 to 10

tansan

tansan

Is there a tutorial some where? I mainly want to see the performance on my queries with Abinsthe. If I set it up, would it show up in LiveDashboard?

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Hi @tansan yes :telemetry is basically the ecosystem standard at this point.

tansan

tansan

Sorry to bring up an old thread, but is this still the recommended telemetry for absinthe in 2023?

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Awesome. Do note that once OTP 24 is released we’ve seen significant improvements from the JIT as well, so we expect the overhead to drop a further ~60% from that alone.

derekbrown

derekbrown OP

Yes! Forgot to mention that: we’re using PersistentTerm as well (have been since it was in PR last year), and it’s definitely provided gains as well. Huge thanks to @benwilson512 and team for that.

FWIW, when I say that our response times are manageable, I may have been understating. Our overall times have been reduced to a third of what they were.

It’s still a mystery to me exactly what’s happening, but it’s now a low priority mystery for us. :smiley:

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

The offer to investigate any runnable example stands! Do make sure to check out the persistent_term backend Absinthe.Schema.PersistentTerm — absinthe v1.11.0 which we’re promoting out of the Experimental namespace in the next release. It has proven to be both faster and easier to work with.

I’m seeing the original post was on Absinthe 1.5.0, and we definitely fixed an N^2 regression in our variable handling somewhere in a release between that and latest. Hopefully you’ve updated since!

derekbrown

derekbrown OP

I didn’t unfortunately. But I do think that a lot of it is resolution. We made a couple of changes to batch resolvers that seemed to have helped. There were a couple of uncaught n+1 errors as well on our side. Still a lot of unexplained gaps though, but the response times are at least manageable now.

mmartinson

mmartinson

@derekbrown did you end up with any further learnings from this? I’m working with a similar issue. Any useful resources to link?

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

With respect to this, the best bet would be to create something we can both iterate on that exhibits the behaviour you’re running into. I should also ask about the server you’re running this in.

derekbrown

derekbrown OP

Thanks, Ben! Makes sense. You’ve been super helpful and I’m appreciative.

And JSON encoding being a majority of the tail makes sense as well; I think that length of time is proportionate to our response object. I’m still trying to diagnose if it’s our nested query documents (sometimes 4-5 levels) that’re causing the perf gap during validation or if it’s something else.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews