Scott Lindner
Scott Lindner

Reputation: 584

localstack AWS S3 connection refused with no errors

I'm running localstack 3.0.2 to test a Spring Boot app using aws-java-sdk as an integration test using TestContainers. I need to simulate querying a very large number of S3 objects so I generate a ton of objects (as basic text files) using a structured path that my code needs to navigate and be performant. When I hit around 1 million objects generated my Junit test will throw:

com.amazonaws.SdkClientException: Unable to execute HTTP request: Connect to 127.0.0.1:32822 [/127.0.0.1] failed: Connection refused

at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1219)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1165)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:814)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:781)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:755)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:715)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:697)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:561)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:541)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:5520)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:5467)
at com.amazonaws.services.s3.AmazonS3Client.access$300(AmazonS3Client.java:422)
at com.amazonaws.services.s3.AmazonS3Client$PutObjectStrategy.invokeServiceCall(AmazonS3Client.java:6601)
at com.amazonaws.services.s3.AmazonS3Client.uploadObject(AmazonS3Client.java:1891)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1851)

The docker logs do not show any errors from the container.

There is no consistent specific number of objects where it bombs like this. I can run the same test up to about 950,000 objects fairly consistently but I'd like to get to 2-15 million for different versions of the testing I want to perform. I know this may not be suitable for a TestContainer but before resigning myself to finding a new way to test what I'm looking to test, I'd like to understand the cause of this issue and what my remedies might be.

Upvotes: 0

Views: 1174

Answers (1)

bentsku
bentsku

Reputation: 181

LocalStack stores S3 Objects in memory in they don't go over a certain size threshold (512kb), after which they will be stored on disk in a temporary file. It looks like your container might run out of memory and get killed, which would lead into the Connection refused error.

Maybe you could try to raise your container's available memory and see if you can upload more data?

Upvotes: 0

Related Questions