AWS devicefarm documentation change
Summary
Removed code examples for rate limiting and replaced with support contact instructions.
Security assessment
Simplifies rate limit troubleshooting guidance but does not address a security vulnerability or add security documentation. Rate limiting adjustments are operational, not security fixes.
Diff
diff --git a/devicefarm/latest/testgrid/troubleshooting.md b/devicefarm/latest/testgrid/troubleshooting.md index 2b791efee..fc8fc6455 100644 --- a//devicefarm/latest/testgrid/troubleshooting.md +++ b//devicefarm/latest/testgrid/troubleshooting.md @@ -50,75 +50 @@ If you are opening more than 5 sessions at a time, we recommend adding a random -To mitigate the rate limit of 150 actions per second across WebDriver sessions, you can use a custom `CommandExecuter` that automatically limits the rate of outgoing requests. The following example demonstrates how to accomplish this: - -Java - - - - import org.openqa.selenium.remote.HttpCommandExecutor; - import org.openqa.selenium.remote.Response; - import org.openqa.selenium.remote.Command; - import java.io.IOException; - import java.time.Instant; - import java.util.concurrent.TimeUnit; - - class RateLimitExecutor extends HttpCommandExecutor { - - public static final int CONCURRENT_SESSIONS = 100; - public static final int ACTIONS_RATE_LIMIT_PER_SECOND = 150; - - public static final double SECONDS_PER_ACTION = ((double) CONCURRENT_SESSIONS) - / ((double) ACTIONS_RATE_LIMIT_PER_SECOND); - private long lastExecutionTime; - - public RateLimitExecutor(URL addressOfRemoteServer) { - super(addressOfRemoteServer); - lastExecutionTime = 0; - } - - public Response execute(Command command) throws IOException { - long currentTime = Instant.now().toEpochMilli(); - double elapsedTime = TimeUnit.MILLISECONDS.toSeconds(currentTime - lastExecutionTime); - if (elapsedTime < SECONDS_PER_ACTION) { - try { - Thread.sleep(TimeUnit.SECONDS.toMillis((long)(SECONDS_PER_ACTION - elapsedTime))); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - lastExecutionTime = Instant.now().toEpochMilli(); - return super.execute(command); - } - } - - -When calling the constructor for the remote `WebDriver`, use an instance of this new class as the `command_executor` parameter: - - - RemoteWebDriver driver = new RemoteWebDriver(new RateLimitExecutor(testGridUrl), new FirefoxOptions()); - -Python - - - - CONCURRENT_SESSIONS = 100 - ACTIONS_RATE_LIMIT_PER_SECOND = 150 - - class RateLimitExecutor(RemoteConnection): - - def __init__(self, *args): - super().__init__(*args) - self.last_execution_time = None - self.seconds_per_action = CONCURRENT_SESSIONS / ACTIONS_RATE_LIMIT_PER_SECOND - - def execute(self, *args): - if self.last_execution_time: - current_time = time.time() - elapsed_time = current_time - self.last_execution_time - if elapsed_time < self.seconds_per_action: - time.sleep(self.seconds_per_action - elapsed_time) - self.last_execution_time = time.time() - return super().execute(*args) - -When calling the constructor for the remote `WebDriver`, use an instance of this new class as the `command_executor` parameter: - - - driver = webdriver.Remote(command_executor=CustomCommandExecutor(test_grid_url), desired_capabilities=DesiredCapabilities.CHROME) +If you are frequently experiencing a Rate Limit Exceeded error from Selenium actions other than Create Session calls, then please contact us via a support ticket for assistance. The current default limit is 1200 actions per second.