mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -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
+3
-3
@@ -95,7 +95,7 @@ const give = body => {
|
||||
if (!item) {
|
||||
return {status: 409, body: {error: "That inventory is full"}};
|
||||
}
|
||||
accounts.save();
|
||||
accounts.save(account);
|
||||
if (session) {
|
||||
sendClothingAdded(session, item);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ const give = body => {
|
||||
account.finderGiven[key] = {count: ((account.finderGiven[key] || {}).count || 0) + 1, at: Math.floor(Date.now() / 1000)};
|
||||
const kept = Object.entries(account.finderGiven).sort((one, other) => other[1].at - one[1].at).slice(0, MAX_FAVOURITES);
|
||||
account.finderGiven = Object.fromEntries(kept);
|
||||
accounts.save();
|
||||
accounts.save(account);
|
||||
return {status: 200, body: {ok: true, online: Boolean(session)}};
|
||||
};
|
||||
|
||||
@@ -236,7 +236,7 @@ const handle = async (route, params, body, from) => {
|
||||
const result = accounts.register(username, password, {type: avatarType});
|
||||
if (result.account) {
|
||||
result.account.agreed = {version: config.termsVersion, at: Math.floor(Date.now() / 1000)};
|
||||
accounts.save();
|
||||
accounts.save(result.account);
|
||||
}
|
||||
// the client signs in straight after, and is not asked again.
|
||||
return result.error ? {status: 400, body: {error: result.error}}
|
||||
|
||||
Reference in new issue
Block a user