The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Apply suggestions from code review
egorf891e548bbaa
diff --git a/apps/www/_blog/2023-08-11-supavisor-1-million.mdx b/apps/www/_blog/2023-08-11-supavisor-1-million.mdxindex acadc2dc9e1..b2bb316123d 100644--- a/apps/www/_blog/2023-08-11-supavisor-1-million.mdx+++ b/apps/www/_blog/2023-08-11-supavisor-1-million.mdx@@ -22,7 +22,7 @@ And so we've built [Supavisor](https://github.com/supabase/supavisor), a Postgre## What is Supavisor?-Supavisor is a scalable, cloud-native Postgres connection pooler. It can handle millions of connections without significant overhead or latency. It has been developed with multitenancy in mind and can be used with multiple databases. Supavisor is built in Elixir, in partnership with [José Valim](https://twitter.com/josevalim) (the creator of Elixir) and the [Dashbit](https://dashbit.co/) team.+Supavisor is a scalable, cloud-native Postgres connection pooler. It has been developed with multi-tenancy in mind, handling millions of connections without significant overhead or latency. Supavisor is built in Elixir, in partnership with [José Valim](https://twitter.com/josevalim) (the creator of Elixir) and the [Dashbit](https://dashbit.co/) team.<div><img@@ -37,7 +37,7 @@ Supavisor is a scalable, cloud-native Postgres connection pooler. It can handle/></div>-Supavisor will enable us to build some exciting new features:+Supavisor will enable us to build some exciting new features for your Postgres cluster:- query caching- automatic read-replica load balancing@@ -46,17 +46,17 @@ Supavisor will enable us to build some exciting new features:## Benchmarking 1 million connections-Before rolling out Supavisor to our entire Postgres fleet, we wanted to benchmark the characteristics it exhibited under load. We tested how we can scale the cluster to handle workloads both vertically and horizontally on demand. These results have given us confidence that Supavisor can meet the needs of the Supabase platform.+We've benchmarked the characteristics Supavisor exhibits under load before rolling it out to our entire Postgres fleet. We tested how we can scale the cluster vertically and horizontally. These results have given us confidence that Supavisor is ready.### SetupWe use a [custom load-testing application](https://github.com/supabase/benchmarks) to test the features of the Supabase platform. It consists of:-- Terraform scripts for creating a testing environment on AWS.-- k6 as the load generator. We used the k6 guides for [running large-scale tests](https://k6.io/docs/testing-guides/running-large-tests/) and [fine-tuning OS](https://k6.io/docs/misc/fine-tuning-os/) to tweak the config for AWS instances.-- Grafana + Prometheus for monitoring.+1. Terraform scripts for creating a testing environment on AWS.+2. k6 as the load generator. We used the k6 guides for [running large-scale tests](https://k6.io/docs/testing-guides/running-large-tests/) and [fine-tuning OS](https://k6.io/docs/misc/fine-tuning-os/) to tweak the config for AWS instances.+3. Grafana + Prometheus for monitoring.-To simulate 1,000,000 concurrent active connections, we used 20 AWS EC2 instances with 16 cores and 32GB of RAM. We ran the tests for up to 2 hours to ensure that the Supavisor could handle the load over long periods.+To simulate 1,000,000 concurrent active connections, we used 20 AWS EC2 instances with 16 cores and 32GB of RAM. We ran the tests for up to 2 hours to ensure that the Supavisor can handle load over long periods.### Establishing a baseline@@ -128,7 +128,7 @@ The system showed no signs of instability or performance degradation. QPS remain/></div>-While running this scenario, we also monitored how the load was distributed over Supavisor instance's cores:+We also monitored how the load was distributed over Supavisor instance's cores:<div><img@@ -143,7 +143,7 @@ While running this scenario, we also monitored how the load was distributed over/></div>-The load is evenly spread between all cores, which is great. CPU usage is high, signaling that it is around the maximum possible for the current setup. A single instance of Supavisor with 64 cores could handle about 500,000 connections with little capacity left for emergency cases. With this reference number, we moved on to horizontal scaling tests.+The load is spread evenly between all cores, which is great. CPU usage is high, signaling that the current setup has reached its capacity: a single Supavisor instance with 64 core handles around 500,000 connections. With this reference number, we moved on to horizontal scaling tests.### Scaling to 1,000,000 connections@@ -167,7 +167,7 @@ In the Supavisor architecture, only single node holds direct connections to eachThis setup successfully handled:- **1,003,200 simultaneous connections** to the Supavisor instances.-- **20,000 QPS** or **1.2 million queries per minute.** Each user connected executed `select` queries once every 50 seconds.+- **20,000 QPS** or **1.2 million queries per minute.** Each connection executed a `select` query once every 50 seconds.<div><img@@ -217,7 +217,7 @@ In a multitenant setup (or when using Read-Replicas), the load is much more even### Supavisor's impact on query duration-To measure the impact, we started with 5,000 QPS (queries per second). This allows us to exclude side effects from the database side (long query execution times).+To measure the impact on query duration, we started with 5,000 queries per second. This allows us to exclude side effects from the database side (long query execution times).The query used in the experiment was the following:@@ -254,7 +254,7 @@ We found with Supavisor median query duration was less than 2ms. And this includWe can see that 95% of queries were completed in less than 3 milliseconds. A slightly higher query duration at the beginning of the test can be explained by the dynamic nature of Supavisor-to-Database connection pool. It is being scaled up to the hard limit when more clients establish connections to Supavisor itself and scaled back down when users leave.-But if you are curious about the scenario with 20,000QPS, we measured a median of 18.4ms:+We continued to scale up to 20,000QPS to assess the impact on latency and measured a median of 18.4ms:| | Query Duration || ------ | -------------- |