InstanceStore,EBS或S3 - 加载PHP类EC2的最佳方式吗? [英] Best way to load php classes in EC2 - InstanceStore, EBS or S3?

查看:153
本文介绍了InstanceStore,EBS或S3 - 加载PHP类EC2的最佳方式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是加载PHP类中的EC2在以下情况下的最佳方式(#分别是用于说明的目的)? - >运行Apache和APC 100 EC2实例 - >按要求装100 PHP类(通过__autoload) - >类之间每天100 code的变化(许多类包含被通过cron定期更新自动生成的code)

What is the best way to load PHP classes in EC2 in the following scenario (#s are for illustrative purposes)? -> 100 EC2 instances running apache and APC -> 100 php classes loaded per request (via __autoload) -> 100 code changes per day between the classes (many of the classes contain auto-generated code that are periodically updated via cron).

这是我收集,有3种方式加载在EC2上的PHP类文件:

From what I gather, there are 3 ways to load the php class files in EC2:

A. InstanceStore - The local (virtual) hard drive of an EC2 instance
-> Code must be pushed separately to each instance.
-> Fastest loading since no need to go over the network

B. EBS - A volume mounted to a particular instance
-> Code must be pushed separately to each instance.
-> Slower loading since go over the network

C. S3 - A S3 bucket can be 'mounted' to 1 or more EC2 instances
-> Code only needs to be pushed once
-> Slowest loading since go over the network

即使在apache的情况下启用APC,我不能够禁用FSTAT在APC由于被不确定如何处理缓存的类的无效所有100 Apache的情况下100+次,每天(当code值)。其结果,如果每个类别负载会产生一个呼叫,即使该类被缓存由APC文件系统(做FSTAT呼叫),也不会出现有巨大延迟,如果有通过网络做的fstat 100往返或读取的文件在每次请求?

Even with APC enabled on the apache instances, I am not able to disable fstat in APC due to being unsure of how to handle the invalidation of the cached classes on all 100 apache instances 100+ times a day (when code changes). As a result, if each class load will generate a call to the filesystem even if the class was cached by apc (to do the fstat call), wouldn't there be huge latency if there were 100 round trips over the network to do fstat or read the file on every request?

什么是最好的选择(或者一个新的方式,这里没有列出)加载在场景中的类文件说明?

What is the best option (or maybe a new way that is not list here) to load class files in the scenario described?

推荐答案

<一个href="http://stackoverflow.com/questions/3630506/benefits-of-ebs-vs-instance-store-and-vice-versa/3630707#3630707">Always使用EBS支持的实例。重复:始终使用EBS支持的实例

Always use an EBS backed instance. Repeat: Always use an EBS backed instance.

在code的变化需要应用,旋转起来从当前的快照备份实例的新EBS。不要把它添加到您的负载均衡呢。

When code changes need to be applied, spin up a new EBS backed instance from a snapshot of the current one. Do not add it to your load balancer yet.

应用code的变化。

创建一个新的EBS快照。这是你的金标准快照本轮code的变化。

Create a new EBS snapshot. This is your gold standard snapshot for the current round of code changes.

启动新的EBS支持的情况下,根据需要在新的黄金标准快照。

Launch new EBS-backed instances as needed from the new gold standard snapshot.

运行击中你的网站上的新实例(S),这还没有考虑真实流量的脚本,地暖起来(获取加载到APC的PHP类)。

Run a script that hits your website on the new instance(s), which are not yet taking real traffic, to warm them up (get the PHP classes loaded into APC).

切换负载平衡器,使新的实例正在采取一切活的流量。

Switch your load balancer so that the new instances are taking all live traffic.

终止旧的实例。

所有这一切都可以而且应该与更新脚本自动化。请务必包括错误检查你前进的道路上的脚本(比如,我偶尔会无法启动一个新的实例,由于在可用区资源约束)。

All of this can and should be automated with an update script. Be sure and include error checking in your script along the way (for example, I have occasionally been unable to fire up a new instance due to resource constraints in the availability zone).

创建,并根据需要销毁的新实例的能力是有关云美妙的事情之一。

The ability to create and destroy new instances as needed is one of the wonderful things about the cloud.

这篇关于InstanceStore,EBS或S3 - 加载PHP类EC2的最佳方式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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