Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Loadtest p2 (#5380)
hq18f4b63083e57
diff --git a/Makefile b/Makefileindex 811c303343..fc8afaa64c 100644--- a/Makefile+++ b/Makefile@@ -59,9 +59,9 @@ minio-stop: ## Stop and remove the minio containerloadtest-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.serverloadtest-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.jsdiff --git a/config/.env.load b/config/.env.loadnew file mode 100644index 0000000000..cb957fe126--- /dev/null+++ b/config/.env.load@@ -0,0 +1,37 @@+BASE_URL=http://localhost:8000+SECURE_COOKIE=false+DATABASE_URL=postgres://postgres:[email protected]: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=truediff --git a/config/dev.exs b/config/dev.exsindex ce5a34f632..564dcb86a0 100644--- a/config/dev.exs+++ b/config/dev.exs@@ -3,8 +3,29 @@ import Configconfig :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.DevPaddleApiMockdiff --git a/config/load.exs b/config/load.exsnew file mode 100644index 0000000000..976ddcc1bb--- /dev/null+++ b/config/load.exs@@ -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+ ]diff --git a/config/runtime.exs b/config/runtime.exsindex 756690d923..a981ddae80 100644--- a/config/runtime.exs+++ b/config/runtime.exs@@ -2,7 +2,7 @@ import Configimport Plausible.ConfigHelpersrequire Logger-if config_env() in [:dev, :test] do+if config_env() in [:dev, :test, :load] doEnvy.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 CEif config_env() in [:ce, :ce_dev, :ce_test] doif https_port do@@ -794,7 +759,7 @@ cron_enabled = !disable_cronthirty_days_in_seconds = 60 * 60 * 24 * 30-if config_env() in [:prod, :ce] do+if config_env() in [:prod, :ce, :load] doconfig :plausible, Oban,repo: Plausible.Repo,plugins: [diff --git a/mix.exs b/mix.exsindex c9661a78d4..46a2e98dc1 100644--- a/mix.exs+++ b/mix.exs@@ -10,7 +10,7 @@ defmodule Plausible.MixProject doversion: 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"},diff --git a/test/load/script.js b/test/load/script.jsindex 6936375417..68cac6d1e3 100644--- a/test/load/script.js+++ b/test/load/script.js@@ -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 () {