Академический Документы
Профессиональный Документы
Культура Документы
AboutKhalid
Contributedmodules(37+?)
Userpoints Nagios SecondLife Adsense Jobsearch Favoritenodes Flagcontent Nudge StockAPIandmodule CurrencyAPIandmodule CustomError Imagewatermark Sitemenu Emailloggingandalerts Technorati Referral Nodevote
Memberof
DrupalAssociation(GeneralAssembly) security/infrastructureteams
Cofounderof2bits.com,Inc. Blogathttp://baheyeldin.com
About2bits.com
2bits.comServices
Agenda
Introduction TheLAMPStack
Drupal
Definitions
Goals
Defineyourobjectivesandgoalsfirst
DiminishingReturns
Diagnosis
Validation
Hardware
Physicalservermatters
Dedicated VPS
MultipleServers
Complexityisexpensive(runningcost) Tuningasystemcanavoid(ordelay)thesplit
TheLAMPstack
MostcommonlyusedstackforhostingDrupal andsimilarapplications
Mostofthispresentationappliesto*BSDas well.PartsapplytoWindows(anyoneuseit?).
Linux
Installonlywhatyouneed
(e.g.NoX11,nodesktop,NoJava,NoPostgreSQLif youareonlyusingMySQL,...etc.)
Linux(cont'd)
Balancecompileyourownvs.upgrades Compileyourown
Usingdeb/rpm
Apache
Enableonlymod_phpandmod_rewrite(asastart) Disableeverythingelse(mod_python,mod_perl,...)
Apache
MaxClients(preventswapping/thrashing)
MaxRequestsPerChild
KeepAlive
mod_gzip/deflate
ApacheAlternatives
lighttpd(lighty)
nginx
ApacheAlternatives
MySQL
MySQLEngines
MyISAM
InnoDB
MySQLEngines
Newengines,ownedbyMySQLAB
Maria PBXT
PrimeBaseXT
MySQLtuning
Querycache
Probablythemostimportantthingtotune Alsoimportant
Tablecache
MySQLreplication
Nowinuseondrupal.org
INSERT/UPDATE/DELETEgotothemaster SELECTsgotheslave
PHP
Usearecentversion
InstallanOpcodecache/Accelerator
Opcodecaches
Benefits
APCvs.eAcceleratorvs.Xcachebenchmarkon2bits.com Drawbacks(forotherthanAPC)
OtherthanAPC,theymaycrashoften UselogwatchertoautorestartApache
Unless...
Acceleratorswillnothelpincertaincases
APCadmin
mod_php
PHPasCGI
FastCGI
IfyouhaveoneserverandoneLinuxuser, permissionsmaynotbeanissue.
Oflate,Apachewithfcgidhasproventobestableas wellasbetteronmemoryusage(majorsavings).
mod_phpvs.fcgid
OtherwaysforPHP
RoadsendPHPcompiler
PHC(incomplete,Parrotspinoff)
CauchoQuercus
Drupal
Drupal(cont'd)
Bewaryaboutthrottleandcache
Modulecallsnetwork?
Doesyourmoduledostuffoverthenetwork? Foreverypageview?
Email2,000usersonnode/commentsubmit(og!) Callweb2.0widgets(e.g.Diggthis)?
Mediafiles
Useacontentdeliverynetwork(CDN)e.g.Akamai.
CDN
ContentDeliveryNetwork
CachingReverseProxy
SquidCache
Storesstaticfiles(css,js,images) NeedsapatchforHTML(i.e.Drupalgeneratedpages)
Vastperformanceimprovement
Intermediateproxiesstillanissue NewerthanSquid
Varnish
Drupalcaching
Aggressivecachingcanhavesomeimplications,but givesbetterperformance
Drupalcaching(cont'd)
Certainpartsofcachearealwaysonand cannotbeturnedoff(butseelater)
Boost
Drupalcaching(cont'd)
IfyouuseSquidasacache,thenthosemaynotapply Considerothercachingmodulesthatusefiles
FSFastpath
FileCache
Pluggablecaching
Using$confvariableinsettings.php
'cache_include'=>'./includes/yourcache.inc'
Blockcaching
memcached
memcached(cont'd)
memcached(cont'd)
Watchoutfor:
Also:
AdvancedCaching
Contributedmodule,setofpatches Forauthenticatedusers
Slowmodules
Statisticsmodule
gsitemap(XMLsitemap)
Slowmodules(cont'd)
Aggregator2
MeasureandMonitor
Howdoyouknowyouhaveaproblem?
Waittilluserscomplain(siteissluggish,timeouts)? Waittillyouloseaudience?Lossofinterestfromvisitors?
Differenttoolsforvarioustasks
Top
htop
atop
vmstat
netstat
apachetop
ReadsandanalysesApache'saccesslog Showsall/recenthits
Requestpersecond,KB/sec,KB/req 2xx,3xx,4xx,5xx
apachetopf/var/log/access.log
mtop,mytop
mtop/mytop
Ifyouhaveneither
SHOWFULLPROCESSLIST mysqladminprocesslist
runfromcron?
OtherMySQLtools
Mysqlreport
MySQLDBtuningprimer
SlowQueryLog
Usemysql_slow_log_parserscript Alsomysqlslascript
Stresstesting
Stresstesting(cont'd)
ab/ab2(Apachebenchmark)
Stresstesting(cont'd)
Siege
Jmeter
GraphicalMonitoring
Munin
Cacti
Nagios
Amonitoringplatform
Alertsbyemail,XMPP,SMS,... Alertsaboutmanythings
NewmoduleforDrupal(5.xand6.x)
Websitestatistics
Definitions
SiteStatistics
Awstats
Drupaltools
Develmodule
Tracemodule
PerformanceLogging
Drupaltools(cont'd)
Loadtestmodule
Casestudies
Inreallifeaction...
Case1:Millionpages
CanDrupaldo1,000,000pageviewsaday? Yeswecan!
How?
Case2:Slowforums
Case3:10sofseconds
Case4:Authenticated
Usecache_get()/set()forthisquery InnoDBforsessions,watchdog,accesslogtables
Case5:Hangs
Case6:SlowLAN
Case7:Crawler!
CPU100%
Whatwasit?
WasOKforaday eAccelerator(svn303+PHP 5) NoteCPUutilization(100%, thenhigh,thendroppedlow whengoodversionused)
Memory
Memory
DiskI/O
Network
DDoS
DistributedDenialofService
Aggressivecrawlers Wormsprobingforvulnerabilities
Furtherreading
Discussion
Questions? Comments?