Skip to content

Commit

Permalink
Add pool_count as an example for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Dec 11, 2024
1 parent 0ad88cd commit 2cc77a2
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions installer/lib/phx_new/generator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
"""
]
Expand Down

0 comments on commit 2cc77a2

Please sign in to comment.