Skip to content

Commit

Permalink
pooled connections, tweaked limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Bossett committed Sep 6, 2024
1 parent 87823d8 commit aafe961
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/db/db.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/env/limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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,
}

Expand Down

0 comments on commit aafe961

Please sign in to comment.