Skip to content
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

feat: unify queues in proxy #976

Merged
merged 15 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Changes

- Refactored `miden-tx-prover` proxy load balancing strategy (#976).
- [BREAKING] Better error display when queues are full in the prover service (#967).
- [BREAKING] Remove `AccountBuilder::build_testing` and make `Account::initialize_from_components` private (#969).
- [BREAKING] Add error messages to errors and implement `core::error::Error` (#974).
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ bench-tx: ## Run transaction benchmarks

.PHONY: install-tx-prover
install-tx-prover: ## Install transaction prover's CLI
cargo install --path bin/tx-prover --bin miden-tx-prover --locked
cargo install --path bin/tx-prover --bin miden-tx-prover --locked --features concurrent

.PHONY: install-tx-prover-testing
install-tx-prover-testing: ## Install transaction prover's CLI intended for testing purposes
cargo install --path bin/tx-prover --bin miden-tx-prover --locked --features testing
cargo install --path bin/tx-prover --bin miden-tx-prover --locked --features concurrent,testing
2 changes: 1 addition & 1 deletion bin/tx-prover/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A service for generating Miden transaction proofs on-demand. The binary enables

The worker is a gRPC service that can receive transaction witnesses and returns the proof. It can only handle one request at a time and returns an error if is already in use.

The proxy uses [Cloudflare's Pingora crate](https://crates.io/crates/pingora), which provides features to create a modular proxy. It is meant to handle multiple workers with a queue for each one, load balancing incoming requests in a round-robin manner. Further information about Pingora and its features can be found in the [official GitHub repository](https://github.com/cloudflare/pingora).
The proxy uses [Cloudflare's Pingora crate](https://crates.io/crates/pingora), which provides features to create a modular proxy. It is meant to handle multiple workers with a queue, assigning a worker to each request and retrying if the worker is not available. Further information about Pingora and its features can be found in the [official GitHub repository](https://github.com/cloudflare/pingora).

Additionally, the library can be imported to utilize `RemoteTransactionProver`, a client struct that can be used to interact with the prover service from a Rust codebase.

Expand Down
11 changes: 4 additions & 7 deletions bin/tx-prover/src/commands/proxy.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use clap::Parser;
use pingora::{
apps::HttpServerOptions, lb::LoadBalancer as PingoraLoadBalancer, prelude::Opt, server::Server,
};
use pingora::{apps::HttpServerOptions, lb::Backend, prelude::Opt, server::Server};
use pingora_proxy::http_proxy_service;

use crate::{proxy::LoadBalancer, utils::load_config_from_file};
Expand All @@ -24,10 +22,9 @@ impl StartProxy {
let workers = proxy_config
.workers
.iter()
.map(|worker| format!("{}:{}", worker.host, worker.port));

let workers =
PingoraLoadBalancer::try_from_iter(workers).expect("PROVER_WORKERS is invalid");
.map(|worker| format!("{}:{}", worker.host, worker.port))
.map(|worker| Backend::new(&worker).expect("Failed to create backend"))
.collect::<Vec<Backend>>();

let worker_lb = LoadBalancer::new(workers, &proxy_config);

Expand Down
Loading
Loading