Loadtest p2 (#5380)

* Bring back previous dev config

* Dedicated MIX_ENV for load testing + change k6 script

* Remove unused env var

* Remove test flag

* Add .env.load

* Fixup
This commit is contained in:
hq1 2025-05-06 12:58:06 +02:00 committed by GitHub
parent aa4a8339cb
commit 8f4b63083e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 96 additions and 53 deletions

View File

@ -59,9 +59,9 @@ minio-stop: ## Stop and remove the minio container
loadtest-server:
@echo "Ensure your OTP installation is built with --enable-lock-counter"
MIX_ENV=dev LOADTEST=1 ERL_FLAGS="-emu_type lcnt +Mdai max" iex -S mix phx.server
MIX_ENV=load ERL_FLAGS="-emu_type lcnt +Mdai max" iex -S mix do phx.digest + phx.server
loadtest-client:
@echo "Set your limits for file descriptors/ephermeal ports high... Test begins shortly"
@echo "Set your limits for file descriptors/ephemeral ports high... Test begins shortly"
@sleep 5
k6 run test/load/script.js
k6 run test/load/script.js

37
config/.env.load Normal file
View File

@ -0,0 +1,37 @@
BASE_URL=http://localhost:8000
SECURE_COOKIE=false
DATABASE_URL=postgres://postgres:postgres@127.0.0.1:5432/plausible_dev
CLICKHOUSE_DATABASE_URL=http://127.0.0.1:8123/plausible_events_db
CLICKHOUSE_MAX_BUFFER_SIZE_BYTES=1000000
SECRET_KEY_BASE=/njrhntbycvastyvtk1zycwfm981vpo/0xrvwjjvemdakc/vsvbrevlwsc6u8rcg
TOTP_VAULT_KEY=Q3BD4nddbkVJIPXgHuo5NthGKSIH0yesRfG05J88HIo=
ENVIRONMENT=dev
MAILER_ADAPTER=Bamboo.LocalAdapter
LOG_LEVEL=debug
SELFHOST=false
DISABLE_CRON=true
ADMIN_USER_IDS=1
SHOW_CITIES=true
PADDLE_VENDOR_AUTH_CODE=895e20d4efaec0575bb857f44b183217b332d9592e76e69b8a
PADDLE_VENDOR_ID=3942
GOOGLE_CLIENT_ID=875387135161-l8tp53dpt7fdhdg9m1pc3vl42si95rh0.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=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
PROMEX_DISABLED=false
SITE_DEFAULT_INGEST_THRESHOLD=1000000
S3_DISABLED=false
S3_ACCESS_KEY_ID=minioadmin
S3_SECRET_ACCESS_KEY=minioadmin
S3_REGION=us-east-1
S3_ENDPOINT=http://localhost:10000
S3_EXPORTS_BUCKET=dev-exports
S3_IMPORTS_BUCKET=dev-imports
HELP_SCOUT_APP_ID=fake_app_id
HELP_SCOUT_APP_SECRET=fake_app_secret
HELP_SCOUT_SIGNATURE_KEY=fake_signature_key
HELP_SCOUT_VAULT_KEY=ym9ZQg0KPNGCH3C2eD5y6KpL0tFzUqAhwxQO6uEv/ZM=
VERIFICATION_ENABLED=true

View File

@ -3,8 +3,29 @@ import Config
config :plausible, PlausibleWeb.Endpoint,
server: true,
debug_errors: true,
code_reloader: false,
check_origin: false
code_reloader: true,
check_origin: false,
watchers: [
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]},
tailwind: {Tailwind, :install_and_run, [:default, ~w(--watch)]},
storybook_tailwind: {Tailwind, :install_and_run, [:storybook, ~w(--watch)]},
npm: ["--prefix", "assets", "run", "typecheck", "--", "--watch", "--preserveWatchOutput"],
npm: [
"run",
"deploy",
cd: Path.expand("../tracker", __DIR__)
]
],
live_reload: [
dirs: [
"extra"
],
patterns: [
~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
~r"lib/plausible_web/(controllers|live|components|templates|views|plugs)/.*(ex|heex)$",
~r"storybook/.*(exs)$"
]
]
config :plausible, paddle_api: Plausible.Billing.DevPaddleApiMock

17
config/load.exs Normal file
View File

@ -0,0 +1,17 @@
import Config
config :plausible, PlausibleWeb.Endpoint,
cache_static_manifest: "priv/static/cache_manifest.json",
check_origin: false,
server: true,
code_reloader: false,
http: [
transport_options: [
num_acceptors: 1000
]
],
protocol_options: [
max_keepalive: 5_000,
idle_timeout: 120_000,
request_timeout: 120_000
]

View File

@ -2,7 +2,7 @@ import Config
import Plausible.ConfigHelpers
require Logger
if config_env() in [:dev, :test] do
if config_env() in [:dev, :test, :load] do
Envy.load(["config/.env.#{config_env()}"])
end
@ -331,41 +331,6 @@ config :plausible, PlausibleWeb.Endpoint,
websocket_url: websocket_url,
secure_cookie: secure_cookie
if config_env() in [:dev, :ce_dev] do
loadtest_mode = get_var_from_path_or_env(config_dir, "LOADTEST")
if loadtest_mode do
config :plausible, PlausibleWeb.Endpoint,
debug_errors: false,
code_reloader: false
else
config :plausible, PlausibleWeb.Endpoint,
debug_errors: true,
code_reloader: true,
watchers: [
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]},
tailwind: {Tailwind, :install_and_run, [:default, ~w(--watch)]},
storybook_tailwind: {Tailwind, :install_and_run, [:storybook, ~w(--watch)]},
npm: ["--prefix", "assets", "run", "typecheck", "--", "--watch", "--preserveWatchOutput"],
npm: [
"run",
"deploy",
cd: Path.expand("../tracker", __DIR__)
]
],
live_reload: [
dirs: [
"extra"
],
patterns: [
~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
~r"lib/plausible_web/(controllers|live|components|templates|views|plugs)/.*(ex|heex)$",
~r"storybook/.*(exs)$"
]
]
end
end
# maybe enable HTTPS in CE
if config_env() in [:ce, :ce_dev, :ce_test] do
if https_port do
@ -794,7 +759,7 @@ cron_enabled = !disable_cron
thirty_days_in_seconds = 60 * 60 * 24 * 30
if config_env() in [:prod, :ce] do
if config_env() in [:prod, :ce, :load] do
config :plausible, Oban,
repo: Plausible.Repo,
plugins: [

View File

@ -10,7 +10,7 @@ defmodule Plausible.MixProject do
version: System.get_env("APP_VERSION", "0.0.1"),
elixir: "~> 1.18",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() in [:prod, :ce],
start_permanent: Mix.env() in [:prod, :ce, :load],
aliases: aliases(),
deps: deps(),
test_coverage: [
@ -44,7 +44,7 @@ defmodule Plausible.MixProject do
:runtime_tools,
:tls_certificate_check,
:opentelemetry_exporter
] ++ if(Mix.env() == :dev, do: [:tools, :observer, :wx], else: [])
] ++ if(Mix.env() in [:dev, :load], do: [:tools, :observer, :wx], else: [])
]
end
@ -91,7 +91,8 @@ defmodule Plausible.MixProject do
{:gen_cycle, "~> 1.0.4"},
{:hackney, "~> 1.8"},
{:jason, "~> 1.3"},
{:kaffy, git: "https://github.com/aesmail/kaffy.git", only: [:dev, :test, :staging, :prod]},
{:kaffy,
git: "https://github.com/aesmail/kaffy.git", only: [:dev, :test, :staging, :prod, :load]},
{:location, git: "https://github.com/plausible/location.git"},
{:mox, "~> 1.0", only: [:test, :ce_test]},
{:nanoid, "~> 2.1.0"},

View File

@ -29,14 +29,16 @@ function newParams() {
}
export const options = {
stages: [
{ target: 10000, duration: "10s" },
{ target: 15000, duration: "20s" },
{ target: 20000, duration: "30s" },
{ target: 20000, duration: "30s" },
{ target: 30000, duration: "30s" },
{ target: 30000, duration: "90s" },
],
scenarios: {
constant_rps: {
executor: "constant-arrival-rate",
rate: 12000,
timeUnit: "1s",
duration: "15m",
preAllocatedVUs: 10000,
maxVUs: 30000,
},
},
};
export default function () {