210 likes | 321 Views
01.58.56.60.80 / contact@nbs-system.com. Make Magento run like an antelope. Bio About Magento Speed matters , a LOT From 10s to 3s Breaking the 1.5s wall What servers, what volumes. Magento is oftenly considered like. Powerfull Solution of the futur Complicated to code
E N D
01.58.56.60.80 / contact@nbs-system.com Make Magento runlike an antelope • Bio • About Magento • Speed matters, a LOT • From 10s to 3s • Breaking the 1.5s wall • What servers, what volumes
Magentoisoftenlyconsideredlike • Powerfull • Solution of the futur • Complicated to code • So much fun ! • And • Slow • Ressources hungry • CPU intensive • Complicated to code • Well, thisistrue, most of it.
Organisation de la production NowwhyMagentocanbe more like • First consider the wins • More sales • More efficient • More flexible • Costless to modify / admin • Will last (22 M$ should help) • Then the drawbacks • Ressource intensive • A bit tricky to master Then the solution Put a betterhostingenvironment to correct the « fat boy » feeling and onlyappreciate good points.
Organisation de la production Speed maters, a LOT • Google isnowusing speed as an important ranking factor (it’s official) • Graph (given by Google) show clearly the target: 1.5s • Actually, 1,5s meansyou’re part of the 75% fastest sites but… • More time and you are part of the red team in the red zone, called « SLOW » • Guesswhat, thisis no good for yourranking & SEO • Besides • Revelanceisstill the most important criteriaamong 200, but, http://ow.ly/1xfqt • Amazon loose 1% revenue every 0,1s latency • Yourcustomersfeelit, thisis part of theirexperience on your site ! • Our Goal isnowclear : load in lessthan 1.5s
The keys Stepping down from 10+ to 3 seconds • The right hardware • The right OS • An efficient architecture • Code like a God
Stepping down from 10+ to 4 seconds Organisation de la production • Hardware manufacturer have very different efficiency • Intel and AMD processors doesn’t behave the same • Hyperthreading changes (almost) nothing in server performances • RAM make a HUGE difference on I/O • HARDWARE Advices • Xeon for front servers, 5670 if possible • AMD mono - hexacores for DB • Use DDR3 • Use SAS controllers with cache • Put a LOT of RAM in them (we’ll see later why), 2 Go per core !
Stepping down from 10+ to 4 seconds Organisation de la production • Being OS Agnostic, I’m objective • Windows consume toomuch ressources on PHP interpretation, weak TCP/IP stack, not optimized for *AMP environment • OpenSolaris gave poorresults (30% lessthan Linux) • NetBSDbehavewell, veryfaircompetitor • Linux isleadingquiteseriously • Operating System Advices • Debian Lenny • CentOS • NetBSD • Redhat • (avoid the GUI baseddistro)
Stepping down from 10+ to 4 seconds Organisation de la production • A Firewall + Loadbalancer • A Reverse Proxy willoffload the servers • Content server for static files (CSS/JPG/GIF/JS…) • You candeliversatic content « near to the user » with CDN • Separated web & database servers (+33%) • Create an efficient architecture Advices • Netfilter for FW • IPVS + keepalived • NGINX for the RP • Apache, Litespeed, Zeus, Nginx • Conservative ? Apache + Squid • R&D guy ? Nginx + PHP FPM + Mango DB
Stepping down from 10+ to 4 seconds Organisation de la production • Code like a God • Code maters. A HUGE LOT. • Eachlittleglitchisgoing to beamplified by the visitornumbers : • Small site : dirtythingswon’tbetoomuch of a problem • Big site : a miscodedloopcantake down the servers • Be helped by community • FoomanSpeedster, Magento boosters (likedelorum’s one) • Read Forums, blogs • Bargento (to listen to our top notchtalks) • Apply the whitebooks and blog post optimisation tips • Be helped by Magento Inc • A bit of consulting by the pro, a lot of time won !
Stepping down from 10+ to 4 seconds Organisation de la production • Code like a God • Go to a strong training course • Understand the block caching • Take care of the security ! (xss/csrf/sql-injection) • Leaving a 404 on a picturecreate a PHP exec : bad ! • Optimise the CSS selectors & the CSS calls (justneeded one) • Serialize CSS and then JS order in the downloads(not css/js/css/js) • Minifyyour JS usingJsmin • Avoid redirections, optimizepictures, and DNS queries • Be carefullwhile in a loop, thinkthatyourpiece of code willsometimesbeexecutedthousands of time a minute…
Organisation de la production • a.k.a « Where the fun starts » Breaking the 1.5s wall ! • Getrid of the major bottleneck : I/O • Down deep in the mine • Advanced Tweaks • Analyse your trafic • Use cache the right way • More ?
Breaking the 1.5s wall ! Organisation de la production • The I/O Bottleneck • I/Os are a majorproblem • Write to disk, but with a good Controller, on a excellent disk • Read fromdisk == loosetime (except on VERY good SAS controllers) • ALL TO RAM ! We’vegotplenty of it ! • Faster and more reliablethan a SSD • Optimized by CPU & BUS • Inexpansive • Dawn fast Advices • Put sessions & cache on tmpfsramdisks • Use fastdiskslike 15Ktm SAS and a good controllerwith RAM to boost the writes • Have yourdisks in RAID 10 if possible • Don’t log uselessthings (& don’t log-resolve) • Lot of RAM ? Put the whole site on !
Stepping down from 10+ to 4 seconds Organisation de la production • Split read & write to different DB • <default_read> -> host it on a RAMDISK • <default_write> -> Host it on a PhysicalDisk • Safety + Performances • Use DRBD • DRBD is an opensource Blockdevice sharing over network. • Mainline in Linux Kernelsince 2.6.33 => safe • Simple, safe, efficient (and made for High avaibilityenvironments). This give good results and canbeused but it’slimited to onlytwo servers for now. • MYSQL
Breaking the 1.5s wall ! Organisation de la production • Advanced Tweaks • Use Sysfence to autokill the bombingcrons or phpprocess • Use IRQ_Balancing • Mount yourdiskswithnoatime option (fasteraccess to data) • Lower socket Wait Timeout in /proc • Truncate (or archive) your log tables in Magento • Check the best scheduler, iomapper, L3 (architecture dependant) • Use GRsec/Pax (for securitypurposes) • Tweak Zend server rules • Optimizeyour peering map (network) • Put a QoS tag on yourpackets to speed them up • Check foreignincludesresponse times and put themat the end of pages • Use pagespeed / Yslow / Gtmetrix to analyse your site • IntegrateLucene SOLR on large catalogdatabase (> 100 000 products) • Use latest version of Magento and activate all caches in the BO (if possible)
Breaking the 1.5s wall ! Organisation de la production • Analyzeyour trafic (know yourennemy) • Use your mailing wisely, spreadit on somehours • Same for all trafic generation, « burst » isyourennemy Advices
Breaking the 1.5s wall ! Organisation de la production • Use Cache the right way Tips & Tricks • PHTML blocks shouldbecachedit in order not to begeneratedeachview • To cache a block, you have to declareitexplicitly, no « auto mecanism » • Developersusuallydon’tuse the Block cachingmecanismat all (80%) • Up to ten times fasterloadingwhenusing cache properly ! • The Enterprise Edition has a full page cachingmecanism • (for the final pages, not the individual blocs) • NBS willsoon release a plugin thatwill « automagically » do it for you
Benchmarking Organisation de la production • Funkload & APDEX are the keys to « realistics » benchmarks • Whenyoureach a 0,9 APDEX indice, your server has givenenough power and your user stillfeel confortable. • 4 levels for user experience (likeyourgirlfriend, except for the timings) : • Satisfied (for exemple 3s) • Tolerating (3x more, solessthan 9s) • Frustrated (more than 9s) • Inacceptable (not served/errors)
Benchmarking Organisation de la production
What servers, what volumes ? Organisation de la production • With 5670 dual quad core server • 8 Go of DDR3 1066 Mhz • Optimised settings & servers • Databasesplited to another server • Very good site (optimized) • 80 000 products • Magento 1.4.0.1 + FC demostore • APDEX Limited to 0,9 • 80 000 uniqvisitor / day per front server • 650 Concurrent Users • 0,67s averageload time on the home • (it’sstill a « perfect case », count more on 50 KVU)
01.58.56.60.80 / contact@nbs-system.com O Thankyou for your attention ! Need (fast) hosting ? NBS System 140 bd haussmann 75 008 Paris Tel : +33.1.58.56.60.86 Mail : contact@nbs-system.com Web : www.nbs-system.com 8 november 2010, PARIS 750 + visitors, 30 booths 16 talks