naming for checkin from pool timeout

This commit is contained in:
Alexander Strizhakov 2020-03-03 13:05:28 +03:00
parent 151dc4e387
commit 28ed4b41d0
No known key found for this signature in database
GPG Key ID: 022896A53AEF1381
4 changed files with 5 additions and 5 deletions

View File

@ -607,7 +607,7 @@ config :pleroma, Pleroma.Repo,
prepare: :unnamed prepare: :unnamed
config :pleroma, :connections_pool, config :pleroma, :connections_pool,
receive_connection_timeout: 250, checkin_timeout: 250,
max_connections: 250, max_connections: 250,
retry: 0, retry: 0,
retry_timeout: 100, retry_timeout: 100,

View File

@ -404,7 +404,7 @@ Advanced settings for connections pool. Pool with opened connections. These conn
For big instances it's recommended to increase `config :pleroma, :connections_pool, max_connections: 500` up to 500-1000. For big instances it's recommended to increase `config :pleroma, :connections_pool, max_connections: 500` up to 500-1000.
It will increase memory usage, but federation would work faster. It will increase memory usage, but federation would work faster.
* `:receive_connection_timeout` - timeout to receive connection from pool. Default: 250ms. * `:checkin_timeout` - timeout to checkin connection from pool. Default: 250ms.
* `:max_connections` - maximum number of connections in the pool. Default: 250 connections. * `:max_connections` - maximum number of connections in the pool. Default: 250 connections.
* `:retry` - number of retries, while `gun` will try to reconnect if connections goes down. Default: 5. * `:retry` - number of retries, while `gun` will try to reconnect if connections goes down. Default: 5.
* `:retry_timeout` - timeout while `gun` will try to reconnect. Default: 100ms. * `:retry_timeout` - timeout while `gun` will try to reconnect. Default: 100ms.

View File

@ -34,7 +34,7 @@ defmodule Pleroma.Pool.Connections do
def checkin(url, name) when is_binary(url), do: checkin(URI.parse(url), name) def checkin(url, name) when is_binary(url), do: checkin(URI.parse(url), name)
def checkin(%URI{} = uri, name) do def checkin(%URI{} = uri, name) do
timeout = Config.get([:connections_pool, :receive_connection_timeout], 250) timeout = Config.get([:connections_pool, :checkin_timeout], 250)
GenServer.call( GenServer.call(
name, name,
@ -184,6 +184,7 @@ defmodule Pleroma.Pool.Connections do
time = :os.system_time(:second) time = :os.system_time(:second)
last_reference = time - conn.last_reference last_reference = time - conn.last_reference
current_crf = crf(last_reference, 100, conn.crf) current_crf = crf(last_reference, 100, conn.crf)
put_in(state.conns[key], %{ put_in(state.conns[key], %{
conn conn
| gun_state: :up, | gun_state: :up,

View File

@ -24,8 +24,7 @@ defmodule Pleroma.Pool.ConnectionsTest do
adapter = Application.get_env(:tesla, :adapter) adapter = Application.get_env(:tesla, :adapter)
Application.put_env(:tesla, :adapter, Tesla.Adapter.Gun) Application.put_env(:tesla, :adapter, Tesla.Adapter.Gun)
{:ok, pid} = {:ok, pid} = Connections.start_link({name, [max_connections: 2, checkin_timeout: 1_500]})
Connections.start_link({name, [max_connections: 2, receive_connection_timeout: 1_500]})
on_exit(fn -> on_exit(fn ->
Application.put_env(:tesla, :adapter, adapter) Application.put_env(:tesla, :adapter, adapter)