Chris Caillouet
Dev|Ops Sensei
Rackspace University
Sept 10, 2014
Introductions
- Name (Who am I?)
- Rank (What do I do?)
- Tenure (How long have I done it?)
- Rackspace Story (Why do I love it here?)
Learning Objectives
- Discuss Magento and its usage within customer environments
- Understand components that make up the preferred Magento stack
- Deploy and configure each component in the Magento stack
- Grow capability to consult with customers about preferred practices for Magento
- Understand the Rackspace spheres of support regarding Magento
- Serve as a localized point of contact within their team, in regards to Magento
Spheres of Support
So we are supporting Magento now, you say?!?!
SHORT ANSWER
- No - Magento is still a 3rd party application
- We do not install or migrate Magento, or its data
- I wouldn't do that to you, so don't worry. Yet.
ACTUAL ANSWER
- The underlying components are supportable
- We are here to solidify the parts we DO support
- We can consult on best practices and ideal architectures
- We may build out specialist teams to handle true support
We can offer expertise on the following...
- LAMP Stack & Operating System support
- Nginx + PHP-FPM Alternatives to Apache
- Memcache, Redis & Varnish Caching layers
- Network & Infrastructure Topography
- Database Configuration and Connectivity
- Dedicated, Cloud & Hybrid Architectures
- Consultative Services around Magento Deployments
Magento Overview
Be on the lookout for the next appearance of Magneto during the day!
- Very Powerful
- Very Well Known
- Can Manipulate Magnetic Fields
- Class 9 Mutant (extremely dangerous)
- Formidable Adversary to the X-Men
Why Magento?
Why Magento?
• Community is Free and Open Source
• Extendable - Third party plugins are big a factor for Magento popularity
• Control multiple websites and stores from one Administration Panel
• “100% search engine friendly”
• Support for localization, multiple currencies and tax rates
• Paypal, Sagepay, Google Checkout, etc.
• Lots of reporting tools
• Support for native applications on mobile devices
• API
• Really fast! (actually, it isn't so bad if we do things right)
Basic Magento Installation Steps - Part I
(unlikely our role will be to handle this)
-
Change to the directory you wish to serve Magento from: cd /var/www/html (for example)
-
DOWNLOAD: wget http://www.magentocommerce.com/downloads/assets/1.9.0.1/magento-1.9.0.1.tar.gz
-
EXTRACT: tar -zxvf magento-1.9.0.0.tar.gz
-
MOVE FILES INTO SITE LOCATION: mv magento/* magento/.htaccess .
-
SET PERMISSIONS: chmod -R o+w media var
-
MORE PERMISSIONS: chmod o+w app/etc
-
...
-
PROFIT!!!
Basic Magento Installation Steps - Part II
(unlikely our role will be to handle this)
-
Create a MySQL database and user with full privileges to this DB - save this information
-
Launch the Web based installer by visiting the IP in a browser
-
...
-
PROFIT!!!
ORRRRrrrrr...
You could use a Rackspace Magento Cloud Deployment
LAB: Build out Magento
- Log into your cloud account at mycloud.rackspace.com
- Click into DEPLOYMENTS and peruse the list of choices
- Build a Magento Deployment using a 4GB Performance Server in the datacenter of your preference
- SSH into this new server and pull up the UI in a browser
- Inspect the running environment and peruse the UI
Magento File Tour
Let's have a look around the files within the Magento file structure
Magento File Structure
ALSO:
Magento Database Tour
Let's take a look at the database and tables that Magento utilizes
Magento Database
•Mostly InnoDB, so Percona is a good fit, while MySQL is the fully supported option
•Config in local.xml – straightforward. Note: optional table prefix
•Can configure master/slave natively (but not necessary)
•DB not normally the bottleneck, depends on architecture of the deployment
•max_allowed_packet = 16M 32M [or higher] (this is almost certainly a needed tweak)
Key Tables
The Magento Webserver
• Does not matter. PHP processing is main bottleneck, not static delivery
• Use PHP-FPM where possible
– Better under load
– Use local socket, not TCP:9000
• Matters even less with Varnish and/or CDN
• We prefer Apache, purely for config experience on our floor
– Most agencies prefer Nginx with PHP-FPM, and now we fully support it
--> see the Magento site for example config, or peruse your server
– Magento officially supports NginX for later versions only
Apache or NginX?
Caching Magento
Caching Magento
Zend Two-Level Cache
Backend Caching Options
- File
- APC
- Database
- Memcache
- Redis
File Based Cache Backend
- Default setting
- Better than nothing, but slow under load.
- Can mount tmpfs, but still inefficient.
- Handles Zend two-level
- On filesystem:
~/var/cache
~/var/full_page_cache (Enterprise)
NOTE: Could be in /tmp/magento/var/ if ~/var wasn’t writable
APC Based Cache Backend
- APC can also be used for key/value storage
set apc.shm_size = 1024M
- Works on all versions
- Better than File, but not shared
- Still needs a slow_backend
default : <slow_backend>File</slow_backend>
There is nothing wrong with using APC...
...but use memcache|redis instead, for future scalability.
Database Cache Backend
Memcache Cache Backend
<session_save><![CDATA[memcache]]></session_save>
<session_save_path><![CDATA[tcp://127.0.0.1:11211?persistent=0&weight=2&timeout=10&retry_interval=10]]></session_save_path>
<cache>
<backend>memcached</backend>
<memcached>
<servers>
<server>
<host><![CDATA[127.0.0.1]]></host>
<port><![CDATA[11212]]></port>
<persistent><![CDATA[1]]></persistent>
<weight><![CDATA[1]]></weight>
<timeout><![CDATA[1]]></timeout>
<retry_interval><![CDATA[15]]></retry_interval>
</server>
</servers>
<compression><![CDATA[0]]></compression>
<cache_dir><![CDATA[]]></cache_dir>
<hashed_directory_level><![CDATA[]]></hashed_directory_level>
<hashed_directory_umask><![CDATA[]]></hashed_directory_umask>
<file_name_prefix><![CDATA[]]></file_name_prefix>
</memcached
Excerpt of configuration from app/etc/local.xml
LAB: Memcache Configuration
- Peruse the memcache configuration files in /etc/memcached_*
- What is the current value for session & backend maximum connections? When|Why should you adjust this value?
- Set these values to 10240.
- Restart memcache to enable these changes.
Redis Cache Backend
Redis is Memcache with knobs to enhance #alltehthings
Features:
- Persistence
- Replication,
- Authentication
- Internal database structure
Allows Zend to use it as a slow_backend.
Allows for multiple Magneto shops in a single instance.
BE HONEST!
WHO SAW IT?!?!
So...
...on with the show.
OKAY... Just one moment...
Redis Cache Backend
Redis is Memcache with knobs to enhance #alltehthings
Features:
- Persistence
- Replication,
- Authentication
- Internal database structure
Allows Zend to use it as a slow_backend.
Allows for multiple Magneto shops in a single instance.
Redis Cache Backend - When to use it?
Redis Cache Backend - /etc/redis.conf
Don’t forget to install phpXXX-pecl-redis
Sessions (documented on one.rackspace.com wiki)
Redis Cache Backend - app/etc/local.xml
<session_save><![CDATA[db]]></session_save>
<redis_session>
<host>10.181.99.168</host> <!-- or absolute path to unix socket -->
<port>6379</port> <!-- if unix socket just change it to 0 -->
<password>if_you_set_one</password>
<timeout>3</timeout>
<persistent></persistent>
<db>0</db>
<compression_threshold>2048</compression_threshold>
<compression_lib>gzip</compression_lib>
<log_level>1</log_level>
<max_concurrency>6</max_concurrency>
<break_after_frontend>5</break_after_frontend>
<break_after_adminhtml>30</break_after_adminhtml>
<bot_lifetime>7200</bot_lifetime>
</redis_session>
Magento Cache Backend - Which to use?!?
Need I say anymore? Redis is a natural pairing with Magento and can be a direct replacement to memcache implementations, in many cases.
1.Find the wiki article on redis installation
2.Install and configure Redis on localhost as a replacement to Memcache
… check with “redis-cli info”
3.Don’t forget to enable the sessions usage in the code
4.Configure local.xml for <sessions> and <cache>
… using different DB numbers
5.Test, then disable the Memcache instances once Redis is verified to be working
LAB: Redis Implementation
Hint
Full page caching is a must for the most performant Magento implementations, but is only available with an Enterprise Magento license. There are third party tools that provide this feature, as well.
Magento Full Page Caching
Full Page Cache Improves Time To First Byte
Full Pace Cache - Third Party Options
LAB: Varnish + PageCache
~ Search the one.rackspace wiki for implementation
instructions for Varnish with PageCache for Magento.
~ Implement this caching layer, as per Wiki, using
Varnish 3.x repo and ~/mage installer.
~ Poke around in Magento Dashboard config
Hint
Architecting Magento
~ Single server is OK!
– Actually good value vs Cloud
~ Old advice was before we understood effective FPC options
~ Plenty of CPU/memory
– i.e NOT a Cloud server
~ Separate RAID for DB ideal
~ Good for Enterprise licensing, and no LB complexity (next slide)
~ Better: second server for DB/cache
Dedicated
Adding a Load Balancer
Sample Dedicated Multi Server Configuration
Sample Dedicated Clustered Server Configuration
Sample Cloud Deployment
Sample Cloud Deployment
redis + ObjectRocket
Sample Hybrid Deployment
Troubleshooting Magento
Magento Platform Troubleshooting
First Things First - Magento Logging
Magento Error Page Troubleshooting
Varnish & Web Layer Troubleshooting
Magento Platform Q&A
SURVEY TIME!!!
Chris Caillouet
chris.caillouet@rackspace.com
Dev|Ops Sensei
Rackspace University
fin
Magento Technical Essentials v0.2
By Rackspace University
Magento Technical Essentials v0.2
Magento, the leading e-commerce platform, is a common choice to utilize, but one that is seldom utilized efficiently. This course details best practices and architectures for running a Magento deployment.
- 1,045