If your website consumes 10TB bandwidth per month, you should use CloudFlare

In our example, we are running couple of high traffic websites on AWS EC2. Monthly data transfer out is more than 30TB. Just the bandwidth charges from AWS is almost $4000.

With CloudFlare in the front and caching all our assets (Images, Css and JS), it saves us over 20TB bandwidth per month. That’s more than $2500 savings.

Not to mention that you can get tons of other great features from CloudFlare, such as Web Application Firewall.

Worth mentioning that CloudFront from AWS charges same bandwidth rate as AWS EC2, so THUMB down to CloudFront & THUMB up to CloudFlare.

CloudFlare

When you need more disk space for AWS WorkDoc on AWS WorkSpace

As of today, AWS WorkSpace (Standard) only comes with 50G user data (D drive). You can install WorkDoc client on your WorkSpace to have your data synced. However, if your WorkDoc data exceed 50G, this will fill up your WorkSpace D drive very quickly.

Here a work around:

  • Start a EC2 Windows instance with a big enough EBS, say 300G. This instance must be launched in the same VPC as your WorkSpace.
  • Join this instance to your AWS Directory, same Directory as your WorkSpace
  • Install WorkDoc client on this EC2 instance and share the WorkDoc folder to Directory/Users
  • Added this instance to the existing WorkSpace Controller security group or make sure it is accessible to WorkSpaces via Port 445
  • In each WorkSpace, just map the shared drive on this EC2 instance. \\[ec2 instance computer name]\workdoc

There you have it, good speed, plenty of spaces for your WorkDoc data.

For how to join EC2 instance to your AWS Directory, please refer to this Doc (I am in AWS Sydney region, and we can only do this manually): http://docs.aws.amazon.com/directoryservice/latest/adminguide/join_windows_instance.html

You will also be able to add Directory Management tools on this EC2 instance for management purpose.
http://docs.aws.amazon.com/directoryservice/latest/adminguide/install_ad_tools.html

Hope this helps. If you have other ideas and suggestions, please feel free to let me know.

Set up an Amazon Ubuntu server to run Zend Framework PHP Web Application

First of all, I am new to Ubuntu.

I am a Centos fan for last couple of years, but have heard of Ubuntu is a great system too, especially user friendly.

Today, one client asked me to rebuild a Amazon server for his Zend Framework PHP Web Application dut to its current stability issue. (Amazon Linux seems to have issue with MySQL which causes MySQL memory issue randomly). I figured it is a good time for me to try Ubuntu.

First, start up a new Amazon micro instance with Ubuntu LTS (LTS seems to be more stable and long term support).

Install Zend Server 6.0 Community Edition

Zend Server CE has made the installation so easy for us.

  1. SSH to server
  2. download Zend Server (DEB/RPM Installer Script)
  3. Unzip it and run the install script as root:
    ./install_zs.sh 5.3     or    ./install_zs.sh 5.4  if you need 5.4 version PHP
  4. Simply ‘y’ when prompt
  5. Done – navigate to http://<server ip> you will see “It works”
Install MySQL
  1. apt-get install mysql-server
  2. Please be noted the default MySQL sock is in here: /var/run/mysqld/mysqld.sock

Install phpMyAdmin

  1. Navigate to http://<server ip>:10081 and set up the Zend Server
  2. Deploy Application
  3. Follow this link to download phpMyAdmin package and install it via Zend Server
  4. Well, you may want to disable the auto login for security reason, change auth_type to http in this file:
    /usr/local/zend/var/apps/http/__default__/0/phpMyAdmin/3.5.6.0/config.inc.php

Set up FTP

  1. Follow this link

Set up Unison for Two Way Syncing on 2 Centos Servers

Have been played with both Async and Unison, I found Unison is more powerful, especially on 2 way syncing include deletion. Unison is easy to get start as well.

You can setup Unison by compiling the source, but it is not as easy as I thought – I ran into some libraries dependency conflicts.

Luckily, I am working on Centos servers. I can just use Yum to install it.

Enable Fedora EPEL repos for your Yum with protectbase

wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh epel-release-5-4.noarch.rpm
yum install yum-protectbase.noarch -y
yum repolist

Install Unison via Yum

yum install unison -y

Enable SSH Access without Password

On local host, do these:

ssh-keygen
#followed by three ENTERs
ssh-copy-id -i .ssh/id_rsa.pub root@remotehost
ssh root@remotehost

Sample Unison Command

/usr/bin/unison /web/live1 ssh://remoteserver/web/live2 \
-ignore "Path WEB-INF/config" \
-ignore "Path WEB-INF/derby" \
-ignore "Path WEB-INF/test/test.xml"

Reference

HowTo Use unison File Synchronizer
3 Steps to Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id

My Favorite Centos Installation

I have installed many Linux systems, from Fedora, and now fall in love with Centos.

The best thing is you can install a lot of popular software just via YUM.

Here I just want to share that RPMForge is almost a must Repos you should add into your YUM.

It gives you a lot of useful packages that doesn’t come with default, such as phpmyadmin.

For how to install RPMForge, just follow this page.

On the other hand, if you would need latest version on PHP53, MYSQL etc, you should consider IUS Community.

It is proudly supported by RackSpace and comes with a lot of latest version packages.

For how to get started with IUS, just follow their Client User Guide.

Another tips to install latest version of PHP from IUS is to install php53u instead of php.

Server Time Issue

In Australia, we have day light saving in summer, which confuses a lot of my servers’ timing. To make it easier, just set up the NTP service and configure the right timezone.

Timezone:

  1. make a backup: mv /etc/localtime /etc/localtime.bak
  2. cp /usr/share/zoneinfo/Australia/Sydney /etc/localtime

Set up NTP:

  1. yum install ntp
  2. chkconfig ntpd on
  3. ntpdate 0.au.pool.ntp.org
  4. /etc/init.d/ntpd start

Please note that if you are doing the time setting on virtual system, like XenServer, you should change time on host because normally the guest system’s default time setting is locked with host.

http://www.topologi.com/

Amazon EC2 Instance Boots from EBS (Volume)

With this new feature enabled in Amazon, what are the most valuable benefits can I get?

  1. All the system data are stored in Amazon EBS now and don’t need to worry data will be lost after system crashed or stopped.
  2. With Create-Image function, for Amazon EBS backed instance, we can now create an AMI much quicker and easier (one step). It will create a snapshot of current running instance’s EBS and then register that snapshot as an AMI automatically. To delete that snapshot, you will need to de-register that AMI first.
  3. Instance can be stopped without losing any data and can be restarted later on when you need it. (save $$ too).

What to be more careful?

  1. Data will be LOST if instance is TERMINATED! The whole EBS (Volume) will be deleted if you terminate the instance.

What you can do to be safer? (refer to: http://alestic.com/2010/01/ec2-instance-locking)

  1. Change the way of shutting down from inside of instance (Default to Stop, so no need to change manually)
  2. Change to Not deleting the EBS after termination.
  3. Change to instance attribute to disable API terminate command
  4. Having script to backup your data to S3 regularly
  5. Having script to take snapshot regularly

SSH to Amazon Instance with login and password

Amazon EC2 Instance provides key pair for SSH accessing, which is better than login and password authentication. However, if you still want to SSH with login and password – You can do that.

  1. Login to instance with keypair
    ssh -i xxx.pem ......
  2. Change /etc/ssh/sshd_config file
    PasswordAuthentication yes
  3. (Optional) Enable root access
    PermitRootLogin yes
  4. Restart SSHD
    /etc/init.d/sshd restart
  5. (Optional) Try restart your instance if still doesn’t work