aloukissas

aloukissas

Absinthe.Subscription.publish performance

When doing a publish call, should we expect the performance behavior to be similar to PubSub.broadcast/4 (i.e. almost instant)? Reading through the Absinthe code, it looks like that perhaps the run_docset call may be expensive.

Most Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Hi @aloukissas publish is indeed expensive by design, it is not instant like broadcast. Unlike broadcast which merely needs to send a message to various processes, Absinthe needs to execute the documents associated with a topic before it can send results to end users. So some process somewhere needs to bear the cost of performing this execution.

By default, that is the process that triggers the publish call, generally a mutation. This operates as a form of back pressure, where load incurred by an operation on the system is felt by the request that triggers that load.

hubertlepicki

hubertlepicki

@aloukissas not sure if this is applicable in your case, or you can make it applicable, but I found a tremendous performance improvement after deduplication subscription resolvers Understanding Subscriptions — absinthe v1.11.0

Subscriptions by default are expensive because they have to be resolved in context of each connected user. You can pass a context to it and make it resolve only once.

That not always can be applied, obviously if different users should see different data it often can’t work.

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

No trigger just runs the publish call inside of middleware on the mutation same as calling publish. You can spawn a task and call publish inside the task, or (better) you could build like an oban job queue of publish calls perhaps. The main danger to just spawning tasks is that you overload and potentially even OOM the system if you have many subscribers and many mutations on those subscribers without any backpressure.

Last Post!

gabrielpra

gabrielpra

Hey @aloukissas! Did you find anything useful through your instrumentation?

I have found this comment about context size that could be relevant, but haven’t started digging too deep yet: Absinthe cannot seem to handle even 1000 concurrent subscriptions - #2 by josevalim

Where Next?

Popular in Questions Top

ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 131117 1222
New
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement