本文转自:https://www.mgt-commerce.com/blog/magento-on-steroids-best-practice-for-highest-performance/

There are plenty of blog posts with tips how to increase the performance of a magento store this shows us how important the speed of a magento store is.

As you may heard google is obsessed with speed, speed is one important factor for their search ranking algorithms. Site speed reflects how fast the website (magento shop) responds to web requests.

The speed of a site is not only important for the shop owners, it’s important for all internet user. Faster sites means happy user, happy customers and more sales. If a magento shop responds slowly, customers leave the website and maybe buy products at your competitor.

In my daily work over some years with magento performance issues i want to share my best practices.

In order to get the best performance we have to care about the server with it’s configuration and magento, our shop software.

A) The Server environment – the base for highest performance

  1. Get a dedicated server

    Advantages
    - Whole server power for you
    - You are very flexible in terms of new versions for webserver, database, php …
    - There are not other customers which run “bad” scripts which slow down the shop
    - You don’t share the same ip, very important for SEO.
    If one customer makes a “bad business”, the ip can be blocked by google which affects your search ranking.
    My recommendation:
    I am a big fan of the Amazon EC2 cloud which gives you everything you need (flexibility, scalability, security).
    I installed, configured and optimized more than 100 magento shops around the world, works perfect.

  2. Split database and webserver (if possible)

    A webserver and a database server have different requirements. A database server needs fast hard disks (e.g. SSD) and much memory and not that much CPU. A webserver needs more CPU and less memory.

  3. Use a separate Backend Server (Multi Server Environment)

    Run all cronjobs on this server. You can also handle all admin users there.

  4. Use newest MySQL Version
  5. MySQL Configuration

    Proper MySQL configuration is one of the most important aspects in terms of performance. Optimizing the MySQL configuration can provide up to 65% performance improvement. MySQL by default is configured to use far fewer resources than the average hardware can accommodate. InnoDB, the primary table storage engine type can use the in-memory buffer pool to cache table indexes and data. Less disk I/O is needed to get data from hard drives when the value of the in-memory buffer pool is set higher. A general recommendation is to set this parameter up to 80% of the available RAM for a dedicated database server. If you are running webserver and database server on one server it’s recommended to split the entire memory pool into two parts.

    Setting for the key parameter “innodb_buffer_pool_size”

    Server Type innodb_buffer_pool_size
    Combined webserver and database server, 6 GB RAM 2-3 GB
    Dedicated database server, 6 GB RAM 5 GB
    Dedicated database server, 12 GB RAM 10 GB
    Dedicated database server, 24 GB RAM 18 GB

    Further important MySQL configuration settings

    innodb_thread_concurrency = 2 * [numberofCPUs] + 2
    innodb_flush_log_at_trx_commit = 2
    thread_concurrency = [number of CPUs] * 3
    thread_cache_size = 32
    table_cache = 1024
    query_cache_size = 64M
    query_cache_limit = 2M
    join_buffer_size = 8M
    tmp_table_size = 256M
    key_buffer = 32M
    innodb_autoextend_increment=512
    max_allowed_packet = 16M
    max_heap_table_size = 256M
    read_buffer_size = 2M
    read_rnd_buffer_size = 16M
    bulk_insert_buffer_size = 64M
    myisam_sort_buffer_size = 128M
    myisam_max_sort_file_size = 10G
    myisam_max_extra_sort_file_size = 10G
    myisam_repair_threads = 1

  6. Checkout MySQLTuner

    MySQLTuner is a Perl script that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief format along with some basic performance suggestions.

  7. Mount disk with noatimeoption

    Linux has a special mount option for file systems called noatime. If this option is set for a file system in /etc/fstab, then reading accesses will no longer cause the atime information (last access time – don’t mix this up with the last modified time – if a file is changed, the modification date will still be set) that is associated with a file to be updated (in reverse this means that if noatime is not set, each read access will also result in a write operation). Therefore, using noatime can lead to significant performance gains.

  8. Memory-based filesystem for dynamic data

    By storing dynamic data (var/cache, var/session) on a memory-based filesystem like RAMdisk or tmpfs, the disk I/O is decreased.

  9. Host the shop in same country where your customers are

    The nearest location to your customers means the fastest response.

  10. Install the newest PHP Version

    PHP 5.2.x is very old and slow. PHP 5.3.x is about 30-40% faster than PHP 5.2.x and has a lower memory footprint. PHP 5.4.x is about 20% than PHP 5.3.x for magento.

    Some key parameter for your php.ini

    realpath_cache_size = 32k
    realpath_cache_ttl = 7200
    max_execution_time = 90
    max_input_time = 90
    memory_limit = 256M
    default_socket_timeout = 90
    pdo_mysql.cache_size = 2000
    output_buffering = 4096

  11. Install a byte code cache like APC

    By default, Magento saves it’s cache data in file system. This is fine for small sites with low traffic, but as you get more and more requests, reading and writing to the file system become slower from time to time. With APC you will not have such problems because all valus are stored in memory.

    Example php.ini configuration

    apc.enabled = 1
    apc.optimization  = 0
    apc.shm_segments = 1
    apc.shm_size = 768M
    apc.ttl = 48000
    apc.user_ttl  = 48000
    apc.num_files_hint = 8096
    apc.user_entries_hint = 8096
    apc.mmap_file_mask = /tmp/apc.XXXXXX
    apc.enable_cli = 1
    apc.cache_by_default  = 1
    apc.max_file_size = 10M
    apc.include_once_override = 0
  12. Swap Apache for NGINX

    NGINX is a high performance, high concurrency edge web server with the key features to build modern, efficient, accelerated web infrastructure.
    In one of my previous project (biggest e-commerce site in brasil) with 750.000 unique visitors / day we swapped 6 apache webserver with 2 nginx webserver and we had a load of 1.00 afterwards.

  13. Enable Gzip Compression in NGINX configuration or Apache .htaccess

    Test your Site: http://www.gidnetwork.com/tools/gzip-test.php

  14. Set expiration header for static files

    Configuration for nginx vhost: 
    location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ {
    expires max;
    access_log off;
    }
    Apache:
    Make sure the module “mod_expire” is enabled

  15. Apache modules – use just necessary modules
  16. Apache: Eliminating directory structure scans for the .htaccess
  17. Enable KeepAlive

    KeepAlive provides long-lived HTTP sessions which allow multiple requests to be sent over the same TCP connection. In some cases this has been shown to result in an almost 50% speedup in latency times for HTML documents with many images.

    NGINX: http://wiki.nginx.org/HttpCoreModule#keepalive_timeout (Default is 75 seconds, which is good)
    Apache: http://httpd.apache.org/docs/current/misc/perf-tuning.html

  18. Use a Content Delivery Network (CDN) for delivering static files like js, css and images to offload your server

    Afterwards your server has only php request to handle this means all requests for js, css and images are handled by the CDN. You may save a lot of hosting costs.
    My personal experience
    I made very good experience with Amazon Cloufront because it’s very easy to integrate and not expensive and fully integrated in the Amazon Webservice. In my previous posts i wrote about how to use magento with Cloudfront.

  19. Uninstall xdebug or zend debugger on production

    It’s a perfect tool for a development or testing environment but not for production. In some of our projects xdebug had a performance impact of 10-15%, especially with high traffic.

B) Magento configuration

  1. Single Server Environment:
    Use APC as magento cache storage (app/etc/local.xml)

          <global>...<cache><backend>apc</backend><prefix>mgt_</prefix></cache>...</global>

    Multi Server Environment
    Use memcached as central cache storage

    <global>
    ...
    <cache><backend>memcached</backend><!-- apc / memcached / empty=file --><memcached><!-- memcached cache backend related config --><servers><!-- any number of server nodes can be included --><server><host><![CDATA[127.0.0.1]]></host><port><![CDATA[11211]]></port><persistent><![CDATA[1]]></persistent></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>
    </cache>
    ...
    </global>
  2. Store sessions in memory
    Single Server Environment:

    Setup Memory-based filesystem for dynamic data (see point 8 above) or use memcached like multi server environment

    Multi Server Environment

    <global>
    ...
    <session_save><![CDATA[memcache]]></session_save>
    <session_save_path><![CDATA[tcp://127.0.0.1:11211?persistent=0&weight=1&timeout=1&retry_interval=15]]></session_save_path>
    <session_cache_limiter><![CDATA[]]></session_cache_limiter>
    ...
    </global>
  3. Uninstall any extensions that you don’t actually use.

    Disable not needed extensions in app/etc/modules/*.xml or delete

  4. Enable all Magento Caches: System -> Cache Management.
  5. Enable “Use Flat Catalog Category” and “Use Flat Catalog Product” to decrease database queries: System -> Configuration -> Catalog -> Catalog -> Frontend
  6. Enable “Merge JavaScript Files” and “Merge CSS Files” to reduce the number of http requests
  7. Use a Full Page Cache
    More Information + Demo
    • 90% Faster + 200x More Requests per second
    • Results in higher customer satisfaction and increased sales
    • Amazon: +100 ms, -1% sales
    • Better SEO rating from Google
    • Google webmaster tools report site loading in more than 1.5s as “slow”
    • Study show 70% of revenue come from the fastest visits
    • Dramatically decrease page load time
    • Dramatically decrease your server load
    • Reduce hardware requirements
    • Reduce the number of required web servers
    • Shrink your bounce rates.
  8. Don’t use layered navigation if you don’t really need it, it needs a lot of resources
  9. Don’t use ioncube encrypted extensions

    Ioncube is an encoding system for PHP files. Ioncube-encoded files aren’t readable (by humans) so software companies use it to protect their intellectual property. There are many disadvantages with ioncube encrypted extensions. The biggest disadvantage is that it slow down your shop and it’s impossible to extend. Another big problem is that you can’t step into the code with a debugger like xdebug or zend debugger to see what happens.
    Willem from http://www.byte.nl wrote a nice article about the ioncube and magento performance.

  10. Limit the number of products on a product overview page.
    System -> Configuration -> Catalog -> Catalog -> Frontend
  11. Disable the Magento log
    System -> Configuration -> Advanced -> Developer -> Log Settings (default is disabled)
  12. Enable cron and log cleaning: System > Configuration > Advanced > System -> Log Cleaning

    By default, Magento logs every visitor’s requests to the database. As time goes, the number of records may become enormous and slowing down writes as the table grows.

C) Magento Templating/Frontend

  1. Compress images

    We often think that the higher the image quality is, the better our blog/site will look. Unfortunately, you are sacrificing a much more important feat – site’s performance! Higher image quality means higher file size. Higher file size means it will take longer and slower to upload/serve that file to a visitor.

    Recommended services for image compression

    • http://www.smush.it/
    • http://www.jpegmini.com/
  2. Minimize Javascript use
  3. Specify Image dimensions.
  4. Use Block cache and HTML output in your extensions.
  5. Remove all blocks which you actually don’t use/need from layout xml
    Example how to remove the poll from the right column

    <layout version="0.1.0"><default><reference name="right"><remove name="right.poll"/></reference></default>
    </layout>
  6. Use a Lazy Image Loader to load images on demand
  7. Use a lighweight template

D) Bonus Tips

  1. Install only extensions which you really need, less is more
  2. Avoid ioncube encrypted extensions
  3. Start developing with a developer toolbar from the very first beginning
    More Information + Demo
    • Requests: involved controller classes, modules, actions and request parameters
    • General Info: website id, website name, store id, store name, storeview id, storeview code, storeview name and configured caching method
    • Handles:overview of layout handles
    • Events/Observer: overview of events with it’s observers
    • DB-Profiler: Number of executed queries, average query length, queries per second, longest query length, longest query and detailed query listing including simple syntax highlighting of SQL
    • Config: enable/disable frontend hints, inline translation and cache clearing
    • PHP-Info output of phpinfo()
    • Profling output of Varien_Profiler with function execution time, function count and memory usage
    • Additional Information: Information: version information, page execution time and overall memory usage
    • Blocks: overview of block nesting

E) Speed testing tools, Other useful stuff

  1. Test the Load Time of a Web Page – http://tools.pingdom.com/fpt/
  2. Google Pagespeed Tool – https://developers.google.com/speed/pagespeed/?hl=en
  3. Firebug integrates with Firefox to put a wealth of development tools at your fingertips while you brows – https://addons.mozilla.org/de/firefox/addon/firebug/
  4. YSlow analyzes web pages and why they’re slow based on Yahoo!’s rules for high performance web sites
    https://addons.mozilla.org/de/firefox/addon/yslow/

转载于:https://www.cnblogs.com/freeliver54/p/9125707.html

[转]Magento on Steroids – Best practice for highest performance相关推荐

  1. PAT (Advanced Level) Practice A1090 Highest Price in Supply Chain (25 分)(C++)(甲级)(树,深度)

    原题链接:A1090 Highest Price in Supply Chain #include<algorithm> #include<iostream> #include ...

  2. 5篇CVPR 各路大佬显身手 点云分割、姿态估计、物体检测、生成重建

    点击上方"3D视觉工坊",选择"星标" 干货第一时间送达 3D方向:港中文针对分割问题提出双重设置点分组模型:清华提出无需 PoseNet 的联合深度姿势学习: ...

  3. tidb数据库_异构数据库复制到TiDB

    tidb数据库 This article is based on a talk given by Tianshuang Qin at TiDB DevCon 2020. 本文基于Tianshuang ...

  4. SPINN: Synergistic Progressive Inferenceof Neural Networks over Device and Cloud

    题目:SPINN: Synergistic Progressive Inferenceof Neural Networks over Device and Cloud SPINN:设备和云上神经网络的 ...

  5. Discriminative Feature Learning for Unsupervised Video Summarization(论文翻译)

    Discriminative Feature Learning for Unsupervised Video Summarization Abstract 在本文中,我们解决了无监督视频摘要的问题,该 ...

  6. ICML 2019 Accepted Papers (Title, Author, Abstract, Code) (001-150)

    本博客致力于整理出ICML 2019接收的所有论文,包括题目.作者.摘要等重要信息,能够方便广大读者迅速找到自己领域相关的论文. 相关论文代码.附录可参考ICML 2019 #####1-10#### ...

  7. [VQA文献阅读] FloodNet: A High Resolution Aerial Imagery Dataset for Post Flood Scene Understanding

    背景 文章题目:<FloodNet: A High Resolution Aerial Imagery Dataset for Post Flood Scene Understanding> ...

  8. 新思科技招聘 | 十一月热招职位(外企内推哦)

    open岗位: 1.IP Subsystem Design Engineer (PCIE/USB) 北京/上海/深圳 2.Analog Design Engineer, Staff武汉 3.ASIC ...

  9. Memory Hierarchy - 存储器层次结构

    Memory Hierarchy - 存储器层次结构 计算机系统将存储器分成若干层级 (memory hierarchy) ,越靠近 CPU 的存储器容量越小但访问速度越快. 1. Memory hi ...

最新文章

  1. golang 开发常见坑
  2. mockito_Eclipse的Mockito模板
  3. CSS连载-控制背景与CSS精灵
  4. JVM解释器和编译器
  5. 文件系统之-JAVA Sftp远程操作:
  6. 分布式应用CAP理论
  7. SpringCloud 从菜鸟到大牛之一 微服务介绍
  8. php生成游客id_PHP生成唯一ID 公认较为安全的写法 上传随机文件名
  9. 如果有多个虚拟机,手动启动哪个
  10. unity 后台计时器实现
  11. VBA中的数据字典,可以理解为Java中的Map
  12. ObjectDataSource 如何传递查询参数
  13. 改进3D/2D U-NET--添加深度监督deep supervision【Keras】
  14. ROS学习记录:读入bag文件,用Rviz读入播放
  15. php 省份的缩写,34个省级行政区记忆口诀、省份简称和省会城市表
  16. Automative SPICE 之五 过程能力层次和过程属性
  17. sqlserver2005 安装图解教程以及SQL 2005 SP3补丁安装图文教程
  18. 植物大战僵尸修改存档用户名、关卡、金钱说明
  19. 教你怎么解决64位Windows版Redis狂占C盘的问题.
  20. 京东返利PHP采集关键字,php-爬虫练习:抓取京东商品列表与详情-2019年10月18日...

热门文章

  1. Chromium GN入门学习(本文参考于谷歌Brett Wilson PPT学习资料及谷歌官网文档)
  2. Python-函数的练习题
  3. 基于国产UOS操作系统的Samba服务
  4. auto.js开发_赚钱( $ _ $ )app脚本_ZHOU125disorder_
  5. EXCEL按单元格颜色进行筛选 VBA代码 FOR EXCEL2003 (原创)
  6. 安卓平板安装桌面linux,Android手机或平板电脑使用Linux桌面
  7. VS2012编译OpenEXR
  8. 青岛大学附属医院辛海燕:打造空间分离、服务一体的多院区信息化建设
  9. 《PHP微服务练兵》系列
  10. Asp.Net MVC HTML Helper 中 LabelFor TextBoxFor的一些理解