diff --git a/addon/addon.js b/addon/addon.js index f7fb696..f7566e0 100644 --- a/addon/addon.js +++ b/addon/addon.js @@ -18,17 +18,18 @@ const STALE_ERROR_AGE = 7 * 24 * 60 * 60; // 7 days const builder = new addonBuilder(dummyManifest()); const limiter = new Bottleneck({ - maxConcurrent: process.env.LIMIT_MAX_CONCURRENT || 200, - highWater: process.env.LIMIT_QUEUE_SIZE || 220, + maxConcurrent: process.env.LIMIT_MAX_CONCURRENT || 100, + highWater: process.env.LIMIT_QUEUE_SIZE || 120, strategy: Bottleneck.strategy.OVERFLOW }); +const limiterOptions = { expiration: 2 * 60 * 1000 } builder.defineStreamHandler((args) => { if (!args.id.match(/tt\d+/i) && !args.id.match(/kitsu:\d+/i)) { return Promise.resolve({ streams: [] }); } - return cacheWrapStream(args.id, () => limiter.schedule(() => streamHandler(args) + return cacheWrapStream(args.id, () => limiter.schedule(limiterOptions, () => streamHandler(args) .then(records => records .sort((a, b) => b.torrent.seeders - a.torrent.seeders || b.torrent.uploadDate - a.torrent.uploadDate) .map(record => toStreamInfo(record))))) diff --git a/addon/lib/cache.js b/addon/lib/cache.js index 710f50e..48a3d35 100644 --- a/addon/lib/cache.js +++ b/addon/lib/cache.js @@ -29,7 +29,8 @@ function initiateRemoteCache() { uri: MONGO_URI, options: { collection: 'torrentio_addon_collection', - socketTimeoutMS: 120000, + socketTimeoutMS: 30000, + poolSize: 150, useNewUrlParser: true, useUnifiedTopology: false, ttl: STREAM_EMPTY_TTL diff --git a/addon/lib/repository.js b/addon/lib/repository.js index e6c3029..cdee1ac 100644 --- a/addon/lib/repository.js +++ b/addon/lib/repository.js @@ -3,7 +3,7 @@ const Op = Sequelize.Op; const DATABASE_URI = process.env.DATABASE_URI; -const database = new Sequelize(DATABASE_URI, { logging: false }); +const database = new Sequelize(DATABASE_URI, { logging: false, pool: { max: 50 } }); const Torrent = database.define('torrent', {