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
@@ -48,7 +48,7 @@ module.exports = ({others, sendItemList}) => {
achievements.currencyChanged(account, currency, -purchase.cost);
achievements.add(account, achievements.VARS.clothesBought);
const item = addClothing(account, def.id, colors[colorIndex]);
accounts.save();
accounts.save(account);
sendClothingAdded(session, item);
session.sendXt("ib", -1, 1, shopId, account.currency[currency], purchase.currencyType);
},
@@ -95,7 +95,7 @@ module.exports = ({others, sendItemList}) => {
};
const off = ids.slice(onCount).filter(invIdx => setWorn(invIdx, false) !== null);
const on = ids.slice(0, onCount).map(invIdx => [invIdx, setWorn(invIdx, true)]).filter(([, def]) => def !== null);
accounts.save();
accounts.save(account);
// ItemXtCommManager.itemUseResponse
session.sendXt("iu", -1, 1);
// the reply only closes the editor. the animal in the room is redrawn
@@ -127,7 +127,7 @@ module.exports = ({others, sendItemList}) => {
account.currency[received] = (account.currency[received] || 0) + def.result;
achievements.currencyChanged(account, paid, -def.cost);
achievements.currencyChanged(account, received, def.result);
accounts.save();
accounts.save(account);
// ItemXtCommManager.currencyUpdateResponse: [currencyType, newAmount, reason]
session.sendXt("cu", -1, def.resultType, account.currency[received], 0);
session.sendXt("ce", -1, 1, account.currency[paid]);
@@ -154,7 +154,7 @@ module.exports = ({others, sendItemList}) => {
account.items.splice(index, 1);
recycled.push(invIdx);
}
accounts.save();
accounts.save(account);
session.sendXt("ir", -1, recycled.length, account.currency.gems || 0, ...recycled);
if (recycled.length) {
sendClothingRemoved(session, recycled);