Skip to content

DRAFT PR for using RateLimiter with Streaming Pipeline#37879

Draft
tarun-google wants to merge 2 commits intoapache:masterfrom
tarun-google:ratelimiter_streaming_test
Draft

DRAFT PR for using RateLimiter with Streaming Pipeline#37879
tarun-google wants to merge 2 commits intoapache:masterfrom
tarun-google:ratelimiter_streaming_test

Conversation

@tarun-google
Copy link
Contributor

@tarun-google tarun-google commented Mar 17, 2026

Setup:
Run ./deploy.sh in beam/examples/terraform/envoy-ratelimiter This gives the ratelimiter IP

Sample command for running pipeline:
./gradlew :examples:java:exec -PrunnerDependency=:runners:google-cloud-dataflow-java -DmainClass=org.apache.beam.examples.RateLimitedPubsubReader -Dexec.args="--runner=DataflowRunner --project=apache-beam-testing --region=us-central1 --tempLocation=gs://taxi_rides_test/temp --stagingLocation=gs://taxi_rides_test/staging --jobName=tarun-test-ratelimiter-pubsub --sdkContainerImage=gcr.io/apache-beam-testing/beam-sdk/beam_java11_sdk:latest --subnetwork=regions/us-central1/subnetworks/private-subnet --rateLimiterAddress=<IP>:8081 --rateLimiterDomain=mongo_cps --topic=projects/pubsub-public-data/topics/taxirides-realtime --streaming --experiments=use_runner_v2"

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a practical example of how to implement external rate limiting within an Apache Beam streaming pipeline. By integrating with an Envoy Rate Limit Service, the new example showcases a robust mechanism for controlling the processing rate of data from a Pub/Sub topic, which is crucial for managing downstream service load or adhering to API quotas. The accompanying Terraform configuration updates facilitate easier deployment and testing of this rate-limiting setup.

Highlights

  • New Streaming Rate Limiting Example: Introduced RateLimitedPubsubReader.java, a new Java example demonstrating how to integrate an Envoy Rate Limit Service with an Apache Beam streaming pipeline reading from Pub/Sub.
  • Terraform Configuration Updates: Updated terraform.tfvars to specify concrete GCP project, region, VPC, and subnet details for deploying the Envoy Rate Limiter, and increased the default requests_per_unit from 1 to 10.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • examples/java/src/main/java/org/apache/beam/examples/RateLimitedPubsubReader.java
    • Added a new Java example demonstrating a Pub/Sub reader with Envoy-based rate limiting.
    • Implemented RateLimitAndLogFn DoFn to acquire rate limit tokens before processing elements.
    • Defined Options interface for configuring rate limiter address, domain, and Pub/Sub topic.
  • examples/terraform/envoy-ratelimiter/terraform.tfvars
    • Updated project_id from "PROJECT_ID" to "apache-beam-testing".
    • Updated region from "REGION" to "us-central1".
    • Updated vpc_name from "VPC_NAME" to "tarun-private-vpc".
    • Updated subnet_name from "SUBNET_NAME" to "private-subnet".
    • Increased requests_per_unit for the users descriptor from 1 to 10.
Activity
  • This is a DRAFT PR, indicating ongoing work.
  • Setup instructions are provided for deploying the Envoy Rate Limiter using Terraform.
  • A sample command is included for running the streaming pipeline with specific DataflowRunner arguments, including the rate limiter address and domain.
  • GitHub Actions test statuses for Python, Java, and Go are linked, showing the status on the master branch.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant