The images uploaded on Heroku will disappear over time, so

According to my research, it seems that I can leave it using Amazon S3,

Which is better, Japan or America for the Amazon S3 region?

The region of heroku's app is in the US, but would it make the response faster if combined with the region of heroku?

I would appreciate it if you could tell me.

[Rails] How to enable posting images on Heroku (ActiveStorage + Amazon S3

  • Answer # 1

    First of all, as a premise, I personally investigated and summarized. (It is not a measurement, so it is an individual impression.)

    Conclusion: Personally, I think it's good for the Tokyo region.

    Since the data movement of direct upload is as follows, it takes quite a while.

    Client ⇒ Rails ⇒ S3 ⇒ Rails ⇒ Client ⇒ Image * ⇒ S3
    For the first time at *, the image will be directly uploaded from the client to S3.

    Since it is not measured, it cannot be determined, but...
    I think that it will be the following form when rearranging including the distance from Japan to the United States.

    S3 Region Download (display) Upload Japan ⇔ USA at the time of upload
    America should be late 3 times
    Japan should be early and late 4 times
    If you add a CDN (CloudFront, etc.) here, it should look like the following.

    S3 Region Download (display) Upload Japan ⇔ USA at the time of upload
    America + CDN Early, late, should be early 3 times
    Japan+CDN Early, slow 4 times
    *If the upload is supposed to be early or late, we judge that it will lead to a significant delay as the number of times the data travels between Japan and the United States is large.
    However, the heavier the data you upload, the faster the S3 in the Japan region will be.

    If you can manage it, AWS+S3+CDN (CloudFront) in Japan region will be much faster.
    If you use Heroku, I think it would be preferable to implement the Rails standard function as much as possible (by using remote: true or Turbolinks) to reduce the delay.

    Once again...I haven't measured it, so it's my personal impression.