Speed Optimize Magento for Developer Machine Windows

Summary:  optimize Magento for a local Windows developer machine

We've optimized Magento for a local Windows machine and reached speeds increasements of 400% (4 times) till 3000~1500% (15 to 30 times). The screen below shows the speed measurements.

After optimization the average load of a Magento page is 1.0 seconds till 1.53 seconds. Below 12 steps have been detailed out to optimize your own Magento.

Wampserver + magento speed optimization on windows

Content

1.     Added APC cache and optimized for Magento.
2.     Disabled Xdebug extension.
3.     Changed memory limit of PHP to 512MB
4.     Unloaded Apache extensions not used, also unload PHP Extensions.
5.     Disabled firewall and antivirus.
6.     Tweak thread and memory settings of Apache.
7.     Enable gzip compression with .htaccess
8.     Moved .htaccess to vhost file, and Allow Options None in documentroot.
9.     Enabled in Magento backend (System > Configuration > Advanced > Developers > Css merge)
10.  Enabled Javascript compression
11.  Enable Magento compiler (will compile all files to /includes/src ~ System > Tools > Compiler)
12.  Use IPv4 only

1.      Added APC cache and optimized for Magento.

To add APC cache and optimized for Magento, you can review at here
Notes:
-  Suggest for configure APC: apc.shm_size = 128MB, apc.max_file_size = 10MB, apc.num_files_hint = 8000, apc.user_entries_hint = 1000.
-  FIX: Fatal error: Cannot override final method Mage_Core_Model_Abstract::clearInstance(), just restart Wampserver, and close some other applications to use less RAM

  • apc.stat=1
  • apc.canonicalize = 0

2.      Disabled Xdebug extension.

Comment code lines for Xdebug in your php.ini. My php.ini as below

;zend_extension = "c:/wamp/bin/php/php5.4.16/zend_ext/php_xdebug-2.2.3-5.4-vc9.dll"

[xdebug]
;xdebug.default_enable=0
; turn those always off
;xdebug.remote_enable=on
;xdebug.remote_handler="dbgp"
;xdebug.remote_host=127.0.0.1
;xdebug.remote_port=9000
;xdebug.remote_autostart=on
;xdebug.idekey="netbeans-xdebug"
;xdebug.remote_mode=req
;xdebug.remote_connect_back=0
;xdebug.profiler_enable = off
;xdebug.profiler_enable_trigger = off
;xdebug.profiler_output_name = cachegrind.out.%t.%p
;xdebug.profiler_output_dir = "c:/wamp/tmp"

3.      Changed memory limit of PHP to 512MB

Set memory_limit in you php.ini into 512M

Note: In your Magento this setting may be overridden, please check index.php or .htaccess in root directory Magento

4.      Unloaded Apache extensions not used, also unload PHP Extensions.

Settings your php.ini as below for unload Apache, PHP not used:

;extension=php_bz2.dll
extension=php_curl.dll
;extension=php_dba.dll
;extension=php_exif.dll
;extension=php_fileinfo.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
;extension=php_ming.dll
;extension=php_mssql.dll
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll
;extension=php_oci8_11g.dll
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_phar.dll
;extension=php_pspell.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_soap.dll
;extension=php_sockets.dll
;extension=php_sqlite.dll
;extension=php_sqlite3.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
;extension=php_zip.dll

In httpd.conf file

LoadModule access_compat_module modules/mod_access_compat.so
#LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
#LoadModule allowmethods_module modules/mod_allowmethods.so
#LoadModule asis_module modules/mod_asis.so
#LoadModule auth_basic_module modules/mod_auth_basic.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule authn_anon_module modules/mod_authn_anon.so
#LoadModule authn_core_module modules/mod_authn_core.so
#LoadModule authn_dbd_module modules/mod_authn_dbd.so
#LoadModule authn_dbm_module modules/mod_authn_dbm.so
#LoadModule authn_file_module modules/mod_authn_file.so
#LoadModule authn_socache_module modules/mod_authn_socache.so
#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule authz_core_module modules/mod_authz_core.so
#LoadModule authz_dbd_module modules/mod_authz_dbd.so
#LoadModule authz_dbm_module modules/mod_authz_dbm.so
#LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
#LoadModule authz_host_module modules/mod_authz_host.so
#LoadModule authz_owner_module modules/mod_authz_owner.so
#LoadModule authz_user_module modules/mod_authz_user.so
#LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule buffer_module modules/mod_buffer.so
#LoadModule cache_module modules/mod_cache.so
#LoadModule cache_disk_module modules/mod_cache_disk.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
#LoadModule cgi_module modules/mod_cgi.so
#LoadModule charset_lite_module modules/mod_charset_lite.so
#LoadModule data_module modules/mod_data.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule dav_lock_module modules/mod_dav_lock.so
#LoadModule dbd_module modules/mod_dbd.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
#LoadModule dumpio_module modules/mod_dumpio.so
#LoadModule env_module modules/mod_env.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule ext_filter_module modules/mod_ext_filter.so
#LoadModule file_cache_module modules/mod_file_cache.so
LoadModule filter_module modules/mod_filter.so
LoadModule headers_module modules/mod_headers.so
#LoadModule heartbeat_module modules/mod_heartbeat.so
#LoadModule heartmonitor_module modules/mod_heartmonitor.so
#LoadModule ident_module modules/mod_ident.so
#LoadModule imagemap_module modules/mod_imagemap.so
#LoadModule include_module modules/mod_include.so
#LoadModule info_module modules/mod_info.so
#LoadModule isapi_module modules/mod_isapi.so
#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
#LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
#LoadModule ldap_module modules/mod_ldap.so
#LoadModule logio_module modules/mod_logio.so
LoadModule log_config_module modules/mod_log_config.so
#LoadModule log_debug_module modules/mod_log_debug.so
#LoadModule log_forensic_module modules/mod_log_forensic.so
#LoadModule lua_module modules/mod_lua.so
LoadModule mime_module modules/mod_mime.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
#LoadModule negotiation_module modules/mod_negotiation.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_express_module modules/mod_proxy_express.so
#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_html_module modules/mod_proxy_html.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
#LoadModule ratelimit_module modules/mod_ratelimit.so
#LoadModule reflector_module modules/mod_reflector.so
#LoadModule remoteip_module modules/mod_remoteip.so
#LoadModule request_module modules/mod_request.so
#LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule rewrite_module modules/mod_rewrite.so
#LoadModule sed_module modules/mod_sed.so
#LoadModule session_module modules/mod_session.so
#LoadModule session_cookie_module modules/mod_session_cookie.so
#LoadModule session_crypto_module modules/mod_session_crypto.so
#LoadModule session_dbd_module modules/mod_session_dbd.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule slotmem_plain_module modules/mod_slotmem_plain.so
#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
#LoadModule socache_dbm_module modules/mod_socache_dbm.so
#LoadModule socache_memcache_module modules/mod_socache_memcache.so
#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule ssl_module modules/mod_ssl.so
#LoadModule status_module modules/mod_status.so
#LoadModule substitute_module modules/mod_substitute.so
#LoadModule unique_id_module modules/mod_unique_id.so
#LoadModule userdir_module modules/mod_userdir.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule version_module modules/mod_version.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule watchdog_module modules/mod_watchdog.so
#LoadModule xml2enc_module modules/mod_xml2enc.so

Afterwards always test with "httpd.exe -S" and "httpd.exe -t" to test if configuration is valid. Then, you watch apache error log to fix error if an error occurs

5.      Disabled firewall and antivirus.

When firewall antivirus checks/reads writes, it can slow up the local site significantly. This happens not all the time. To speed up access to Magento you should disable virus scanning program.

6.      Tweak thread and memory settings of Apache.

Depending on OS very much, check your resource monitor. After tweak, (watch your Task Manager > Resource monitor), Apache feels snappier and more eager to respond.

RECOMMENDED: you add code below in your httpd.conf file

#MaxMemFree 16
ThreadLimit 1920
#ThreadStackSize 8192
ThreadsPerChild 64
#MaxRequestsPerChild 100
KeepAliveTimeout 600
MaxKeepAliveRequests 128

Below are VALUES I use for a LOW-VOLUME site (try to be honest with yourself - either you get a lot of traffic or you don't - there's no shame in having low #traffic - it is what it is):

#MaxMemFree 16
#ThreadLimit 32
#ThreadStackSize 8192
#ThreadsPerChild 32
#MaxRequestsPerChild 100
#KeepAliveTimeout 2

7.      Enable gzip compression with .htaccess

Enable deflate_module and enable params in mod_deflate.c in Htaccess file

8.      Moved .htaccess to vhost file, and Allow Options None in documentroot.

Sample config of httpd-vhosts file

<VirtualHost 127.0.0.1:80>

 DocumentRoot "C:/w/MEX003/src2/domains/dragonfroot.com/public_html"
# ServerName yourdomain.com
ServerName mex003-v2.local

    ServerAlias mex003-v2.local

 ErrorLog C:/wamp/logs/apache_error.log
CustomLog C:/wamp/logs/access.log common

 <Directory "C:/w/MEX003/src2/domains/dragonfroot.com/public_html">
allow from all
</Directory>

 # Begin Magento Directives

 <Directory "C:/w/MEX003/src2/domains/dragonfroot.com/public_html">
AllowOverride None
</Directory>

 <Directory "C:/w/MEX003/src2/domains/dragonfroot.com/public_html"> ############################################
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
## it might be /cgi-bin/php-cgi
#    Action php5-cgi /cgi-bin/php5-cgi
#    AddHandler php5-cgi .php

 ############################################
## GoDaddy specific options
#   Options -MultiViews
## You might also need to add this line to php.ini
##     cgi.fix_pathinfo = 1
## if it still doesn't work, rename php.ini to php5.ini ############################################
## This line is specific for 1and1 hosting
#AddType x-mapp-php5 .php
#AddHandler x-mapp-php5 .php
############################################
## default index file
DirectoryIndex index.php
<IfModule mod_php5.c>

############################################
## adjust memory limit
#    php_value memory_limit 64M
php_value memory_limit 512M
php_value max_execution_time 18000

 ############################################
## disable magic quotes for php request vars
php_flag magic_quotes_gpc off
############################################
## disable automatic session start
## Before autoload was initialized
php_flag session.auto_start off
############################################
## enable resulting html compression
#php_flag zlib.output_compression on
###########################################
# Disable user agent verification to not break multiple image upload
php_flag suhosin.session.cryptua off ###########################################

 # Turn off compatibility with PHP4 when dealing with objects
php_flag zend.ze1_compatibility_mode Off
</IfModule>
<IfModule mod_security.c>
###########################################
# Disable POST processing to not break multiple image upload

  SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

 <IfModule mod_deflate.c>
############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
# Insert filter on all content
SetOutputFilter DEFLATE
# Insert filter on selected content types only
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 has some more problems
BrowserMatch ^Mozilla/4.0[678] no-gzip

  # MSIE masquerades as Netscape, but it is fine
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
# don’t compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary

  # Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
<IfModule mod_ssl.c>
############################################
## make HTTPS env vars available for CGI mode
SSLOptions StdEnvVars
</IfModule>

 <IfModule mod_rewrite.c>
############################################
## enable rewrites
Options +FollowSymLinks
RewriteEngine on
############################################
## you can put here your magento root folder
## path relative to web root
#RewriteBase /magento/

 ############################################
## Workaround for HTTP authorization
## In CGI environment
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

 ############################################
## Compress, Combine and Cache Javascript/CSS
# Fooman Speedster module, uncomment if needed
#RewriteRule ^(index.php/)?minify/([^/]+)(/.*.(js|css))$ lib/minify/m.php?f=$3&d=$2

 ############################################
## Always send 404 on missing files in these folders
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/ ############################################

 ## never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l ############################################

 ## rewrite everything else to index.php
RewriteRule .* index.php [L]
</IfModule>
############################################
## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead
AddDefaultCharset Off
#AddDefaultCharset UTF-8
<IfModule mod_expires.c>
############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
ExpiresDefault "access plus 1 year"
</IfModule>
############################################
## By default allow all access
Order allow,deny
Allow from all
###########################################
## Deny access to release notes to prevent disclosure of the installed Magento version

  <Files RELEASE_NOTES.txt>
order allow,deny
deny from all
</Files>

############################################
## If running in cluster environment, uncomment this
## http://developer.yahoo.com/performance/rules.html#etags
#FileETag none
</Directory>

 <Directory "C:/w/MEX003/src2/domains/dragonfroot.com/public_html/app">
Order deny,allow
Deny from all
</Directory>

 <Directory "C:/w/MEX003/src2/domains/dragonfroot.com/public_html/errors">  <FilesMatch ".(xml|phtml)$">
Deny from all
</FilesMatch>
</Directory>

 <Directory "C:/w/MEX003/src2/domains/dragonfroot.com/public_html/pkginfo">
Order deny,allow
Deny from all
</Directory>

 <Directory "C:/w/MEX003/src2/domains/dragonfroot.com/public_html/lib">
Order deny,allow
Deny from all
</Directory>

 <Directory "C:/w/MEX003/src2/domains/dragonfroot.com/public_html/var">
Order deny,allow
Deny from all
</Directory>

 <Directory "C:/w/MEX003/src2/domains/dragonfroot.com/public_html/includes">
Order deny,allow
Deny from all
</Directory>

 <Directory "C:/w/MEX003/src2/domains/dragonfroot.com/public_html/media">
Options All -Indexes
<IfModule mod_php5.c>
php_flag engine 0
</IfModule>
AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi
Options -ExecCGI
<IfModule mod_rewrite.c>

   ############################################
## enable rewrites
Options +FollowSymLinks
RewriteEngine on
############################################
## never rewrite for existing files
RewriteCond %{REQUEST_FILENAME} !-f   ############################################
## rewrite everything else to index.php
RewriteRule .* ../get.php [L]
</IfModule>
</Directory>

 <Directory "C:/w/MEX003/src2/domains/dragonfroot.com/public_html/media/customer">
Order deny,allow
Deny from all
</Directory>

 <Directory "C:/w/MEX003/src2/domains/dragonfroot.com/public_html/media/downloadable">
Order deny,allow
Deny from all
</Directory>

 <Directory "C:/w/MEX003/src2/domains/dragonfroot.com/public_html/downloader">
<IfModule mod_deflate.c>
RemoveOutputFilter DEFLATE
RemoveOutputFilter GZIP
</IfModule>

  <Files ~ ".(cfg|ini|xml)$">
order allow,deny
deny from all
</Files>
</Directory>

 <Directory "C:/w/MEX003/src2/domains/dragonfroot.com/public_html/downloader/template">
Order deny,allow
Deny from all
</Directory>
# End Magento Directives
</VirtualHost>

9.      Enabled in Magento backend (System > Configuration > Advanced > Developers > Css merge)

10.  Enabled Javascript compression

11.  Enable Magento compiler (will compile all files to /includes/src ~ System > Tools > Compiler)

12.  Use IPv4 only

In httpd.conf: Change "Listen 127.0.0.1:80" into "Listen 0.0.0.0:80"

Comments
My Cart
loading