Alexandre Martini
Alexandre Martini

Reputation: 429

Low upload speed to ec2 instance running on another region

I have a few EC2 instances (t2.micro) behind a load balancer on the us-east-1 region (N. Virginia) and my users are accessing the application from South America. This is my current setup mainly because costs are about 50% of what I would pay for the same services here in Brasil.

My uploads all go to S3 buckets, also in the us-east-1 region.

When a user requests a file from my app, I check for permission because the buckets are not public (hence why I need all data to go through EC2 instances) and I stream the file from S3 to the user. The download speeds for the users are fine and usually reach the maximum the user connection can handle, since I have transfer acceleration enabled for my buckets.

My issue is uploading files through the EC2 instances. The upload speeds suffer a lot and, in this case, having transfer acceleration enabled on S3 does not help in any way. It feels like I'm being throttled by AWS, because the maximum speed is capped around 1Mb/s.

I could maybe transfer files directly from the user to S3, then update my databases, but that would introduce a few issues to my main workflow.

So, I have two questions:

1) Is it normal for upload speeds to EC2 instances to suffer like that?

2) What options do I have, other than moving all services to South America, closer to my users?

Thanks in advance!

Upvotes: 0

Views: 726

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 270224

There is no need to 'stream' data from Amazon S3 via an Amazon EC2 instance. Nor is there any need to 'upload' via Amazon EC2.

Instead, you should be using Pre-signed URLs. These are URLs that grant time-limited access to upload to, or download from, Amazon S3.

The way it works is:

  • Your application verifies whether the user is permitted to upload/download a file
  • The application then generates a Pre-signed URL with an expiry time (eg 5 minutes)
  • The application supplied the URL to the client (eg a mobile app) or includes it in an HTML page (as a link for downloads or as a form for uploads)
  • The user then uploads/downloads the file directly to Amazon S3

The result is a highly scalable system because your EC2 system does not need to be involved in the actual data transfer.

See:

Upvotes: 2

Related Questions