

Amazon Timestream for LiveAnalytics와 유사한 기능을 원하는 경우 Amazon Timestream for InfluxDB를 고려해 보세요. 간소화된 데이터 수집과 실시간 분석을 위한 10밀리초 미만의 쿼리 응답 시간을 제공합니다. [여기](https://docs.aws.amazon.com//timestream/latest/developerguide/timestream-for-influxdb.html)에서 자세히 알아보세요.

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# Write SDK 클라이언트
<a name="code-samples.write-client"></a>

다음 코드 조각을 사용하여 Write SDK용 Timestream 클라이언트를 생성할 수 있습니다. Write SDK는 CRUD 작업을 수행하고 Timestream에 시계열 데이터를 삽입하는 데 사용됩니다.

**참고**  
이러한 코드 조각은 [GitHub](https://github.com/awslabs/amazon-timestream-tools/blob/master/sample_apps)의 전체 샘플 애플리케이션을 기반으로 합니다. 샘플 애플리케이션을 시작하는 방법에 대한 자세한 내용은 [샘플 애플리케이션](sample-apps.md) 섹션을 참조하세요.

------
#### [  Java  ]

```
    private static AmazonTimestreamWrite buildWriteClient() {
        final ClientConfiguration clientConfiguration = new ClientConfiguration()
                .withMaxConnections(5000)
                .withRequestTimeout(20 * 1000)
                .withMaxErrorRetry(10);

        return AmazonTimestreamWriteClientBuilder
                .standard()
                .withRegion("us-east-1")
                .withClientConfiguration(clientConfiguration)
                .build();
    }
```

------
#### [  Java v2  ]

```
    private static TimestreamWriteClient buildWriteClient() {
        ApacheHttpClient.Builder httpClientBuilder =
                ApacheHttpClient.builder();
        httpClientBuilder.maxConnections(5000);

        RetryPolicy.Builder retryPolicy =
                RetryPolicy.builder();
        retryPolicy.numRetries(10);

        ClientOverrideConfiguration.Builder overrideConfig =
                ClientOverrideConfiguration.builder();
        overrideConfig.apiCallAttemptTimeout(Duration.ofSeconds(20));
        overrideConfig.retryPolicy(retryPolicy.build());

        return TimestreamWriteClient.builder()
                .httpClientBuilder(httpClientBuilder)
                .overrideConfiguration(overrideConfig.build())
                .region(Region.US_EAST_1)
                .build();
    }
```

------
#### [  Go  ]

```
tr := &http.Transport{
        ResponseHeaderTimeout: 20 * time.Second,
        // Using DefaultTransport values for other parameters: https://golang.org/pkg/net/http/#RoundTripper
        Proxy: http.ProxyFromEnvironment,
        DialContext: (&net.Dialer{
            KeepAlive: 30 * time.Second,
            DualStack: true,
            Timeout:   30 * time.Second,
        }).DialContext,
        MaxIdleConns:          100,
        IdleConnTimeout:       90 * time.Second,
        TLSHandshakeTimeout:   10 * time.Second,
        ExpectContinueTimeout: 1 * time.Second,
    }

    // So client makes HTTP/2 requests
    http2.ConfigureTransport(tr)

    sess, err := session.NewSession(&aws.Config{ Region: aws.String("us-east-1"), MaxRetries: aws.Int(10), HTTPClient: &http.Client{ Transport: tr }})
    writeSvc := timestreamwrite.New(sess)
```

------
#### [  Python  ]

```
write_client = session.client('timestream-write', config=Config(read_timeout=20, max_pool_connections = 5000, retries={'max_attempts': 10})) 
```

------
#### [  Node.js  ]

다음 코드 조각은 AWS SDK for JavaScript v3를 사용합니다. 클라이언트 설치 및 사용 방법에 대한 자세한 내용은 [Timestream Write Client - AWS SDK for JavaScript v3](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-timestream-write/index.html)를 참조하세요.

여기에 추가 명령 import가 표시됩니다. `CreateDatabaseCommand` import는 클라이언트를 생성하는 데 필요하지 않습니다.

```
import { TimestreamWriteClient, CreateDatabaseCommand } from "@aws-sdk/client-timestream-write";
const writeClient = new TimestreamWriteClient({ region: "us-east-1" });
```

다음 코드 조각은 AWS SDK for JavaScript V2 스타일을 사용합니다. 이 코드 조각은 [GitHub의 Node.js 샘플 Amazon Timestream for LiveAnalytics 애플리케이션](https://github.com/awslabs/amazon-timestream-tools/tree/mainline/sample_apps/js)에 있는 샘플 애플리케이션을 기반으로 합니다.

```
var https = require('https');
var agent = new https.Agent({
    maxSockets: 5000
});
writeClient = new AWS.TimestreamWrite({
        maxRetries: 10,
        httpOptions: {
            timeout: 20000,
            agent: agent
        }
    });
```

------
#### [  .NET  ]

```
var writeClientConfig = new AmazonTimestreamWriteConfig
{
    RegionEndpoint = RegionEndpoint.USEast1,
    Timeout = TimeSpan.FromSeconds(20),
    MaxErrorRetry = 10
};

var writeClient = new AmazonTimestreamWriteClient(writeClientConfig);
```

------

다음 구성을 권장합니다.
+ SDK 재시도 횟수를 `10`으로 설정합니다.
+ 를 사용합니다.`SDK DEFAULT_BACKOFF_STRATEGY`
+ `20`을 `RequestTimeout`초로 설정합니다.
+ 최대 연결 수를 `5000` 이상으로 설정합니다.