-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DPLT-1118 Parallelize stream processing with worker threads #191
Conversation
f2d5da8
to
6983e21
Compare
2d69c4d
to
71be610
Compare
42ecd8c
to
e82e2ef
Compare
e82e2ef
to
49a3a4b
Compare
name: 'queryapi_runner_execution_duration_milliseconds', | ||
help: 'Time taken to execute an indexer function', | ||
labelNames: ['indexer', 'type'], | ||
}); | ||
|
||
export const METRICS = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exporting as a single group allows us to automatically create associated types, see: Metric
in StreamHandler
import { type Message } from './types'; | ||
import { METRICS } from '../metrics'; | ||
|
||
export default class StreamHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a wrapper around Worker
which will (eventually) expose a nicer API to the consumer, meaning they don't have to deal with sending/receiving messages.
@@ -0,0 +1,9 @@ | |||
import { type METRICS } from '../metrics'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shared types between the worker and api (StreamHandler
)
|
||
const unprocessedMessages = await redisClient.getUnprocessedStreamMessages(streamKey); | ||
|
||
parentPort?.postMessage({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics written directly from another thread won't be picked up by the main thread, where the metrics server aggregates and exposes them. We therefore need to send the metric to the main thread and write them there.
f581c94
to
6cfc43c
Compare
fdb019d
to
6cfc43c
Compare
This PR parallelises indexer processing by moving them to their own threads. This means that CPU is no longer shared across all indexers on the single thread. I/O is still shared across all threads, but shouldn't be an issue as this isn't the limiting factor of Runner.