From 134a13f835cc22f8fbba08f2d2a4b4d874ffd6ab Mon Sep 17 00:00:00 2001 From: Rodrigo Mansueli Date: Fri, 19 Apr 2024 08:39:07 -0300 Subject: [PATCH] feat: storage egress guide (#22807) * feat: storage egress guide * typo + prettier * Update bandwidth.mdx * Update bandwidth.mdx * Update bandwidth.mdx * Update apps/docs/content/guides/storage/serving/bandwidth.mdx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> --------- Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> --- .../NavigationMenu.constants.ts | 4 ++ .../guides/storage/serving/bandwidth.mdx | 72 +++++++++++++++++++ .../guides/storage/serving/downloads.mdx | 2 +- 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 apps/docs/content/guides/storage/serving/bandwidth.mdx diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts index dd368b2c605..03bd6aaeb03 100644 --- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts +++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts @@ -1376,6 +1376,10 @@ export const storage: NavMenuConstant = { name: 'Image Transformations', url: '/guides/storage/serving/image-transformations', }, + { + name: 'Bandwidth & Storage Egress', + url: '/guides/storage/serving/bandwidth', + }, ], }, { diff --git a/apps/docs/content/guides/storage/serving/bandwidth.mdx b/apps/docs/content/guides/storage/serving/bandwidth.mdx new file mode 100644 index 00000000000..4c0049ed0db --- /dev/null +++ b/apps/docs/content/guides/storage/serving/bandwidth.mdx @@ -0,0 +1,72 @@ +--- +id: 'storage-bandwidth' +title: 'Bandwidth & Storage Egress' +description: 'How to calculate the Bandwidth and Storage Egress' +subtitle: 'Bandwidth & Storage Egress' +sidebar_label: 'Bandwidth & Storage Egress' +--- + +## Bandwidth & Storage Egress + +Free plan Organizations in Supabase have a limit of 5 GB of bandwidth. This limit is calculated by the sum of all the data transferred from the Supabase servers to the client. This includes all the data transferred from the database, storage, and functions. + +### Checking Storage Egress Requests in Log Explorer: + +We have a template query that you can use to get the number of requests for each object in [Log Explorer](/dashboard/project/_/logs/explorer/templates). + +```sql +select + r.method as http_verb, + r.path as filepath, + count(*) as num_requests +from + edge_logs + cross join unnest(metadata) as m + cross join unnest(m.request) as r + cross join unnest(r.headers) as h +where (path like '%storage/v1/object/%' or path like '%storage/v1/render/%') and r.method = 'GET' +group by r.path, r.method +order by num_requests desc +limit 100; +``` + +Example of the output: + +``` +[ + {"filepath":"/storage/v1/object/sign/large%20bucket/20230902_200037.gif", + "http_verb":"GET", + "num_requests":100 + }, + {"filepath":"/storage/v1/object/public/demob/Sports/volleyball.png", + "http_verb":"GET", + "num_requests":168 + } +] +``` + +### Calculating Egress: + +If you already know the size of those files, you can calculate the egress by multiplying the number of requests by the size of the file. +You can also get the size of the file with the following cURL: + +```bash +curl -s -w "%{size_download}\n" -o /dev/null "https://my_project.supabase.co/storage/v1/object/large%20bucket/20230902_200037.gif" +``` + +This will return the size of the file in bytes. +For this example, let's say that `20230902_200037.gif` has a file size of 3 megabytes and `volleyball.png` has a file size of 570 kilobytes. + +Now, we have to sum all the egress for all the files to get the total egress: + +``` +100 * 3MB = 300MB +168 * 570KB = 95.76MB +Total Egress = 395.76MB +``` + +You can see that these values can get quite large, so it's important to keep track of the egress and optimize the files. + +### Optimizing Egress: + +If you are on the pro plan, you can use the [Supabase Image Transformations](/docs/guides/storage/image-transformations) to optimize the images and reduce the egress. diff --git a/apps/docs/content/guides/storage/serving/downloads.mdx b/apps/docs/content/guides/storage/serving/downloads.mdx index 31256c46cb0..c0603bbd2eb 100644 --- a/apps/docs/content/guides/storage/serving/downloads.mdx +++ b/apps/docs/content/guides/storage/serving/downloads.mdx @@ -1,5 +1,5 @@ --- -id: 'storage-image-transformations' +id: 'storage-image-downloads' title: 'Serving assets from Storage' description: 'Serving assets from Storage' subtitle: 'Serving assets from Storage'