mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 01:27:51 -05:00
perf: save only changed accounts, cache missing assets, lighter logging and backup
Ping on prod jumped to seconds because node's main thread was busy most of every second. - accounts.save(account, ...) names the changed accounts, which are written within a second; the rest are looked at a few at a time (10 ms a save for those in play, 5 ms for the others). One save under prod-like load: 289 ms before, 16 ms after. - an asset the CDN does not have gets a cacheable 404 and is logged once - the proxy's own connections no longer count against the web cap, which had node reset requests nginx had already let in - a repeated client error is written once in ten minutes; the panel's log buffer trims in batches - the daily backup uses sqlite's online backup off the main thread
This commit is contained in:
1 parent
edca7bf790
commit
aa455f52d0
26 files changed
+334
-220
No files matched your search
+8
-8
@@ -177,7 +177,7 @@ module.exports = ({blocks}) => {
|
||||
owner.wall.posts.push(post);
|
||||
owner.wall.posts = owner.wall.posts.slice(-MAX_POSTS);
|
||||
owner.wall.modified = post.t;
|
||||
accounts.save();
|
||||
accounts.save(owner);
|
||||
return {PUT: {s: true}, x: post.x, t: post.t, GET: getReply(owner, viewer)};
|
||||
};
|
||||
|
||||
@@ -207,7 +207,7 @@ module.exports = ({blocks}) => {
|
||||
}
|
||||
wall.posts = wall.posts.filter(candidate => candidate !== post && candidate.pp !== post.x);
|
||||
wall.modified = Date.now();
|
||||
accounts.save();
|
||||
accounts.save(owner);
|
||||
return {s: true};
|
||||
}
|
||||
case "GMB": // posts the owner chose to hide
|
||||
@@ -217,7 +217,7 @@ module.exports = ({blocks}) => {
|
||||
return {s: false};
|
||||
}
|
||||
wall.hidden = [...new Set([...wall.hidden, body.x])].slice(-MAX_HIDDEN);
|
||||
accounts.save();
|
||||
accounts.save(owner);
|
||||
return {s: true};
|
||||
case "CLW":
|
||||
if (!mine) {
|
||||
@@ -226,7 +226,7 @@ module.exports = ({blocks}) => {
|
||||
wall.posts = [];
|
||||
wall.hidden = [];
|
||||
wall.modified = Date.now();
|
||||
accounts.save();
|
||||
accounts.save(owner);
|
||||
return {s: true};
|
||||
case "RMP": // masterpieces taken off the wall; there are none
|
||||
case "ACK": // notifications marked as read; there are none
|
||||
@@ -264,7 +264,7 @@ module.exports = ({blocks}) => {
|
||||
&& mayOpen(owner, session.account) === TOKEN_OK;
|
||||
if (allowed) {
|
||||
owner.wall.likes = [...likes(owner), session.account.id];
|
||||
accounts.save();
|
||||
accounts.save(owner);
|
||||
}
|
||||
session.sendXt("crp", -1, allowed ? 1 : 0);
|
||||
},
|
||||
@@ -286,7 +286,7 @@ module.exports = ({blocks}) => {
|
||||
const valid = [NOBODY, BUDDIES, EVERYONE].includes(value);
|
||||
if (valid) {
|
||||
session.account.wall.privacy = value;
|
||||
accounts.save();
|
||||
accounts.save(session.account);
|
||||
}
|
||||
session.sendXt("wss", -1, valid ? 1 : 0);
|
||||
},
|
||||
@@ -324,7 +324,7 @@ module.exports = ({blocks}) => {
|
||||
}
|
||||
wall.params = merged;
|
||||
wall.modified = Date.now();
|
||||
accounts.save();
|
||||
accounts.save(session.account);
|
||||
session.sendXt("wps", -1, 1);
|
||||
},
|
||||
|
||||
@@ -333,7 +333,7 @@ module.exports = ({blocks}) => {
|
||||
const owner = accounts.byName(username);
|
||||
if (owner && owner !== session.account && mayOpen(owner, session.account) === TOKEN_OK) {
|
||||
owner.wall.visits++;
|
||||
accounts.save();
|
||||
accounts.save(owner);
|
||||
}
|
||||
session.sendXt("wci", -1, owner ? 1 : 0);
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user