-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Impose limit on batch request size #879
Conversation
c2222fc
to
ae94c15
Compare
portal-bridge/src/pandaops.rs
Outdated
@@ -45,6 +47,23 @@ impl PandaOpsMiddleware { | |||
/// multiple async requests. Using "ureq" consistently resulted in errors as soon as the number of | |||
/// concurrent tasks increased significantly. | |||
pub async fn batch_request(&self, obj: Vec<JsonRequest>) -> anyhow::Result<String> { | |||
let futs = obj |
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.
let futs = obj | |
let batched_request_futures = obj |
portal-bridge/src/pandaops.rs
Outdated
.chunks(BATCH_LIMIT) | ||
.map(|chunk| self.batch_request_100(chunk.to_vec())) | ||
.collect::<Vec<_>>(); | ||
match futures::future::join_all(futs).await.into_iter().try_fold( |
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.
I'd use futures::future::join_all
instead of inlining
portal-bridge/src/pandaops.rs
Outdated
@@ -45,6 +47,23 @@ impl PandaOpsMiddleware { | |||
/// multiple async requests. Using "ureq" consistently resulted in errors as soon as the number of | |||
/// concurrent tasks increased significantly. | |||
pub async fn batch_request(&self, obj: Vec<JsonRequest>) -> anyhow::Result<String> { |
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.
pub async fn batch_request(&self, obj: Vec<JsonRequest>) -> anyhow::Result<String> { | |
pub async fn batch_requests(&self, obj: Vec<JsonRequest>) -> anyhow::Result<String> { |
nit: I think that this name makes more sense given the new behavior
portal-bridge/src/pandaops.rs
Outdated
} | ||
} | ||
|
||
async fn batch_request_100(&self, obj: Vec<JsonRequest>) -> anyhow::Result<Vec<Value>> { |
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.
async fn batch_request_100(&self, obj: Vec<JsonRequest>) -> anyhow::Result<Vec<Value>> { | |
async fn send_requests(&self, requests: Vec<JsonRequest>) -> anyhow::Result<Vec<Value>> { | |
if requests.len() > BATCH_LIMIT { warn!("Attempting to send requests outnumbering pandaops limit") } |
use serde_json::json; | ||
use serde_json::{json, Value}; | ||
|
||
const BATCH_LIMIT: usize = 100; |
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.
A short docstring will be useful here to describe this const.
portal-bridge/src/pandaops.rs
Outdated
} | ||
} | ||
|
||
async fn batch_request_100(&self, obj: Vec<JsonRequest>) -> anyhow::Result<Vec<Value>> { |
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.
if we change the BATCH_LIMIT
const this function name will not be relevant anymore.
2824f2c
to
fbbb6e8
Compare
fbbb6e8
to
64c1a33
Compare
What was wrong?
Fixes #830
Batch requests to a panda-ops provider of > 100 were failing as those clients are configured to handle a max of 100 batch requests at a time.
This bug was the reason why our bridge has not been pumping out receipts. Can confirm that bridge now gossips receipts as expected.
How was it fixed?
Add a limit to haw many pandaops requests can be batched into a single request.
To-Do