3

I'm developing an API on Appfog and want to know what to focus on (more memory with one instances or more instances with lower memory).

Appfog gives you free 2GB of RAM and up to 16 instances if each instances get 128 MB RAM.

My application uses PHP, MySql and Memcachier. I want to launch it soon and want to know which configuration is best for my server.

What is the benefit with more RAM or instances?

Thanks for helping :)

Best Regards, Johnny

Johnny Ha
  • 633
  • 5
  • 21

1 Answers1

6

You want as many instances as your app will run without running out of memory :). More instances means better performance and uptime. However, if an instance runs out of memory it will be shut down leaving your app running with fewer instances until they all collapse. You can diagnose this problem with the af apps and af logs <appname> --all commands. If the app is running at < 100% regularly then the instance memory budget may be too low. When there are down instances, the logs command may reveal memory limit reached errors.

Memory Recommendations

Here are some memory recommendations to start out with: Wordpress with several installed plugins will need > 512mb to be stable. For lean custom PHP apps 128mb is usually sufficient but should be watched. If an app is using a framework try 256mb. These memory limits may seem high but it's really the peak memory usage not the average usage.

Load Test

Load testing using Seige can help find a memory / instance balance. It does this by determining if your app is peaking out over the memory limit. Scale the app down to 1 instance and siege with 5, 10, and 15 concurrent connections progressively increasing by 5 until the app falls over. If the app does stop, bump the memory up and try again.

Tim Santeford
  • 27,385
  • 16
  • 74
  • 101
  • Thanks for your answers, right now I have two instances and memory usage is 63.20MB of 128MB and no 0% CPU. I will maybe try to do a load test when I have time and increase the memory usage to 256MB for each instances. Talked to a few colleagues about this, and they probably thought that more instances were better. – Johnny Ha Apr 26 '13 at 13:57
  • The af stats command gives you just a snapshot and may not show fluctuations. I would load test the app and monitor af stats to look for peak memory. See my updated answer on load testing. – Tim Santeford Apr 26 '13 at 17:10