本文介绍了AWS-在考虑性能的情况下提供静态文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个我的项目,我希望每月大约有500-750k的唯一ping.

I'm working on a project of mine and I'm expecting about ~500-750k unique pings per month.

我很好奇,是否有比下面的想法更好的方式(就延迟而言)来托管静态网站.

I'm curious to hear if there's any better way (in terms of latency) to host a static website than my idea below.

想法:

  • 在启用了gzip的情况下运行NGINX的EC2实例
  • 用于CDN的CloudFront

我要托管的内容:

  • HTML(共3页)
  • CSS
  • SVG/PNG图像

此外,如果我的上述想法还可以,那么您将选择哪个EC2实例?我以为微型实例就可以了,我不明白为什么我需要额外的RAM/CPU.

Also, if my idea above is OK, which EC2 instance would you go for? I'm thinking a micro instance would do just fine, I don't see why I would need the extra RAM/CPU.

还是像CloudFront的S3这样简单的东西呢?

Or how about something simpler like S3 w/ CloudFront?

推荐答案

AWS S3 :

  1. 创建S3存储桶(mybucket)并在其上启用网站静态属性.

  1. Create S3 Bucket (mybucket) and enable website static properties on it.

创建具有该存储桶读/写权限的IAM用户.

Create IAM user with a permission of read/write on that bucket.

    "Version": "2012-10-17",
    "Statement": [
      {
        "Action": "s3:ListAllMyBuckets",
        "Effect": "Allow",
        "Resource": "arn:aws:s3:::*"
      },
      {
        "Sid": "Stmt1487841624000",
        "Effect": "Allow",
        "Action": ["s3:*"],
        "Resource": ["arn:aws:s3:::mybucket/*", "arn:aws:s3:::mybucket"]
      }
    ]
    }

(保留秘密密钥和访问密钥以及创建存储桶的区域)

(Keep secret key and access key and the region where you create the bucket)

在笔记本电脑中配置您的秘密密钥和访问密钥

Configure your secret key and access key in your laptop

  aws configure;

  • 然后上传您的静态网站:

  • Then upload your static website :

      aws s3 sync /path/to/local/dir s3://mybucket; 
    

  • 恭喜!您的网站托管: http://[BUCKETNAME] .s3-website.[ REGIONMAME] .amazonaws.com

    Congrats! your website is hosted : http://[BUCKETNAME].s3-website.[REGIONMAME].amazonaws.com

    如果您想:

    • 将网站映射到另一个域

    • map the website to another domain

    或/和使用SSL

    或/并与WAF集成.

    或/等等...

    还使用 AWS CloudFront .

    这篇关于AWS-在考虑性能的情况下提供静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    10-12 17:36