Add server overload detection

This commit is contained in:
2024-12-27 11:46:21 +01:00
parent 2c1aa92159
commit 3fa40e1954
6 changed files with 38 additions and 35 deletions

View File

@@ -35,9 +35,9 @@ will use your account's transfer limit.
## Free download limit ## Free download limit
The pixeldrain filesystem uses the same download limit as the regular files on The pixeldrain filesystem uses the same download limit as the regular files on
pixeldrain. The only difference is that the limit is 2 GB higher. So while you pixeldrain. The only difference is that the limit is 1 GB higher. So while you
can freely download up to 6 GB per day from regular pixeldrain files, you can can freely download up to 5 GB per day from regular pixeldrain files, you can
download up to 8 GB per day from the filesystem. When the limit is exceeded the download up to 6 GB per day from the filesystem. When the limit is exceeded the
speed is limited to 1 MiB/s like usual. speed is limited to 1 MiB/s like usual.
If you want to embed pixeldrain files on your own website, distribute direct If you want to embed pixeldrain files on your own website, distribute direct

View File

@@ -1,5 +1,7 @@
<script> <script>
import { onMount } from "svelte" import { onMount } from "svelte"
import { formatDataVolume } from "../util/Formatting.svelte";
import { stats } from "../lib/StatsSocket.js"
let ad_type = "" let ad_type = ""
@@ -8,18 +10,28 @@ onMount(() => {
// 10% reviews // 10% reviews
// 50% patreon // 50% patreon
let rand = Math.random() // let rand = Math.random()
if (rand < 0.4) { // if (rand < 0.4) {
ad_type = "socials" // ad_type = "socials"
} else if (rand < 0.5) { // } else if (rand < 0.5) {
ad_type = "reviews" // ad_type = "reviews"
} else { // } else {
ad_type = "patreon_support" // ad_type = "patreon_support"
} // }
}) })
</script> </script>
{#if ad_type === "patreon_support"} {#if $stats.limits_init && $stats.limits.server_overload}
<div class="highlight_yellow" style="margin: 3px;">
Pixeldrain's servers are currently overloaded. In order to ensure
stability for our paying customers the free download limit has been
temporarily reduced to {formatDataVolume($stats.limits.transfer_limit,
3)}. If you want fast downloads, please return later when peak hours are
over.
</div>
{:else if ad_type === "patreon_support"}
<div class="banner support_banner"> <div class="banner support_banner">
<span style="display: block; margin-bottom: 2px;"> <span style="display: block; margin-bottom: 2px;">
@@ -35,23 +47,18 @@ onMount(() => {
<div class="banner center"> <div class="banner center">
<div class="socials"> <div class="socials">
Pixeldrain is on the fediverse!<br/> Pixeldrain on social media<br/>
<a href="https://mastodon.social/@fornax" rel="noreferrer" class="button" target="_blank" style="background-color: #595aff; color: #ffffff;"> <a href="https://mastodon.social/@fornax" rel="noreferrer" class="button" target="_blank" style="background-color: #595aff; color: #ffffff;">
<i class="icon small">people</i> <i class="icon small">people</i>
Mastodon Mastodon
</a> </a>
<a href="https://lemmy.fornaxian.tech/c/pixeldrain" <a href="https://bsky.app/profile/fornax.bsky.social"
rel="noreferrer" class="button" target="_blank" style="background-color: #14854f; color: #ffffff;" rel="noreferrer" class="button" target="_blank" style="background-color: #208bfe; color: #ffffff;"
> >
<i class="icon small">people</i> <i class="icon small">people</i>
Lemmy Bluesky
</a> </a>
</div>
<div class="socials">
And on other media too<br/>
<a href="https://discord.gg/TWKGvYAFvX" rel="noreferrer" class="button" target="_blank" style="background-color: #5b5eee; color: #ffffff;"> <a href="https://discord.gg/TWKGvYAFvX" rel="noreferrer" class="button" target="_blank" style="background-color: #5b5eee; color: #ffffff;">
<i class="icon small">people</i> <i class="icon small">people</i>
Discord Discord
@@ -99,14 +106,6 @@ onMount(() => {
</a> </a>
</div> </div>
{:else if ad_type === "overload"}
<div class="highlight_yellow" style="margin: 3px;">
Pixeldrain's server host is having network problems. In order to
ensure stability for our paying customers the free download limit
has been temporarily reduced to 3 GB
</div>
{/if} {/if}
<style> <style>

View File

@@ -39,9 +39,9 @@ $: {
width: 100%; width: 100%;
/* the font-size is two pixels smaller than the progress bar, this leaves /* the font-size is two pixels smaller than the progress bar, this leaves
one px margin top and bottom */ one px margin top and bottom */
height: 16px; height: 18px;
font-size: 14px; font-size: 15px;
line-height: 15px; line-height: 18px;
overflow: hidden; overflow: hidden;
} }
.progress_bar_inner { .progress_bar_inner {

View File

@@ -32,6 +32,8 @@ export const set_file = async file => {
file.availability === "ip_download_limited_captcha_required" file.availability === "ip_download_limited_captcha_required"
) { ) {
viewer_type = "rate_limit" viewer_type = "rate_limit"
} else if (!premium_download && $stats.limits.transfer_limit_used > $stats.limits.transfer_limit) {
viewer_type = "slow_down"
} else { } else {
viewer_type = file_type(file) viewer_type = file_type(file)
} }
@@ -65,7 +67,7 @@ export const seek = delta => {
</div> </div>
{:else if viewer_type === "abuse"} {:else if viewer_type === "abuse"}
<Abuse bind:this={viewer} on:download></Abuse> <Abuse bind:this={viewer} on:download></Abuse>
{:else if !premium_download && $stats.limits.transfer_limit_used > $stats.limits.transfer_limit} {:else if viewer_type === "slow_down"}
<SlowDown <SlowDown
on:download on:download
file_size={current_file.size} file_size={current_file.size}

View File

@@ -33,8 +33,8 @@ export let icon_href = ""
Come back tomorrow when your free transfer limit resets Come back tomorrow when your free transfer limit resets
</li> </li>
<li> <li>
Download the file at a limited rate of 1 MiB/s. This will take at Download the file at a limited rate of {formatDataVolume($stats.limits.speed_limit, 3)}/s. This will take at
least {formatDuration((file_size/(1<<20))*1000, 0)} least {formatDuration((file_size/($stats.limits.speed_limit))*1000, 0)}
</li> </li>
<li> <li>
<a href="/#pro" target="_blank" class="button button_highlight"> <a href="/#pro" target="_blank" class="button button_highlight">

View File

@@ -11,6 +11,8 @@ let results = {
}, },
limits_init: false, limits_init: false,
limits: { limits: {
server_overload: false,
speed_limit: 0,
download_limit: 0, download_limit: 0,
download_limit_used: 0, download_limit_used: 0,
transfer_limit: 0, transfer_limit: 0,