Skip to content

Commit

Permalink
Register the 'SEQUENCING_MAX_WORKER_NUM' knob
Browse files Browse the repository at this point in the history
* Set the server worker pool with this value
  • Loading branch information
goetzrrGit committed Jun 12, 2024
1 parent cdafe36 commit 745ead5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sequencing-server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export let graphqlClient = new GraphQLClient(getEnv().MERLIN_GRAPHQL_URL, {
export const piscina = new Piscina({
filename: new URL('worker.js', import.meta.url).pathname,
minThreads: parseInt(getEnv().SEQUENCING_WORKER_NUM),
maxThreads: parseInt(getEnv().SEQUENCING_MAX_WORKER_NUM),
resourceLimits: { maxOldGenerationSizeMb: parseInt(getEnv().SEQUENCING_MAX_WORKER_HEAP_MB) },
});
export const promiseThrottler = new PromiseThrottler(parseInt(getEnv().SEQUENCING_WORKER_NUM) - 2);
Expand Down Expand Up @@ -299,6 +300,7 @@ app.listen(PORT, () => {
logger.info(`connected to port ${PORT}`);
logger.info(`Worker pool initialized:
Total workers started: ${piscina.threads.length},
Max Workers Allowed: ${getEnv().SEQUENCING_MAX_WORKER_NUM},
Heap Size per Worker: ${getEnv().SEQUENCING_MAX_WORKER_HEAP_MB} MB`);

if (getEnv().TRANSPILER_ENABLED === 'true') {
Expand Down
4 changes: 4 additions & 0 deletions sequencing-server/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type Env = {
SEQUENCING_DB_PASSWORD: string;
STORAGE: string;
SEQUENCING_WORKER_NUM: string;
SEQUENCING_MAX_WORKER_NUM : string
SEQUENCING_MAX_WORKER_HEAP_MB: string;
TRANSPILER_ENABLED: string;
};
Expand All @@ -27,6 +28,7 @@ export const defaultEnv: Env = {
STORAGE: 'sequencing_file_store',
SEQUENCING_WORKER_NUM: '8',
SEQUENCING_MAX_WORKER_HEAP_MB: '1000',
SEQUENCING_MAX_WORKER_NUM : '8',
TRANSPILER_ENABLED: 'true',
};

Expand All @@ -44,6 +46,7 @@ export function getEnv(): Env {
const SEQUENCING_DB_PASSWORD = env['SEQUENCING_DB_PASSWORD'] ?? defaultEnv.SEQUENCING_DB_PASSWORD;
const STORAGE = env['SEQUENCING_LOCAL_STORE'] ?? defaultEnv.STORAGE;
const SEQUENCING_WORKER_NUM = env['SEQUENCING_WORKER_NUM'] ?? defaultEnv.SEQUENCING_WORKER_NUM;
const SEQUENCING_MAX_WORKER_NUM = env['SEQUENCING_MAX_WORKER_NUM'] ?? defaultEnv.SEQUENCING_MAX_WORKER_NUM;
const SEQUENCING_MAX_WORKER_HEAP_MB =
env['SEQUENCING_MAX_WORKER_HEAP_MB'] ?? defaultEnv.SEQUENCING_MAX_WORKER_HEAP_MB;
const TRANSPILER_ENABLED = env['TRANSPILER_ENABLED'] ?? defaultEnv.TRANSPILER_ENABLED;
Expand All @@ -59,6 +62,7 @@ export function getEnv(): Env {
SEQUENCING_DB_PASSWORD,
STORAGE,
SEQUENCING_WORKER_NUM,
SEQUENCING_MAX_WORKER_NUM,
SEQUENCING_MAX_WORKER_HEAP_MB,
TRANSPILER_ENABLED,
};
Expand Down

0 comments on commit 745ead5

Please sign in to comment.