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:
Burrowdev committed 2026-10-17 11:57:40 +03:00
1 parent edca7bf790
commit aa455f52d0
26 files changed
+334 -220

No files matched your search

+4 -4
View File
@@ -78,7 +78,7 @@ module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields}
// (accounts.freeAvatarSlot).
const avatar = accounts.newAvatar({perUserAvId: account.nextInv++, avInvId: accounts.freeAvatarSlot(account)}, `${name1}|${name2}|${name3}`, type, customAvId);
account.avatars.push(avatar);
accounts.save();
accounts.save(account);
session.sendXt("aa", -1, 1, avatar.perUserAvId, avatar.avInvId);
},
@@ -93,7 +93,7 @@ module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields}
return;
}
account.activeAvatar = avatar.perUserAvId;
accounts.save();
accounts.save(account);
const messageRoom = session.room ? session.room.id : -1;
const common = [1, session.id, avatar.perUserAvId, avatar.avInvId, avatar.customAvId, avatar.type, ...avatar.colors, avatar.name];
session.sendXt("as", messageRoom, ...common, avatar.petInvId, avatar.questLevel || 0);
@@ -116,7 +116,7 @@ module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields}
for (const item of account.items) {
item.on = item.on.filter(avInvId => avInvId !== avatar.avInvId);
}
accounts.save();
accounts.save(account);
session.sendXt("ak", -1, 1, 0);
},
@@ -134,7 +134,7 @@ module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields}
if (tagChanged) {
session.account.nameBarData = nameBarData;
}
accounts.save();
accounts.save(session.account);
session.sendXt("ap", -1, 1);
refreshForOthers(session);
if (tagChanged) {