You are on page 1of 18

Caching in Drupal

APC and Memcached,


CacheRouter and Memcache API
Benchmarking tests for a heavy drupal 6 demo site
Characteristics
Linode VPS, 1GB RAM, single server setup
Debian GNU/Linu !"# $%&bit
'ernel ("$")!"%&*$+$%&linode1$, *$+$%
Apa,-e ("(".
P/P !"("$, running as 0ast1G2
AP1 )"#"1.
Me3,a,-ed 1"("(
M4S5L !"#"!1
Drupal $"(#
Aut-enti,ated User Page 1a,-ing 6aut-,a,-e7 1"#&r,(
1a,-e Router 6,a,-router7 1"#&r,1
1a,-e Router Statisti,s 6,a,-erouter+stats7 1"#&beta)
Me3,a,-e AP2 and 2ntegration 63e3,a,-e7 1"#&beta)
8avaS,ript Aggregator 69avas,ript+aggregator7 1"!
1SS G:ip 6,ss+g:ip7 1")
-eav4 drupal site 61*( 3odules, .! pro9e,ts7
Methodology
dae3on restart bet;een tests 6apa,-e(, 34s<l, 3e3,a,-ed7
page re=res- 6>Re,ent posts> page, tra,?er(7, =ollo;ed b4 3ultiple visits & average results
ta?en
login session in =ire=o, anon43ous session in ,-ro3e
login session not user 1, but =ull ad3inistrator nonet-eless
Daemon settings
AP1 on 61(!$MB, standb47
Me3,a,-ed on 61(*MB, standb47
Drupal settings
Blo,? ,a,-e on
Page ,o3pression on
1SS and 8avaS,ript aggregation on
1SS ,o3pression on 61SS G:ip7
8avaS,ript ,o3pression on and 3ini=4 on 68avaS,ript Aggregator7
Devel on 6,olle,t <uer4, displa4 ti3er, displa4 3e3or47
@ra,?er ( on
!etc!php!conf"d!custom"ini
Aap,B
ap,"enabled C 1
ap,"s-3+seg3ents C 1
Dap,"s-3+si:e C )#
ap,"s-3+si:e C (!$
ap,"nu3+=iles+-int C 1###
ap,"user+entries+-int C %#.$
ap,"ttl C #
ap,"user+ttl C #
ap,"g,+ttl C )$##
ap,",a,-e+b4+de=ault C 1
ap,"sla3+de=ense C #
ap,"=ile+update+prote,tion C (
ap,"enable+,li C #
Dap,"3a+=ile+si:e C !##'
ap,"3a+=ile+si:e C 1M
ap,"33ap+=ile+3as?C>>
ap,"use+re<uest+ti3e C 1
ap,"stat C 1
ap,";rite+lo,? C 1
ap,"report+auto=ilter C #
ap,"in,lude+on,e+override C #
ap,"=iltersC>>
ap,"r=,1*$E C 1
ap,"r=,1*$E+pre=i C >upload+>
ap,"r=,1*$E+na3e C >AP1+UPLFAD+PRFGRGSS>
ap,"r=,1*$E+=re< C #
ap,"r=,1*$E+ttl C )$##
ap,"lo,al,a,-e C #
ap,"lo,al,a,-e"si:e C !1(
ap,",oredu3p+un3ap C #
ap,"stat+,ti3e C #
ap,"=ile+3d! C #
ap,",anoni,ali:e C 1
ap,"la:4+=un,tions C #
ap,"la:4+,lasses C #
A3e3,a,-eB
session"save+-andlerC>3e3,a,-e>
session"save+pat-C>t,pH//1(E"#"#"1H11(11IpersistentC1J;eig-tC1Jti3eoutC1Jretr4+intervalC1!>
3e3,a,-e"dbpat-C>>
3e3,a,-e"proto,olCas,ii
3e3,a,-e"de=ault+portC11(11
3e3,a,-e"de=ault+ti3eout+3sC1###
3e3,a,-e",-un?+si:eC)(E$*
3e3,a,-e"-as-+strateg4C>,onsistent>
3e3,a,-e"-as-+=un,tionC>,r,)(>
3e3,a,-e"redundan,4C1
3e3,a,-e"session+redundan,4C(
3e3,a,-e"allo;+=ailoverC#
3e3,a,-e"3a+=ailover+atte3ptsC!
3e3,a,-e"3aratioC#
3e3,a,-e"3are,levelC#
3e3,a,-e"3a=ilesC#
3e3,a,-e"3a=ilesi:eC#
3e3,a,-e"ar,-ive3e3li3C#
!etc!memcached"conf
D 3e3,a,-ed de=ault ,on=ig =ile
D (##) & 8a4 Bon,i K9a4bon,iLdebian"orgM
D @-is ,on=iguration =ile is read b4 t-e start&3e3,a,-ed s,ript provided as
D part o= t-e Debian GNU/Linu distribution"
D Run 3e3,a,-ed as a dae3on" @-is ,o33and is i3plied, and is not needed =or t-e
D dae3on to run" See t-e RGADMG"Debian t-at ,o3es ;it- t-is pa,?age =or 3ore
D in=or3ation"
&d
D Log 3e3,a,-edNs output to /var/log/3e3,a,-ed
log=ile /var/log/3e3,a,-ed"log
D Be verbose
D &v
D Be even 3ore verbose 6print ,lient ,o33ands as ;ell7
D &vv
D Start ;it- a ,ap o= $% 3egs o= 3e3or4" 2tNs reasonable, and t-e dae3on de=ault
D Note t-at t-e dae3on ;ill gro; to t-is si:e, but does not start out -olding t-is 3u,-
D 3e3or4
D&3 $%
&3 1(*
D De=ault ,onne,tion port is 11(11
&p 11(11
D Run t-e dae3on as root" @-e start&3e3,a,-ed ;ill de=ault to running as root i= no
D &u ,o33and is present in t-is ,on=ig =ile
&u nobod4
D Spe,i=4 ;-i,- 2P address to listen on" @-e de=ault is to listen on all 2P addresses
D @-is para3eter is one o= t-e onl4 se,urit4 3easures t-at 3e3,a,-ed -as, so 3a?e sure
D itNs listening on a =ire;alled inter=a,e"
D&l 1(E"#"#"1
D&l 1(E"#"#"1 (1)"((*"1%1"). 1.("1$*"#"1#1
&l 1(E"#"#"1
D Li3it t-e nu3ber o= si3ultaneous in,o3ing ,onne,tions" @-e dae3on de=ault is 1#(%
D &, 1#(%
D Lo,? do;n all paged 3e3or4" 1onsult ;it- t-e RGADMG and -o3epage be=ore 4ou do t-is
D &?
D Return error ;-en 3e3or4 is e-austed 6rat-er t-an re3oving ite3s7
D &M
D Mai3i:e ,ore =ile li3it
D &r
#a$le %ith results
#est method Apache
MB
&'R!APC
in Apache
MB
Memcache
MB
My&()
MB
)ogin
Apache
ms
)ogin
My&()
*uery
)ogin
My&()
ms
Anon
Apache
ms
Anon
My&()
*uery
Anon
My&()
ms
APC + Memcache API +
AuthCache
1$% E* 1! EE %(1"! .) 1!"E* (1E"$) !) .".*
Memcache API + AuthCache
1## *"$ (# *# *(*")) .) 1$")E $(1"%( !) 1#".$
APC + CacheRouter ,file+apc- +
AuthCache
1(! $1 & E* %(#"1% .( 1*"#% ($%"1E !% 1(".1
APC + CacheRouter ,apc- +
AuthCache
1$! E. & E$ %!#"%* .( 1E"E. (11"%E !% 1#"EE
APC + CacheRouter
,memcache- + AuthCache
1$$ E* (( E$ 1$E%")* .! 1$"% 1((!"(E !% 1#"%*
APC + CacheRouter ,file- +
AuthCache
1(% $1 & EE %(#"#$ .( 1* (($"$$ !% 1(".!
CacheRouter ,apc- + AuthCache
.$ 1# & E$ *%!"%$ .( 1*")! !%)"%% !% ."!1
CacheRouter ,memcache- +
AuthCache
.. *"% (1 E$ 1**#"*) .( 1*"(( 1%)*"#( !% 1#")*
CacheRouter ,file- + AuthCache
E( *") & EE *%)"!! .( 1E"%1 $)#"#. !% 1#"E
CacheRouter ,d$- + AuthCache
E$ *") & E. .##"E. 11% ).")E !E*"1( E% (E"%
Drupal cache
.$ *"% & *# *%$"1) 11% )!"*! !$."EE E. (*"(.
Conclusions
0or 3ai3u3 per=or3an,e, AP1 s-ould be turned on b4 de=ault 6global7 =or t-e virtual
-ost"
O-ile not ,o3pared in t-se ben,-3ar?s, -aving Aut-1a,-e enabled 3a?es a -uge
di==eren,e =or aut-enti,ated users"
/aving =ile&based ,a,-ing 61a,-eRouter, BoostP7 ,an save a lot o= 3e3or4, but itNs
per=or3an,e ,an be -a3pered b4 2/F"
Me3,a,-e based ,a,-ing 6Me3,a,-e AP27 is also e<uall4 e==e,tive, spending about t-e
sa3e resour,es"
Do not use Me3,a,-e ;it- 1a,-eRouter & t-e 3odule per=or3s ver4 poorl4 ;it- t-at
,a,-ing ba,?end"
Avoid using AP1 turned on b4 de=ault 6global7 in ,on9u,tion ;it- AP1 enabled on Drupal
61a,-eRouter, AP17"
@-e t-ree best ,on=igurations =or a single server are as =ollo;sH
AP1 P 1a,-eRouter 6=ilePap,7 P Aut-1a,-eH -ig- per=or3an,eQ not s,alableQ lo;er 3e3or4
,onsu3ption
AP1 P 1a,-eRouter 6=ile7 P Aut-1a,-eH -ig- per=or3an,eQ not s,alableQ lo;er 3e3or4
,onsu3ptionQ -a3pered in 2/F
AP1 P Me3,a,-e AP2 P Aut-1a,-eH best per=or3an,e, s,alableQ -ig-er 3e3or4
,onsu3ption
All information collected
APC on $y default, Memcache API on, AuthCache on, Drupal cache on
S4ste3 StatsH
Me3H 1#1.1*#? total, *$%!$%? used, 1!%$1$? =ree, )%%1(? bu==ers
S;apH ($(1%#? total, 1(*%%? used, (%.(.$? =ree, !(*#)$? ,a,-ed
P2D USGR PR N2 V2R@ RGS S/R S R1PU RMGM @2MGP 1FMMAND
!!1% gala4&n (# # !!(3 1$%3 E*3 S # 1$"! #H#)"%$ p-p!&,gi
!((E 34s<l (# # (%*3 EE3 !%%* S # E"* #H#)"*% 34s<ld
!(*E nobod4 (# # )1%E$ 1!3 E1( S # 1"! #H##"#) 3e3,a,-ed
Session & logged in, 3anagerH
Page ee,ution ti3e ;as %(1"! 3s" Ge,uted .) <ueries in 1!"E* 3illise,onds"
Me3or4 used atH devel+init67C."/6 MB, devel+s-utdo;n67C0."12 MB"
Session & anon43ousH
Page ee,ution ti3e ;as (1E"$) 3s" Ge,uted !) <ueries in .".* 3illise,onds"
Me3or4 used atH devel+init67C."/1 MB, devel+s-utdo;n67C33"4/ MB"
APC off $y default, Memcache API on, AuthCache on, Drupal cache on
S4ste3 StatsH
Me3H 1#1.1*#? total, *!%*%#? used, 1$%)%#? =ree, E)(%%? bu==ers
S;apH ($(1%#? total, 1(*%%? used, (%.(.$? =ree, %!EE%#? ,a,-ed
P2D USGR PR N2 V2R@ RGS S/R S R1PU RMGM @2MGP 1FMMAND
!.E) gala4&n (# # !!E3 1##3 *!E( S # 1#"1 #H(#"$! p-p!&,gi
!E(# 34s<l (# # (%%3 *#3 !E#* S # *"1 #H#$")* 34s<ld
!EE. nobod4 (# # )$$## (#3 E1( S # ("# #H##"#$ 3e3,a,-ed
Session & logged in, 3anagerH
Page ee,ution ti3e ;as *(*")) 3s" Ge,uted .) <ueries in 1$")E 3illise,onds"
Me3or4 used atH devel+init67C5"64 MB, devel+s-utdo;n67C/2"4 MB"
Session & anon43ousH
Page ee,ution ti3e ;as $(1"%( 3s" Ge,uted !) <ueries in 1#".$ 3illise,onds"
Me3or4 used atH devel+init67C5"66 MB, devel+s-utdo;n67C62"60 MB"
APC on $y default, CacheRouter on ,file+apc-, AuthCache on, Drupal cache off
S4ste3 StatsH
Me3H 1#1.1*#? total, *E().(? used, 1%$E**? =ree, E)##%? bu==ers
S;apH ($(1%#? total, .$)(? used, (!(!#*? =ree, %*$.(*? ,a,-ed
P2D USGR PR N2 V2R@ RGS S/R S R1PU RMGM @2MGP 1FMMAND
1.$!1 gala4&n (# # !(.3 1(!3 $13 S # 1("$ #H#!"(* p-p!&,gi
1.%#) 34s<l (# # ((!3 E*3 !!!( S # E". #H#%"#E 34s<ld
Session & logged in, 3anagerH
Page ee,ution ti3e ;as %(#"1% 3s" Ge,uted .( <ueries in 1*"#% 3illise,onds"
Me3or4 used atH devel+init67C."/2 MB, devel+s-utdo;n67C0."12 MB"
Session & anon43ousH
Page ee,ution ti3e ;as ($%"1E 3s" Ge,uted !% <ueries in 1(".1 3illise,onds"
Me3or4 used atH devel+init67C."/0 MB, devel+s-utdo;n67C33"// MB"
APC on $y default, CacheRouter on ,apc-, AuthCache on, Drupal cache off
S4ste3 StatsH
Me3H 1#1.1*#? total, *!(%)(? used, 1$$E%*? =ree, E)$(#? bu==ers
S;apH ($(1%#? total, .$)(? used, (!(!#*? =ree, %E.#.(? ,a,-ed
P2D USGR PR N2 V2R@ RGS S/R S R1PU RMGM @2MGP 1FMMAND
(#1!# gala4&n (# # !!13 1$!3 E.3 S # 1$"$ #H#(".1 p-p!&,gi
1..#( 34s<l (# # ($%3 E$3 !%)( S # E"$ #H#%")$ 34s<ld
Session & logged in, 3anagerH
Page ee,ution ti3e ;as %!#"%* 3s" Ge,uted .( <ueries in 1E"E. 3illise,onds"
Me3or4 used atH devel+init67C."/2 MB, devel+s-utdo;n67C0."56 MB"
Session & anon43ousH
Page ee,ution ti3e ;as (11"%E 3s" Ge,uted !% <ueries in 1#"EE 3illise,onds"
Me3or4 used atH devel+init67C."/0 MB, devel+s-utdo;n67C33"/2 MB"
1a,-eRouter StatsH
1a,-ed 0ilesH $*% 6 $1"1
MB4tes7
/itsH %E#.
MissesH $*%
1a,-ed VariablesH )% 6 ("1
MB4tes7
/itsH 1EE
MissesH #
0rag3entationH #"1)R 6(%$"$
'B4tes7
APC on $y default, CacheRouter on ,memcache-, AuthCache on, Drupal cache off
S4ste3 StatsH
Me3H 1#1.1*#? total, ...(%#? used, 1..%#? =ree, E#1E(? bu==ers
S;apH ($(1%#? total, 1#.)$? used, (!1(#%? =ree, !%1))$? ,a,-ed
P2D USGR PR N2 V2R@ RGS S/R S R1PU RMGM @2MGP 1FMMAND
(E(!E gala4&n (# # !!%3 1$$3 E*3 S # 1$"* #H)!"*! p-p!&,gi
(E##. 34s<l (# # ($%3 E$3 !!)$ S # E"E #H#%"1. 34s<ld
(E#$* nobod4 (# # )*!(* ((3 E1( S # ("( #H(("## 3e3,a,-ed
Session & logged in, 3anagerH
Page ee,ution ti3e ;as 1$E%")* 3s" Ge,uted .! <ueries in 1$"% 3illise,onds"
Me3or4 used atH devel+init67C."// MB, devel+s-utdo;n67C03"66 MB"
Session & anon43ousH
Page ee,ution ti3e ;as 1((!"(E 3s" Ge,uted !% <ueries in 1#"%* 3illise,onds"
Me3or4 used atH devel+init67C."/6 MB, devel+s-utdo;n67C30"15 MB"
1a,-eRouter StatsH
Used 1a,-e Si:eH ("1 MB4tes
@otal 1a,-e Si:eH 1(*"#
MB4tes
1urrent 2te3s 6total7H )$ 6()E7
/itsH (($
MissesH !!
APC on $y default, CacheRouter on ,file-, AuthCache on, Drupal cache off
S4ste3 StatsH
Me3H 1#1.1*#? total, *11E!$? used, (#E%(%? =ree, E%*$%? bu==ers
S;apH ($(1%#? total, .$)(? used, (!(!#*? =ree, %$#$E(? ,a,-ed
P2D USGR PR N2 V2R@ RGS S/R S R1PU RMGM @2MGP 1FMMAND
(#$%$ gala4&n (# # !(.3 1(%3 $13 S # 1("! #H11"E% p-p!&,gi
(#).* 34s<l (# # ((%3 EE3 !%E( S # E"* #H#%"(( 34s<ld
Session & logged in, 3anagerH
Page ee,ution ti3e ;as %(#"#$ 3s" Ge,uted .( <ueries in 1* 3illise,onds"
Me3or4 used atH devel+init67C."/2 MB, devel+s-utdo;n67C0."10 MB"
Session & anon43ousH
Page ee,ution ti3e ;as (($"$$ 3s" Ge,uted !% <ueries in 1(".! 3illise,onds"
Me3or4 used atH devel+init67C."/0 MB, devel+s-utdo;n67C33"/1 MB"
APC off $y default, CacheRouter on ,apc-, AuthCache on, Drupal cache off
S4ste3 StatsH
Me3H 1#1.1*#? total, E*($1$? used, ()$!$%? =ree, E$!##? bu==ers
S;apH ($(1%#? total, .$(%? used, (!(!1$? =ree, %#*(%*? ,a,-ed
P2D USGR PR N2 V2R@ RGS S/R S R1PU RMGM @2MGP 1FMMAND
(1$%# gala4&n (# # !!(3 .$3 1#3 S # ."E #H#.".( p-p!&,gi
(1).( 34s<l (# # ($%3 E$3 !%E$ S # E"$ #H#)"** 34s<ld
Session & logged in, 3anagerH
Page ee,ution ti3e ;as *%!"%$ 3s" Ge,uted .( <ueries in 1*")! 3illise,onds"
Me3or4 used atH devel+init67C5"10 MB, devel+s-utdo;n67C/2"54 MB"
Session & anon43ousH
Page ee,ution ti3e ;as !%)"%% 3s" Ge,uted !% <ueries in ."!1 3illise,onds"
Me3or4 used atH devel+init67C5"13 MB, devel+s-utdo;n67C62"63 MB"
1a,-eRouter StatsH
1a,-ed 0ilesH # 6 #"# B4tes7
/itsH 1
MissesH #
1a,-ed VariablesH )% 6 ("1
MB4tes7
/itsH 1!*
MissesH #
0rag3entationH #"1(R 6)1*"$
'B4tes7
APC off $y default, CacheRouter on ,memcache-, AuthCache on, Drupal cache off
S4ste3 StatsH
Me3H 1#1.1*#? total, *1E#E(? used, (#(1#*? =ree, EE1%%? bu==ers
S;apH ($(1%#? total, .$(%? used, (!(!1$? =ree, %#$1#*? ,a,-ed
P2D USGR PR N2 V2R@ RGS S/R S R1PU RMGM @2MGP 1FMMAND
((1(% gala4&n (# # !!E3 ..3 *)E$ S # 1#"# #H(#"*) p-p!&,gi
(1*E# 34s<l (# # ($%3 E$3 !!1( S # E"E #H#%"1( 34s<ld
(1.(. nobod4 (# # )E%%# (13 E1( S # ("1 #H1#".$ 3e3,a,-ed
Session & logged in, 3anagerH
Page ee,ution ti3e ;as 1**#"*) 3s" Ge,uted .( <ueries in 1*"(( 3illise,onds"
Me3or4 used atH devel+init67C5"14 MB, devel+s-utdo;n67C/5"64 MB"
Session & anon43ousH
Page ee,ution ti3e ;as 1%)*"#( 3s" Ge,uted !% <ueries in 1#")* 3illise,onds"
Me3or4 used atH devel+init67C5"1/ MB, devel+s-utdo;n67C65"55 MB"
1a,-eRouter StatsH
Used 1a,-e Si:eH ("1 MB4tes
@otal 1a,-e Si:eH 1(*"#
MB4tes
1urrent 2te3s 6total7H )$ 6(#%7
/itsH 1E1
MissesH %$
APC off $y default, CacheRouter on ,file-, AuthCache on, Drupal cache off
S4ste3 StatsH
Me3H 1#1.1*#? total, E$##!$? used, (!.1(%? =ree, E!E.$? bu==ers
S;apH ($(1%#? total, .$(%? used, (!(!1$? =ree, %#!.*#? ,a,-ed
P2D USGR PR N2 V2R@ RGS S/R S R1PU RMGM @2MGP 1FMMAND
(#*.) 34s<l (# # ().3 EE3 !!1( S # E"* #H#)"*. 34s<ld
(11%1 gala4&n (# # !)#3 E(3 *(*% S # E") #H#!"!) p-p!&,gi
Session & logged in, 3anagerH
Page ee,ution ti3e ;as *%)"!! 3s" Ge,uted .( <ueries in 1E"%1 3illise,onds"
Me3or4 used atH devel+init67C5"1/ MB, devel+s-utdo;n67C/2"11 MB"
Session & anon43ousH
Page ee,ution ti3e ;as $)#"#. 3s" Ge,uted !% <ueries in 1#"E 3illise,onds"
Me3or4 used atH devel+init67C5"16 MB, devel+s-utdo;n67C62"64 MB"
APC off $y default, CacheRouter on ,d$-, AuthCache on, Drupal cache off
S4ste3 StatsH
Me3H 1#1.1*#? total, EEE%%*? used, (%1E)(? =ree, E*$$*? bu==ers
S;apH ($(1%#? total, .$(%? used, (!(!1$? =ree, %#$(*%? ,a,-ed
P2D USGR PR N2 V2R@ RGS S/R S R1PU RMGM @2MGP 1FMMAND
((*!. 34s<l (# # (#13 E.3 !!*% S # *"# #H#)"*$ 34s<ld
()11% gala4&n (# # !))3 E$3 *(.$ S # E"$ #H#*"!# p-p!&,gi
Session & logged in, 3anagerH
Page ee,ution ti3e ;as .##"E. 3s" Ge,uted 11% <ueries in ).")E 3illise,onds"
Me3or4 used atH devel+init67C5"13 MB, devel+s-utdo;n67C/5".1 MB"
Session & anon43ousH
Page ee,ution ti3e ;as !E*"1( 3s" Ge,uted E% <ueries in (E"% 3illise,onds"
Me3or4 used atH devel+init67C5"56 MB, devel+s-utdo;n67C65"34 MB"
APC off $y default, all cache modules off, Drupal cache on
S4ste3 StatsH
Me3H 1#1.1*#? total, E.*#*%? used, ((1#.$? =ree, *#*!(? bu==ers
S;apH ($(1%#? total, .$(%? used, (!(!1$? =ree, %11*)(? ,a,-ed
P2D USGR PR N2 V2R@ RGS S/R S R1PU RMGM @2MGP 1FMMAND
(%1$! gala4&n (# # !!%3 .$3 *)$# S # ."E #H11"%$ p-p!&,gi
().1% 34s<l (# # (!.3 *#3 !$#* S # *"1 #H#%"() 34s<ld
Session & logged in, 3anagerH
Page ee,ution ti3e ;as *%$"1) 3s" Ge,uted 11% <ueries in )!"*! 3illise,onds"
Me3or4 used atH devel+init67C5".2 MB, devel+s-utdo;n67C/2"35 MB"
Session & anon43ousH
Page ee,ution ti3e ;as !$."EE 3s" Ge,uted E. <ueries in (*"(. 3illise,onds"
Me3or4 used atH devel+init67C5".1 MB, devel+s-utdo;n67C62"56 MB"

You might also like