From c9b431f3a5d3bdc6a1d0ff3c29a229226e991195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 11 Dec 2024 22:22:04 +0100 Subject: [PATCH] Add pool_count as an example for performance (#6014) --- installer/lib/phx_new/generator.ex | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/installer/lib/phx_new/generator.ex b/installer/lib/phx_new/generator.ex index c342557bb6..18a8cd94ef 100644 --- a/installer/lib/phx_new/generator.ex +++ b/installer/lib/phx_new/generator.ex @@ -188,7 +188,8 @@ defmodule Phx.New.Generator do {adapter_app, adapter_module, adapter_config} = get_ecto_adapter(db, String.downcase(project.app), project.app_mod) - {web_adapter_app, web_adapter_vsn, web_adapter_module, web_adapter_docs} = get_web_adapter(web_adapter) + {web_adapter_app, web_adapter_vsn, web_adapter_module, web_adapter_docs} = + get_web_adapter(web_adapter) pubsub_server = get_pubsub_server(project.app_mod) @@ -304,8 +305,16 @@ defmodule Phx.New.Generator do Mix.raise("Unknown database #{inspect(db)}") end - defp get_web_adapter("cowboy"), do: {:plug_cowboy, "~> 2.7", Phoenix.Endpoint.Cowboy2Adapter, "https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html"} - defp get_web_adapter("bandit"), do: {:bandit, "~> 1.5", Bandit.PhoenixAdapter, "https://hexdocs.pm/bandit/Bandit.html#t:options/0"} + defp get_web_adapter("cowboy"), + do: + {:plug_cowboy, "~> 2.7", Phoenix.Endpoint.Cowboy2Adapter, + "https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html"} + + defp get_web_adapter("bandit"), + do: + {:bandit, "~> 1.5", Bandit.PhoenixAdapter, + "https://hexdocs.pm/bandit/Bandit.html#t:options/0"} + defp get_web_adapter(other), do: Mix.raise("Unknown web adapter #{inspect(other)}") defp fs_db_config(app, module) do @@ -380,6 +389,8 @@ defmodule Phx.New.Generator do # ssl: true, url: database_url, pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"), + # For machines with several cores, consider starting multiple pools of `pool_size` + # pool_count: 4, socket_options: maybe_ipv6 """ ]