From aafe9612147892b57b691edccfa560b66e3ab253 Mon Sep 17 00:00:00 2001 From: Bossett Date: Fri, 6 Sep 2024 03:23:09 +0000 Subject: [PATCH] pooled connections, tweaked limit --- src/db/db.ts | 5 +++-- src/env/limits.ts | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/db/db.ts b/src/db/db.ts index 64998e6..9594995 100644 --- a/src/db/db.ts +++ b/src/db/db.ts @@ -1,7 +1,6 @@ import env from '@/env/env.js' import * as schema from '@/db/schema.js' -/* import { Pool, neonConfig } from '@neondatabase/serverless' import { drizzle } from 'drizzle-orm/neon-serverless' @@ -10,13 +9,15 @@ import ws from 'ws' neonConfig.webSocketConstructor = ws const pool = new Pool({ connectionString: env.NEON_DATABASE_URL }) -const db = drizzle(pool, { schema: schema })*/ +const db = drizzle(pool, { schema: schema }) +/* import { drizzle } from 'drizzle-orm/postgres-js' import postgres from 'postgres' const queryClient = postgres(env.NEON_DATABASE_URL) const db = drizzle(queryClient, { schema: schema }) +*/ export default db diff --git a/src/env/limits.ts b/src/env/limits.ts index 4aea733..af578ee 100644 --- a/src/env/limits.ts +++ b/src/env/limits.ts @@ -16,12 +16,12 @@ const limits = { DELETE_LIMIT_MAX_RATE: 2_750, DELETE_LIMIT_RATE_INTERVAL_MS: 60 * 60 * 1000, // rate limit for plc.directory - PLC_LIMIT_MAX_CONCURRENT: 192, + PLC_LIMIT_MAX_CONCURRENT: undefined, PLC_LIMIT_MAX_DELAY_MS: undefined, PLC_LIMIT_MAX_RATE: undefined, PLC_LIMIT_RATE_INTERVAL_MS: undefined, // rate limit for public API - PUBLIC_LIMIT_MAX_CONCURRENT: 96, + PUBLIC_LIMIT_MAX_CONCURRENT: 64, PUBLIC_LIMIT_MAX_DELAY_MS: undefined, PUBLIC_LIMIT_MAX_RATE: undefined, PUBLIC_LIMIT_RATE_INTERVAL_MS: undefined, @@ -31,7 +31,7 @@ const limits = { // ***** APPLICATION CONFIG ***** AUTHOR_FEED_MAX_RESULTS: 30, // sets the limit parameter requesting an author's posts - 30 is what bsky.app uses so the cache should be fresher DB_WRITE_INTERVAL_MS: 15 * 60 * 1000, // time between pauses to update firehose sequence and scavenge cache - higher is generally better but you will have to reprocess this much on restart - MAX_CONCURRENT_PROCESSCOMMITS: 96, // this influences # of http requests, so lower can be faster + MAX_CONCURRENT_PROCESSCOMMITS: 128, // this influences # of http requests, so lower can be faster MAX_FIREHOSE_DELAY: 3 * 60 * 1000, // how long between events before considering the firehose stalled MIN_FIREHOSE_OPS: 30, // the minimum number of operations per interval before considering the firehose stalled MAX_PENDING_INSERTS_WAIT_MS: 30 * 1000, // the maximum amount of time between inserting pending label events @@ -46,7 +46,7 @@ const limits = { PLC_DIRECTORY_MAX_SIZE: 25000, POST_CACHE_MAX_AGE_MS: 3 * 60 * 60 * 1000, POST_CACHE_MAX_SIZE: 1500, - MIN_BATCH_WAIT_TIME_MS: 100, + MIN_BATCH_WAIT_TIME_MS: 500, BATCH_CYCLE_TIMEOUT_MS: 3 * 60 * 1000, }