1

I need to speed up my magento installation, so I'm planning to put the content of 'var/' (or only var/cache and var/sessions) on a tmpfs.

I'm also buying a reserved instance on Amazon, so I would like to keep a sufficent amount of RAM. I want to enable memcached, PHP Apc, MySQL caching and HTTP caching.

I'm thinking of a Medium Reserved Instance with the following specs:

3.75 GB memory
2 EC2 Compute Unit (1 virtual core with 2 EC2 Compute Unit)
410 GB instance storage
32-bit or 64-bit platform
I/O Performance: Moderate
EBS-Optimized Available: No
API name: m1.medium

Will the RAM be enough to appy a good caching system? Looking now (after 3 months) the var directory is 14gb, but I think cleaning it up each 5/7 days would be good too.

Do you have any suggestion for me?

P.S. the store will contain an average of 100/150 products.

3 Answers3

5

I think moving /var to a tmpfs is probably not your biggest bottleneck and would likely be more trouble than its worth. Make sure Magento caching is enabled and you have APC enabled.

This post covers some general tips on increasing Magento performance:

Why is Magento so slow?

Community
  • 1
  • 1
Cody Caughlan
  • 32,456
  • 5
  • 63
  • 68
  • And sessions will not survive a reboot... that's one of my biggest gripes with sessions in memcached as well. – philwinkle Aug 20 '12 at 20:33
4

I would suggest looking into setting up a reverse proxy like Varnish.

If you do plan on just using a tmpfs in memory I would suggest looking into Colin's improved over Zend_Cache_Backend_File

Also I would suggest looking into mytop to keep tabs of if you have any places you can optimize queries in the application itself or in my.cnf to help ease any DB bottlenecks.

Session Digital has a good white paper (although somewhat dated) on optimizing Magento enterprise and the same can be applied to Community. Out of everything I've tried, Varnish, as mentioned in the White paper offered the most significant increase in response time.

Hope this helps!

Community
  • 1
  • 1
B00MER
  • 5,471
  • 1
  • 24
  • 41
  • Thanks! Will this instance be useful to use varnish or the Zend Cache Backend? I'm talking about RAM and CPUs requirements. –  Aug 20 '12 at 15:38
  • Varnish has a very low memory and CPU usage foot print, I don't see it being any problem with a EC2 Medium instance you quoted. Just a fun fact, Varnish was initially developed by a FreeBSD core developer. http://en.wikipedia.org/wiki/Varnish_(software) – B00MER Aug 20 '12 at 15:47
  • Is memcached an alternative to the tmpfs? What if I configure the backend caching to be memcached in magento configuration? The var/sessions and var/cache should be empty, am I right? Thanks for Varnish, I completely forgot it!! –  Aug 21 '12 at 19:27
  • tmpfs, in essence is a **_basic_** form of memcache. If you are using memcached for session and cache then yes, both var/cache and var/sessions would be empty. – B00MER Aug 21 '12 at 19:40
  • what if there is thousand of user or cache(sessions) is too much bigger than RAM? what happen if reboot? all session stored in RAM is distroyed? regarding "tmpfs" – user2733745 Dec 09 '14 at 10:37
  • Avoid using a tmpfs/ and use memcache or reddis + database `db` to keep a tab of session ids, this is the best of both worlds and isn't volatile to RAM for sessions. Checkout CM_RedisSession as well. – B00MER Dec 11 '14 at 01:15
1

Firstly, +1 to all of the answers here.

if you're thinking about running /var/ out of tmpfs it's probably because you've heard of the lousy file IO on AWS or you have experienced issues with it yourself. However, the /var/ directory is the least of your concern - Zend / Magento's autoloaders are more taxing to IO. To mitigate that you want to run APC and the compilation (assuming you're not using persistent shopping cart).

As echoed by other commenters, anything that runs from cache or memory will circumvent PHP and thus the need to touch the disk and incur IO issues. Varnish is a bit of a brute-force approach and is a wonderful tool on massive sites that scale to millions of views; but I believe that Varnish's limitations with SSL and the lack of real documentation and support from our Magento community make it a better intellectual choice than an actual alternative.

When running Magento Community I prefer to run Tinybrick's Lightspeed on AWS on a Medium instance - which gives me the most bang-for-buck and is itself a full-page-cache. I get 200+ concurrent pages/second in this setup and I'm not running memcached or using compilation.

http://www.tinybrick.com/improve-magentos-slow-performance.html/

Be careful with running memcached in your AWS instance as well - I find that it can be impeded by a power-hungry Apache gone wild in the rare instance you haven't got a primed cache which causes Apache maxclients issues while it waits for cache response. If you could afford it I would rather run two micro Apache instances with a shared memcached session store and a load balancer in front of them - give some horsepower to the db on a separate box for them to share, though. But all setups are unique and your traffic/usage will dictate what you need.

I have run Magento in the AWS cloud for 3 years with great success - and I wish the same to you. Cheers.

philwinkle
  • 7,036
  • 3
  • 27
  • 46
  • Thanks! Didn't know about Lightspeed, it seems pretty good. BTW this time I think I'll try with Varnish first, then I'll try LightSpeed to compare results :) –  Aug 22 '12 at 06:57
  • 1
    What's wrong using a persistent cart with APC and compilation? –  Aug 22 '12 at 06:59
  • 1
    It actually doesn't work; an incompatibility within Magento. There is quite a bit of documentation out there about it - see here: http://stackoverflow.com/questions/7531071/magento-blank-screen-on-checkout-cart-with-compiler-enabled and a proposed fix is here: http://www.iweb.co.uk/mg/fix-magento-cartcheckout-blank-page-with-compilation-enabled/ – philwinkle Aug 22 '12 at 16:27