Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have started doing some work for a mate running Apache2 and PHP on Ubuntu and the CPU is topping out. What I am really after is advice around whether using a Micro instance is a good idea for a production/public facing Web Site. My gut feel is no and that using a Standard or High instance would be a better idea but as I have only started to play around in AWS I just wanted to see what other people have done.

Now he does run a number of these Load Balanced but he is having to kill instances off, I am going to look at setting up Cloudwatch to do this for him automatically until I can get a better handle on what is going on with his app under the hood.

I know that is a pretty vague questions and I have not supplied a lot of details around the setup but that is I am still getting up to speed on his site.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Short answer: Don't discount the t1.micro - it is a capable instance and can definitely run a PHP site - but if you can't make it work with one t1.micro, then get a larger instance (as opposed to multiple t1.micros).

Long Answer: The t1.micro instance is quite capable of generating dynamic content - and can run fairly smoothly serving multiple small sites. For a well optimized setup (let's say Wordpress with caching), I would say that the t1.micro should handle at least 50k hits/month, if not more. One of the key ideas though, is that things are well optimized - a default Apache install will bring down a t1.micro fairly fast - since each request spawns a new process - with all the associated overhead.

Additionally, the t1.micro has no swap space by default (it may be helpful to setup a 1GB EBS volume to use as swap space - more as a safety measure than to actually use it. If you find it being used a lot, then something needs to change.

If you are going to run multiple instances, I would advise against going for multiple t1.micro instances. The performance per dollar is far better on the larger instances (memory, i/o, and CPU). One of the other points about the t1.micro is that while you can 'burst' additional CPU, cycles can also be 'stolen'. Definitely go with a 32-bit instance if you are going the t1.micro route - the added overhead of 64-bit registers will simply lead to the instance running out of memory easier, without any tangible performance gain.

If possible, I would recommend use php-fpm instead of mod_php - while slightly slower, it is able to withstand a far higher volume of traffic with less load on the instance. Additionally, if possible, offload the serving of static content. For the latter you could use a CDN such as Cloudfront (or even using S3) - the idea being that these requests don't consume the bandwidth, disk i/o, or processing power (or memory) of the instance. Alternatively, you can use a lightweight front-end server (e.g. nginx) to handle static content and then proxy dynamic requests back to apache (if you can't switch entirely to using that front-end server) - this does add complexity to the setup - but especially if your pages are cached (i.e. static versions generated whenever the page changes) the performance gain can be substantial. It may also be advisable to cache dynamic content with a front-end server (the duration will depend on the site's popularity) - to avoid unnecessary processing of dynamic requests.

One final suggestion - which may not be possible - consider using Amazon's Linux as your operating system instead of Ubuntu. I have found it to be extremely lightweight and efficient on a t1.micro - it comes with the minimum of installed packages and has a very small footprint.

Running a dyanmic website on a t1.micro is certainly possible to do - I have run several small sites (Wordpress/Drupal/Joomla) on a single t1.micro - both using nginx/apache/php-fcgi and varnish/nginx/php-fpm - including a mail server (postfix), imap (dovecot), database (mysql), and ftp server (pure-ftp/vsftp) - with decent performance (Wordpress sites load in a 1-2s), low load averages (typically under 0.1, on a request every 15s), and about 150-200MB of used memory). It wouldn't be my choice for performance, but it is the least costly solution for a site that simply needs to reliably be online, without expecting much traffic.

I would say that the t1.micro makes a very good platform to work on your optimization skills - it lets you see how much you can get out of the bare minimum, and what optimizations will be more costly than they are worth. If however, your site is simply too large for a single t1.micro, use a larger instance not additional t1.micro instances (unless your specific purpose is fail over - but chances are at that stage you will be using larger instances anyway.). Do not load balance t1.micro instances - there is very little to gain from that approach - a larger instance will serve you better. However, you definitely want to find out why those instances are dying - I would wager it is a memory issue, over a CPU one. You definitely want to try to launch a copy of your site, and run ab (or seige, etc) on it and see what the server can stand - and whether or not it the design of the application (which you probably can't change) or the setup of the server.

(Unless you are using spot instances, you can upgrade the instance type fairly easily - just stop (not terminate), and use ec2-modify-instance-attribute to change the type, before restarting).

share|improve this answer
    
Thank you for this information, he is already using Cloudfront for some of his images, I have recommend that he sources all images for his site from Cloudfront. I am also recommend that he sets up a new S3/Cloudfront instance for his static content(HTML,CSS,JS) to reduce the amount of calls he gets to his apache servers. On the Linux front I was going to look at using Turnkey Linux as I have a friend of mine that used in AWS for his LAMP site but I will have a look at the Amazon one as well. –  enterzero Nov 9 '11 at 3:13

t1.micro instances are fine for public facing web sites as long as you don't get more traffic than the t1.micro instance can handle. (That previous sentence did not say much.)

It sounds like you are getting more traffic than a t1.micro can handle with the way the application is currently written so you should upgrade to a larger instance type.

I don't think load balancing t1.micro makes sense. The minimum for load balancing in my opinion would be m1.small and even then you're likely better off just running a c1.medium as it's cheaper than the number of m1.smalls needed to get equivalent CPUs.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.