From 396356faac83809bb47414ecab7f1ce59607cc2f Mon Sep 17 00:00:00 2001 From: Ertugrul Aypek Date: Sun, 12 Jan 2025 16:28:13 +0100 Subject: [PATCH] separate s3 clients for sns requests and chunks --- deploy/stage/common-values-iris-mpc.yaml | 2 +- iris-mpc-store/src/s3_importer.rs | 2 +- iris-mpc/src/bin/server.rs | 21 ++++++++++++++------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/deploy/stage/common-values-iris-mpc.yaml b/deploy/stage/common-values-iris-mpc.yaml index 572f11407..f41376c43 100644 --- a/deploy/stage/common-values-iris-mpc.yaml +++ b/deploy/stage/common-values-iris-mpc.yaml @@ -1,4 +1,4 @@ -image: "ghcr.io/worldcoin/iris-mpc:05d4b8bf587826573163c6ef5d6145a2a12cf9f2" +image: "ghcr.io/worldcoin/iris-mpc:103fccb9459f70c73fcb3d2c04bd994545e2b441" environment: stage replicaCount: 1 diff --git a/iris-mpc-store/src/s3_importer.rs b/iris-mpc-store/src/s3_importer.rs index 58cfcefdf..59df6b017 100644 --- a/iris-mpc-store/src/s3_importer.rs +++ b/iris-mpc-store/src/s3_importer.rs @@ -19,7 +19,7 @@ const SINGLE_ELEMENT_SIZE: usize = IRIS_CODE_LENGTH * mem::size_of::() * 2 + MASK_CODE_LENGTH * mem::size_of::() * 2 + mem::size_of::(); // 75 KB -const MAX_RANGE_SIZE: usize = 200; // Download chunks in sub-chunks of 100 elements = 7.5 MB +const MAX_RANGE_SIZE: usize = 200; // Download chunks in sub-chunks of 200 elements = 15 MB pub struct S3StoredIris { #[allow(dead_code)] diff --git a/iris-mpc/src/bin/server.rs b/iris-mpc/src/bin/server.rs index c355567c5..495b33801 100644 --- a/iris-mpc/src/bin/server.rs +++ b/iris-mpc/src/bin/server.rs @@ -755,8 +755,11 @@ async fn server_main(config: Config) -> eyre::Result<()> { )); shutdown_handler.wait_for_shutdown_signal().await; - let shares_bucket_host = format!("{}.s3.{}.amazonaws.com", config.shares_bucket_name, "eu-central-1"); - let shares_bucket_ips = resolve_export_bucket_ips(shares_bucket_host); + let db_chunks_bucket_host = format!( + "{}.s3.{}.amazonaws.com", + config.db_chunks_bucket_name, REGION + ); + let db_chunks_bucket_ips = resolve_export_bucket_ips(db_chunks_bucket_host); // Load batch_size config *CURRENT_BATCH_SIZE.lock().unwrap() = config.max_batch_size; let max_sync_lookback: usize = config.max_batch_size * 2; @@ -776,18 +779,22 @@ async fn server_main(config: Config) -> eyre::Result<()> { let sns_client = SNSClient::new(&shared_config); // Increase S3 retries to 5 - let static_resolver = StaticResolver::new(shares_bucket_ips.await?); - let client = HyperClientBuilder::new() + let static_resolver = StaticResolver::new(db_chunks_bucket_ips.await?); + let http_client = HyperClientBuilder::new() .crypto_mode(CryptoMode::Ring) .build_with_resolver(static_resolver); let retry_config = RetryConfig::standard().with_max_attempts(5); let s3_config = S3ConfigBuilder::from(&shared_config) + .retry_config(retry_config.clone()) + .build(); + let db_chunks_s3_config = S3ConfigBuilder::from(&shared_config) .retry_config(retry_config) - .http_client(client) + .http_client(http_client) .build(); + let s3_client = Arc::new(S3Client::from_conf(s3_config)); - let s3_client_clone = Arc::clone(&s3_client); + let db_chunks_s3_client = Arc::new(S3Client::from_conf(db_chunks_s3_config)); let shares_encryption_key_pair = match SharesEncryptionKeyPairs::from_storage(config.clone()).await { Ok(key_pair) => key_pair, @@ -1129,7 +1136,7 @@ async fn server_main(config: Config) -> eyre::Result<()> { "Initialize iris db: Loading from DB (parallelism: {})", parallelism ); - let s3_store = S3Store::new(s3_client_clone, db_chunks_bucket_name); + let s3_store = S3Store::new(db_chunks_s3_client, db_chunks_bucket_name); tokio::runtime::Handle::current().block_on(async { let mut stream = match config.enable_s3_importer { true => {