Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Bandwidth... • Amazon EC2’s bandwidth
is about 250 - 1000Mbps. • You’re only billed for what you use. Making it cheap, but different than what you’re used to. • Amazon is located closer to peering points. There are East Coast and Europe DC’s.

Pricing It’s all usage based,
with discounts. Bandwidth CPU Usage $0.10 per GB (incoming) $0.03 per hour Small $0.17 per GB $0.12 per hour Large (ﬁrst 10 TB outgoing) Billed the entire time the Free between S3 and EC2 machine is online.

Limitations of EC2 • When
an instance is shutdown all of the disks are wiped. Cache is cleared. • There are no guarantees that a particular machine will remain up.

So what’s it good for?
1. Parallel processing tasks without building a server farm. 2. Building cache servers to serve your content on quickly and cheaper than you can. 3. Bragging about how your infrastructure is in “the cloud”.

DNS EC2 will go down,
when you least expect it. You don’t want the users to get errors and you don’t want to be sending requests to a down server for very long. Use dynamic DNS updates and keep very short TTL times for the records. Or EC2’s static addresses. Monitoring and DNS code needs to be reliable, use more then once separate network.

DNS Redirection If you host
more then one website, generally you don’t want to setup instances for every domain. Setup one caching instance, and then create CNAME records for all of your other domains. For instance to cache requests at www.prolitegear.com I can use cache.prolitegear.com which is a CNAME for c.cache.infogears.com.

Logging It’s good to judge
cache hits to make sure your cache is working. LogFormat "%{Host}i %h %l %u %t "%r" %>s %b "%{Referer}i" "% {User-Agent}i" %{Age}" proxy The Age header contains the age of the cached result in seconds, if not found it logs “-”. Logs should be sent back to reliable storage every so often.

Proxy ProxyRequests Off <Proxy *>
Order deny,allow Allow from all </Proxy> • Make sure you don’t make an open proxy. • Our proxy requests will only be the result of rewrite rules.

Cache CacheEnable disk / CacheRoot
/mnt/cache CacheDirLevels 3 CacheDirLength 1 CacheIgnoreCacheControl Off CacheDefaultExpire 7200 CacheMaxExpire 604800 CacheMaxFileSize 2000000000 Make sure that the cache root exists before Apache starts, otherwise it won’t start. /mnt is a good place. Make sure you have the correct permissions so Apache can write to the directory. Change the directory levels and limits to suit your needs.

Monitoring Monitoring is important to
make sure that EC2 can reach your servers, and your EC2 server is still running. I use Perl for this since it has everything I need: a way to update DNS and a way to send web requests. SNMP Trafﬁc Monitoring is also essential.

Monitoring Do this forever Try
example proxy request using Amazon Did it succeed? No Yes Has Amazon address already been set? Set address to No failback server Yes Set Amazon address Sleep