Skip to content

Open-source status page, incident response and uptime monitoring

🚀 improve fly (#450)

Thibault Le Ouayefe458d39586
diff --git a/apps/server/fly.toml b/apps/server/fly.toml
index 2b43881e9..5e1866ef5 100644
--- a/apps/server/fly.toml
+++ b/apps/server/fly.toml
@@ -15,11 +15,15 @@ primary_region = "ams"
force_https = true
auto_stop_machines = true
auto_start_machines = true
- min_machines_running = 6
+ min_machines_running = 12
processes = ["app"]
+ [http_service.concurrency]
+ type = "requests"
+ hard_limit = 1000
+ soft_limit = 500
[deploy]
- strategy = "canary"
+ strategy = "bluegreen"
[[http_service.checks]]
grace_period = "10s"
diff --git a/apps/server/src/public/index.ts b/apps/server/src/public/index.ts
index 21e485a3e..ae87572f2 100644
--- a/apps/server/src/public/index.ts
+++ b/apps/server/src/public/index.ts
@@ -1,9 +1,11 @@
import { Hono } from "hono";
import { logger } from "hono/logger";
+import { timing } from "hono/timing";
import { status } from "./status";
export const publicRoute = new Hono();
publicRoute.use("*", logger());
+publicRoute.use("*", timing());
publicRoute.route("/status", status);
diff --git a/apps/server/src/public/status.ts b/apps/server/src/public/status.ts
index 11bef7e0d..e54e3f919 100644
--- a/apps/server/src/public/status.ts
+++ b/apps/server/src/public/status.ts
@@ -1,4 +1,5 @@
import { Hono } from "hono";
+import { endTime, setMetric, startTime } from "hono/timing";
import { db, eq } from "@openstatus/db";
import { monitor, monitorsToPages, page } from "@openstatus/db/src/schema";
@@ -27,8 +28,12 @@ status.get("/:slug", async (c) => {
const { slug } = c.req.param();
const cache = await redis.get(slug);
- if (cache) return c.json({ status: cache });
+ if (cache) {
+ setMetric(c, "OpenStatus-Cache", "HIT");
+ return c.json({ status: cache });
+ }
+ startTime(c, "database");
// { monitors, pages, monitors_to_pages }
const monitorData = await db
.select()
@@ -37,7 +42,9 @@ status.get("/:slug", async (c) => {
.leftJoin(page, eq(monitorsToPages.pageId, page.id))
.where(eq(page.slug, slug))
.all();
+ endTime(c, "database");
+ startTime(c, "clickhouse");
// { data: [{ ok, count }] }
const lastMonitorPings = await Promise.allSettled(
monitorData.map(async ({ monitors_to_pages }) => {
@@ -47,7 +54,7 @@ status.get("/:slug", async (c) => {
});
}),
);
-
+ endTime(c, "clickhouse");
// { ok, count }
const data = lastMonitorPings.reduce(
(prev, curr) => {