-
-
Notifications
You must be signed in to change notification settings - Fork 6
feat(taskbroker): Batch Claimed → Processing Updates #637
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
base: main
Are you sure you want to change the base?
Changes from all commits
264c538
26dfa5f
04b7962
9c87519
27ae1de
67a692d
c2112fe
81f949d
88dce44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,11 +122,10 @@ impl<T: TaskPusher + Send + Sync + 'static> FetchPool<T> { | |
| } | ||
|
|
||
| _ = async { | ||
| let start = Instant::now(); | ||
|
|
||
| debug!("Fetching next batch of pending activations..."); | ||
| metrics::counter!("fetch.loop.count").increment(1); | ||
|
|
||
| let start = Instant::now(); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Starting the timer here results in more accurate metrics. It was already like this before but I unintentionally moved it in #618. |
||
| let mut backoff = false; | ||
|
|
||
| let result = store.claim_activations_for_push(limit, bucket).await; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,10 +98,14 @@ impl InflightActivationStore for MockStore { | |
| }) | ||
| } | ||
|
|
||
| async fn mark_activation_processing(&self, _id: &str) -> Result<(), Error> { | ||
| async fn mark_processing(&self, _id: &str) -> Result<(), Error> { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor naming change to match |
||
| Ok(()) | ||
| } | ||
|
|
||
| async fn mark_processing_batch(&self, _ids: &[String]) -> Result<u64, Error> { | ||
| unimplemented!() | ||
| } | ||
|
|
||
| async fn pending_activation_max_lag(&self, _now: &DateTime<Utc>) -> f64 { | ||
| unimplemented!() | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ use taskbroker::config::{Config, DatabaseAdapter, DeliveryMode}; | |
| use taskbroker::fetch::FetchPool; | ||
| use taskbroker::grpc::auth_middleware::AuthLayer; | ||
| use taskbroker::grpc::metrics_middleware::MetricsLayer; | ||
| use taskbroker::grpc::server::{TaskbrokerServer, flush_updates}; | ||
| use taskbroker::grpc::server::TaskbrokerServer; | ||
| use taskbroker::kafka::admin::create_missing_topics; | ||
| use taskbroker::kafka::consumer::start_consumer; | ||
| use taskbroker::kafka::deserialize::{self, DeserializeConfig}; | ||
|
|
@@ -27,7 +27,6 @@ use taskbroker::kafka::inflight_activation_writer::{ | |
| ActivationWriterConfig, InflightActivationWriter, | ||
| }; | ||
| use taskbroker::kafka::os_stream_writer::{OsStream, OsStreamWriter}; | ||
| use taskbroker::logging; | ||
| use taskbroker::metrics; | ||
| use taskbroker::processing_strategy; | ||
| use taskbroker::push::PushPool; | ||
|
|
@@ -40,6 +39,7 @@ use taskbroker::store::traits::InflightActivationStore; | |
| use taskbroker::upkeep::upkeep; | ||
| use taskbroker::{Args, get_version}; | ||
| use taskbroker::{SERVICE_NAME, flusher}; | ||
| use taskbroker::{grpc, logging, push}; | ||
|
|
||
| async fn log_task_completion<T: AsRef<str>>(name: T, task: JoinHandle<Result<(), Error>>) { | ||
| match task.await { | ||
|
|
@@ -203,7 +203,7 @@ async fn main() -> Result<(), Error> { | |
| rx, | ||
| flusher_config.status_update_batch_size, | ||
| flusher_config.status_update_interval_ms, | ||
| move |buffer| Box::pin(flush_updates(flusher_store.clone(), buffer)), | ||
| move |buffer| Box::pin(grpc::server::flush_updates(flusher_store.clone(), buffer)), | ||
| ) | ||
| .await | ||
| }); | ||
|
|
@@ -265,8 +265,30 @@ async fn main() -> Result<(), Error> { | |
| } | ||
| }); | ||
|
|
||
| // Push update flush task | ||
| let (push_update_tx, push_update_task) = if config.batch_push_updates { | ||
| let (tx, rx) = tokio::sync::mpsc::channel(config.push_update_batch_size.max(1)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reasoning behind setting the channel size to the batch flush size? Did we do any testing around how changing the amount slack between these two configurations affect the system?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A metric that would be interesting is the channel's depth which might give some intuition behind if producers want to send faster than the flusher drains
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Added gauges for
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And no, I haven't extensively tested different channel / batch flush sizes. Good idea for the future. |
||
|
|
||
| let flusher_store = store.clone(); | ||
| let flusher_config = config.clone(); | ||
|
|
||
| let handle = tokio::spawn(async move { | ||
| flusher::run_flusher( | ||
| rx, | ||
| flusher_config.push_update_batch_size, | ||
| flusher_config.push_update_interval_ms, | ||
| move |buffer| Box::pin(push::flush_updates(flusher_store.clone(), buffer)), | ||
| ) | ||
| .await | ||
| }); | ||
|
|
||
| (Some(tx), Some(handle)) | ||
| } else { | ||
| (None, None) | ||
| }; | ||
|
|
||
| // Initialize push and fetch pools | ||
| let push_pool = Arc::new(PushPool::new(config.clone(), store.clone())); | ||
| let push_pool = Arc::new(PushPool::new(config.clone(), store.clone(), push_update_tx)); | ||
| let fetch_pool = FetchPool::new(store.clone(), config.clone(), push_pool.clone()); | ||
|
|
||
| // Initialize push threads | ||
|
|
@@ -305,6 +327,10 @@ async fn main() -> Result<(), Error> { | |
| departure = departure.on_completion(log_task_completion("status_update_task", task)); | ||
| } | ||
|
|
||
| if let Some(task) = push_update_task { | ||
| departure = departure.on_completion(log_task_completion("push_update_task", task)); | ||
| } | ||
|
sentry[bot] marked this conversation as resolved.
|
||
|
|
||
| departure.await; | ||
| Ok(()) | ||
| } | ||
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.
As soon as all this is done, we should probably reorganize the configuration. It has become enormous 😅
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.
We could break it up into a few different nested structures.