Commit ae3be721 authored by KT315's avatar KT315
Browse files

Use SO_REUSEPORT

parent aeb3cb26
......@@ -3,6 +3,11 @@ defmodule Dummy.Application do
use Application
@sol_socket 1
@so_reuseport 15
@socket_num 36
def start(_type, _args) do
dispatch =
:cowboy_router.compile([
......@@ -12,21 +17,23 @@ defmodule Dummy.Application do
]}
])
children = [
children = 0..@socket_num-1
|> Enum.map(fn i ->
id = :"dummy#{i}"
%{
id: :dummy,
id: id,
start:
{:cowboy, :start_clear,
[
:dummy,
%{max_connections: 999_999, socket_opts: [port: 5000]},
id,
%{max_connections: 1_000_000, socket_opts: [{:port, 5000}, {:raw, @sol_socket, @so_reuseport, <<1::size(32)>>}]},
%{max_keepalive: 1_000, env: %{dispatch: dispatch}}
]},
restart: :permanent,
shutdown: :infinity,
type: :supervisor
}
]
end)
opts = [strategy: :one_for_one, name: Dummy.Supervisor]
Supervisor.start_link(children, opts)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment