From 87bc90e9670c15d14460ffc4b48a58c31479a672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20=C5=81=C4=99picki?= Date: Wed, 2 Oct 2024 09:01:52 +0200 Subject: [PATCH] [#1342] Add note on the need of fixed :pool_size to guide subscriptions.md --- guides/subscriptions.md | 8 ++++++++ lib/absinthe/subscription.ex | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/guides/subscriptions.md b/guides/subscriptions.md index 11030ed282..9a7858eb83 100644 --- a/guides/subscriptions.md +++ b/guides/subscriptions.md @@ -45,6 +45,14 @@ line: Supervisor.start_link(children, opts) ``` +> Note: If your application is deployed in an environment, where the number of CPU cores can differ between the application instances, +> be sure to specify a fixed `:pool_size` option, otherwise the messages will not be delivered reliably between your nodes. This can +> happen often on cloud deployment platforms. + +```elixir +{Absinthe.Subscription, name: MyAppWeb.Endpoint, pool_size: 8} +``` + See `Absinthe.Subscription.child_spec/1` for more information on the supported options. diff --git a/lib/absinthe/subscription.ex b/lib/absinthe/subscription.ex index e4386019a8..694ba75bfe 100644 --- a/lib/absinthe/subscription.ex +++ b/lib/absinthe/subscription.ex @@ -59,6 +59,10 @@ defmodule Absinthe.Subscription do compressed or not. * `:pool_size` - (Optional - default `System.schedulers() * 2`) An integer specifying the number of `Absinthe.Subscription.Proxy` processes to start. + You may want to specify a fixed `:pool_size` if your deployment environment + does not guarantee an equal number of CPU cores to be available on all + application nodes. In such case, using the defaults may lead to missing + messages. This situation often happens on cloud-based deployment environments. """ @spec child_spec(atom() | [opt()]) :: Supervisor.child_spec() def child_spec(pubsub) when is_atom(pubsub) do