Milos Zikic - Personal site, sharing thoughts about startups, products and engineering

Using low-power servers to host php sites (e.g. Amazon Micro instance)

First answer should be DON'T or better said understand your needs and then decide.

It really falls down to what are the expectations and if the site you are planning to run is not having 10s of thousands of visits daily you can probably utilize some of the low power servers available out there. Amazon is great for starting it up since it provide you with one year free tier option. You will have to leave the credit card info with them though since they might be some other charges in the future usage and Amazon would like to be able to charge for it.

So important things:

  • Do not expect to much
  • If you can separate web server and db server (maybe 2 micro instances)
  • If you can use nginx instead of apache web server. Nginx comes with much lower memory footprint.
  • Go with some lighter site frameworks (e.g. your own or wordpress). Drupal or Typo3 will take up a lot more resources.
Here are some recommended values for apache (httpd.conf)
Timeout 30 #Set this to some reasonable amount - who waits more then 30 secs for site to load?

StartServers 3
MinSpareServers 2
MaxSpareServers 1

MaxClients 6
MaxRequestsPerChild 500

We are not allowing many concurrent requests here but it will limit the apache memory consumption so other processes may run. If you do not have intensive operations that require a lot of memory for php processes you should put some small amount for php memory_limit in php.ini

memory_limit = 64M #maximum amount of memory one php process can consume

And if you run MySQL or similar on this server monitor it for usage. If your MySQL process gets killed (Amazon has a watchdog that will do this automatically if there is no more free memory) you may adjust the apache configuration values to even lower values.

Conclusion: if you run some small blog or personal page this configuration will run smoothly for you and will provide you with snappy performance. If you have more then 1k unique visitors a day think of something different (or pay for small ec2 instance).

Share this post