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

[aws-cpp-sdk-s3-crt]: Configure TCP connection-monitoring options #2101

Closed
wants to merge 4 commits into from

Conversation

grrtrr
Copy link
Contributor

@grrtrr grrtrr commented Sep 21, 2022

The main SDK enables TCP keep-alive and connection-speed monitoring by default, these options are also important for the S3CrtClient (e.g. awslabs/aws-c-s3#210).

Hence, based on awslabs/aws-c-s3#204, expose the following ClientConfiguration options to CRT:

  • connect_timeout_ms: S3 socket connection timeout;
  • enableTcpKeepAlive: enable TCP keep-alive probes;
  • tcpKeepAliveIntervalMs: TCP keep-alive wait/probe interval;
  • lowSpeedLimit: aws-c-http TCP connection speed monitoring;
  • requestTimeoutMs: to provide upper bound on the monitoring interval for aws-c-http TCP connection speed monitoring.

Issue #, if available: Resolves #2107.

Description of changes:

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Based on awslabs/aws-c-s3#204, this exposes the following
`ClientConfiguration` options to CRT:
- `connect_timeout_ms`: S3 socket connection timeout;
- `enableTcpKeepAlive`: enable TCP keep-alive probes;
- `tcpKeepAliveIntervalMs`: TCP keep-alive wait/probe interval;
- `lowSpeedLimit`: `aws-c-http` TCP connection speed monitoring;
- `requestTimeoutMs`: to provide upper bound on the monitoring interval for `aws-c-http` TCP connection speed monitoring.
aws_s3_tcp_keep_alive_options tcp_keep_alive_options;
if (config.enableTcpKeepAlive)
{
const uint16_t keep_intvl = std::max<uint16_t>(15, config.tcpKeepAliveIntervalMs/1000);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmklix - I double-checked the aws-c-io/include/aws/io/socket.h, keep_alive_interval_sec takes an uint16_t.
Can you please help with details regarding failing tests - is is the std:max statement?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning was warning C4244: '=': conversion from 'const int' to 'uint16_t', possible loss of data
and to fix that I changed it to this

    uint16_t configKeepAliveS = static_cast<uint16_t>(std::min(static_cast<unsigned long>(std::numeric_limits<uint16_t>::max()), config.tcpKeepAliveIntervalMs / 1000ul));
    static const uint16_t MAX_CRT_KEEP_ALIVE = 15; // seconds
    const uint16_t keep_intvl = std::max(MAX_CRT_KEEP_ALIVE, configKeepAliveS);

const uint32_t monitor_intvl = std::max<uint32_t>(3, config.requestTimeoutMs/1000);

AWS_ZERO_STRUCT(tcp_monitoring_options);
tcp_monitoring_options.minimum_throughput_bytes_per_second = config.lowSpeedLimit;
Copy link
Contributor Author

@grrtrr grrtrr Oct 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will use a static_cast here, lowSpeedLimit is unsigned long, while the LHS is uint64_t.

@jmklix
Copy link
Member

jmklix commented Oct 28, 2022

Changes have been merged here. Closing this PR

@jmklix jmklix closed this Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[aws-cpp-sdk-s3-crt]: need default settings for TCP connection-monitoring options
3 participants