Precharge les mappings IMDb au warmup (1.27s -> 16ms sur le premier appel /api?t=imdb)
This commit is contained in:
@@ -5,6 +5,7 @@ import secureSession from '@fastify/secure-session';
|
||||
import fastifyStatic from '@fastify/static';
|
||||
import Fastify from 'fastify';
|
||||
import { HOST, PORT, RATE_LIMIT_PER_SEC, ROOT, SESSION_SECRET } from './config.js';
|
||||
import { preloadMappings } from './lib/imdbMapping.js';
|
||||
import { getRatings } from './lib/imdbRatings.js';
|
||||
import { httpDuration, httpRequests, imdbRatingsCount, searchWorkers } from './lib/metrics.js';
|
||||
import { getPool } from './lib/searchEngine.js';
|
||||
@@ -80,7 +81,11 @@ fastify.ready().then(async () => {
|
||||
const tv = getPool('tv');
|
||||
searchWorkers.set({ type: 'movie' }, movie.workers.length);
|
||||
searchWorkers.set({ type: 'tv' }, tv.workers.length);
|
||||
fastify.log.info({ ratings: ratings.size }, 'Warmup complete');
|
||||
const maps = await preloadMappings();
|
||||
fastify.log.info(
|
||||
{ ratings: ratings.size, imdb_movie: maps.movie, imdb_tv: maps.tv },
|
||||
'Warmup complete',
|
||||
);
|
||||
} catch (err) {
|
||||
fastify.log.warn({ err }, 'Warmup failed');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user