Amazon Web Service 微实例 - 服务器崩溃 [英] Amazon Web Service Micro Instance - Server Crash

查看:29
本文介绍了Amazon Web Service 微实例 - 服务器崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 AWS 微实例作为允许用户上传照片的网站的 Web 服务器.两个问题:

I am currently using an AWS micro instance as a web server for a website that allows users to upload photos. Two questions:

1) 在查看我的 CloudWatch 指标时,我最近注意到 CPU 峰值,该网站目前接收的流量非常少,但在这些峰值期间变得完全无法使用.这些尖峰可能会持续几个小时,并且重置服务器并不能消除尖峰.

1) When looking at my CloudWatch metrics, I have recently noticed CPU spikes, the website receives very little traffic at the moment, but becomes utterly unusable during these spikes. These spikes can last several hours and resetting the server does not eliminate the spikes.

2) 虽然看似无关,但每当我在 Twitter 上发布我网站的链接时,服务器就会崩溃(即,建立数据库连接时出错).重启 Apache 和 MySQL 后,网站恢复正常功能.

2) Although seemingly unrelated, whenever I post a link of my website on Twitter, the server crashes (i.e.,Error Establishing a Database Connection). Once restarting Apache and MySQL, the website returns to normal functionality.

我唯一的猜测是这个问题在某种程度上是微实例缺陷的结果.不幸的是,当我升级到小型实例时,由于微型实例可以有两个 EC2 计算单元,因此站点实际上变慢了.

My only guess would be that the issue is somehow the result of deficiencies with the micro instance. Unfortunately, when I upgraded to the small instance, the site was actually slower due to fact that the micro instances can have two EC2 compute units.

有什么建议吗?

推荐答案

如果你想留在 AWS(微实例)的免费层,你应该尽可能地从你的 EC2 实例上卸载.

If you want to stay in the free tier of AWS (micro instance), you should off load as much as possible away from your EC2 instance.

我建议您将图像直接上传到 S3,而不是通过您的网络服务器(请参阅此处的一些示例:http://aws.amazon.com/articles/1434).

I would suggest you to upload the images directly to S3 instead of going through your web server (see some example for it here: http://aws.amazon.com/articles/1434).

S3 也可用于为您的大多数网页(图像、js、css...)提供服务,而不是为您的弱网络服务器提供服务.您还可以将 S3 中的这些文件作为源添加到 Amazon CloudFront (CDN) 分发,以提高您的应用程序性能.

S3 can also be used to serve most of your web pages (images, js, css...), instead of your weak web server. You can also add these files in S3 as origin to Amazon CloudFront (CDN) distribution to improve your application performance.

另一个可以帮助您减轻工作负担的服务是 SQS(简单队列服务).您可以将一些请求(例如上传完成)作为消息发送到 SQS,而不是处理来自用户的在线请求,并让您的读者按照自己的节奏处理这些消息.这是处理由多个用户同时使用您的服务造成的瞬时负载的好方法.

Another service that can help you in off loading the work is SQS (Simple Queue Service). Instead of working with online requests from users, you can send some requests (upload done, for example) as a message to SQS and have your reader process these messages on its own pace. This is good way to handel momentary load cause by several users working simultaneously with your service.

另一个服务是 DynamoDB(托管 NoSQL DB 服务).您可以将大部分当前 MySQL 数据和查询放在 dynamoDB 上.Amazon DynamoDB 还提供您可以享受的免费套餐.

Another service is DynamoDB (managed NoSQL DB service). You can put on dynamoDB most of your current MySQL data and queries. Amazon DynamoDB also has a free tier that you can enjoy.

结合上述方法,您可以让您的微实例处理剩余的少数动态页面,直到您需要扩展您的服务并取得越来越大的成功.

With the combination of the above, you can have your micro instance handling the few remaining dynamic pages until you need to scale your service with your growing success.

这篇关于Amazon Web Service 微实例 - 服务器崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆