Skip to content

Commit

Permalink
Revert "perf: bandit adaptor (#2204)"
Browse files Browse the repository at this point in the history
This reverts commit ef021e8.
  • Loading branch information
Ziinc committed Oct 18, 2024
1 parent ef021e8 commit 3a2fcba
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 31 deletions.
17 changes: 0 additions & 17 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,6 @@ config :logflare, Logflare.Source.BigQuery.Schema, updates_per_minute: 6

# Configures the endpoint
config :logflare, LogflareWeb.Endpoint,
adapter: Bandit.PhoenixAdapter,
http: [
thousand_island_options: [
# https://cloud.google.com/load-balancing/docs/https/#timeouts_and_retries
# preserves idle keepalive connections up to load balancer max of 600s
read_timeout: 600_000,
# transport options are passed wholly to :gen_tcp
# https://github.com/mtrudel/thousand_island/blob/ae733332892b1bb2482a9cf4e97de03411fba2ad/lib/thousand_island/transports/tcp.ex#L61
transport_options: [
# https://www.erlang.org/doc/man/inet
# both reuseport and reuseport_lb should be provided for linux
reuseport: true,
reuseport_lb: true
#
]
]
],
url: [host: "localhost", scheme: "http", port: 4000],
secret_key_base: "DSzZYeAgGaXlfRXPQqMOPiA8hJOYSImhnR2lO8lREOE2vWDmkGn1XWHxoCZoASlP",
render_errors: [view: LogflareWeb.ErrorView, accepts: ~w(html json)],
Expand Down
9 changes: 8 additions & 1 deletion config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ config :logflare,
config :logflare, LogflareWeb.Endpoint,
server: true,
http: [
port: System.get_env("PORT") || 4000
port: System.get_env("PORT") || 4000,
transport_options: [
max_connections: 16_384,
num_acceptors: 100,
socket_opts: [{:raw, 0xFFFF, 0x0200, <<1::32-native>>}]
],
protocol_options: [max_keepalive: 1_000],
compress: true
],
live_view: [
signing_salt: "eVpFFmpN+OHPrilThexLilWnF+a8zBLbCtdH/OzAayShcm1B3OHOyGiadM6qOezp"
Expand Down
19 changes: 18 additions & 1 deletion config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,24 @@ config :logflare, env: :prod

config :logflare, LogflareWeb.Endpoint,
http: [
port: 4000
port: 4000,
transport_options: [
max_connections: 64_000,
num_acceptors: 1_000,
# for so_reuseport
socket_opts: [{:raw, 1, 15, <<1::32-native>>}]
],
# https://blog.percy.io/tuning-nginx-behind-google-cloud-platform-http-s-load-balancer-305982ddb340
# https://github.com/ninenines/cowboy/issues/1286#issuecomment-699643478
protocol_options: [
# https://ninenines.eu/docs/en/cowboy/2.8/manual/cowboy_http/
request_timeout: 30_000,
# https://cloud.google.com/load-balancing/docs/https/#timeouts_and_retries
# must be greater than 600s
idle_timeout: 650_000,
max_keepalive: :infinity
],
compress: true
],
cache_static_manifest: "priv/static/cache_manifest.json",
server: true,
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ defmodule Logflare.Mixfile do
defp deps do
[
# Phoenix stuff
{:phoenix, "~> 1.7.14"},
{:phoenix, "~> 1.7"},
{:phoenix_live_view, "~> 0.18"},
{:phoenix_view, "~> 2.0"},
{:phoenix_pubsub, "~> 2.1"},
{:phoenix_ecto, "~> 4.4"},
{:phoenix_live_reload, "~> 1.4", only: :dev},
{:bandit, "~> 1.5.7"},
{:bandit, ">= 0.7.7"},
{:plug_crypto, "~> 1.2.2"},
{:cors_plug, "~> 2.0"},
{:plug_caisson, "~> 0.2.1"},
Expand Down
Loading

0 comments on commit 3a2fcba

Please sign in to comment.