You are on page 1of 4

9/27/13

Command-Line: Reliability Never Goes Out of Style | Talking PDF

T he Place for PDF Information

The Command-Line: Reliability Never Goes Out of Style


Pos ted on February 19, 2010 by Duff Johns on in T alking PDF

T o t h ose t r a in ed a n d ex per ien ced in .NET , V isu a l Ba sic, C libr a r ies a n d ot h er n on -sh ell in t er fa ces, t h e com m a n d-lin e m a y seem lik e a n old-sch ool w a y t o g et t h in g s don e. (If y ou r e a lr ea dy lost , h er es a g ood in t r odu ct ion t o t h e ba sic con cept s). If y ou r focu s is on ea se-of-dev elopm en t a n d ser v er u pt im e, h ow ev er , com m a n d-lin e a pplica t ion s a r e oft en a sm a r t er a n d m or e cost -effect iv e ch oice. I ca n h ea r t h e disbelief a lr ea dy : Hu h ? A r e y ou sa y in g t h a t t h er es been n o r ea l pr og r ess sin ce t h e com m a n d-lin e in t er fa ce w a s in v en t ed?!? V isu a l St u dio is a t v er sion 9 , w h a t else do y ou w a n t ! Gr a n t ed, in com pu t er t er m s, t h e com m a n d-lin e h a s been a r ou n d a lm ost sin ce m a n ca m e dow n fr om t h e t r ees. W h o w a n t s t o r em em ber a ll t h ose opt ion sw it ch es? Ev en so, t a k e a m om en t t o u n der st a n d w h y t h e com m a n d-lin e in t er fa ce st ill m a k es sen se oft en a lot of sen se for m a n y h ig h -lev el pr ocesses in t oda y s m ission cr it ica l ser v er im plem en t a t ion s.

Processes vs. Threads


Com m a n d lin e t ools g en er a lly oper a t e in in depen den t in st a n ces, ea ch a n in div idu a l pr ocess w h ich in t u r n m a y in it ia t e ot h er , a lso dist in ct (a n d in t er n a lly in depen den t ) su bpr ocesses. Ea ch pr ocess does on e t h in g a t a t im e, in isola t ion . Ea ch pr ocess m a y be a dm in ist r a t iv ely k illed if it r u n s a m ok . T h r ea din g , a s im plem en t ed in m ost DLL-ba sed W in dow s ser v er a pplica t ion s, w a s or ig in a lly desig n ed t o g et m u lt iple t h in g s h a ppen in g in t h e sa m e a pplica t ion . Mem or y w a s v er y ex pen siv e, a n d t h r ea ds seem ed ea sier t h a n la u n ch in g a sepa r a t e pr ocess. T h e dow n side w a s (a n d r em a in s) t h a t if a n y t h in g g oes w r on g , it g oes w r on g for t h e w h ole a pplica t ion , n ot sim ply for t h e specific in st a n ce t h a t en cou n t er s t h e pr oblem in pu t . T oda y , it s possible t o ex ch a n g e t h e (v er y ) m odest ov er h ea d a ssocia t ed w it h la u n ch in g fr esh pr ocesses for t h e r elia bilit y a n d ea se of dev elopm en t t h a t com es fr om lev er a g in g t h e fu n ct ion a l isola t ion of t a sk s in t o in div idu a l com m a n d-lin e pr ocesses.

Look deep into the Chrome


On e w a y t o u n der st a n d t h e a dv a n t a g e t h a t pr ocesses en joy ov er t h r ea ds for m ission -cr it ica l ser v er a pplica t ion s is t o look a t Goog les Ch r om e br ow ser . In desig n in g w h a t t h ey r eg a r d a s t h e per fect br ow ser a r ch it ect u r e, Goog le esch ew ed t h r ea din g . W h y ? Rea d it for y ou r self; it s a com ic, y ou don t h a v e t o be a dev eloper t o g et it .
talkingpdf.org/the-command-line-reliability-never-goes-out-of-style/ 1/4

9/27/13

Command-Line: Reliability Never Goes Out of Style | Talking PDF

T h e sh or t v er sion is t h is: Goog le decided t h a t r elia bilit y w a s k ey . User s w it h 2 0 t a bs open ca n n ot a ffor d t o h a v e t h e br ow ser g o dow n beca u se on e t a b lock s u p du e t o a fr ea k ed-ou t ser v er or som e r u n a w a y clien t -side Ja v a Scr ipt . Ch r om es desig n er s t h er efor e specified t h a t ea ch br ow ser t a b sh ou ld r u n a s a com plet ely in depen den t pr ocess. In a t h r ea ded br ow ser (lik e t h e on e y ou a r e u sin g n ow , if y ou a r en t u sin g Ch r om e), t h er es n o w a y t o isola t e a pr oblem t a b fr om t h e r est of t h e a pplica t ion . Ru n a w a y t a bs ca n ca u se a loss of da t a in ot h er t a bs, or r equ ir e a com plet e r est a r t of t h e a pplica t ion , a n d som et im es, t h e w h ole m a ch in e. T h a t ca n t h a ppen in Ch r om e.

Meanwhile, back on the command-line


Ser v er s sh ou ld be a t LEA ST a s st a ble a s w eb-br ow ser s, don t y ou t h in k ? If r elia bilit y is y ou r w a t ch w or d, t h en lik e Goog les Ch r om e, com m a n d-lin e ser v er soft w a r e deliv er s a k ey a dv a n t a g e: pr ocess isola t ion . If on e in st a n ce of a n a pplica t ion h a n g s du e t o a pa r t icu la r docu m en t , 1 0 ot h er in st a n ces of t h e a pplica t ion ca n ju st k eep on r ollin w h ile a n a dm in ist r a t or t a k es a look a t t h e st u ck in st a n ce. T h er es n o r ea son for a n y a pplica t ion , la r g er pr ocess, or m a ch in e, for t h a t m a t t er , t o g o dow n .

Ease of Administration
W ev e a lr ea dy n ot ed t h a t in t h r ea ded a pplica t ion s, a t h r ea d t h a t st a r t s ea t in g m em or y or pr ocessor t im e a lm ost a lw a y s m ea n s t h a t t h e a pplica t ion m u st be t er m in a t ed. En t ir e ser v er clu st er s a r e con ceiv ed, in st a lled a n d m a in t a in ed pr ecisely t o h edg e a g a in st t h ese a ll-t oo-com m on ev en t s w h er e w h ole a pplica t ion in st a n ces or m a ch in es n eed t h eir pow er cy cled (t o ch ose t h e k in dest of a v a ila ble eu ph em ism s). A dm in ist r a t iv e con t r ol of ea ch pr ocess fost er s r elia bilit y a n d r esilien cy in t h e sy st em ; t h a t s w h a t ea sy a dm in ist r a t ion sh ou ld be a ll a bou t . W h ile t h e a n sw er t o r elia bilit y con cer n s is u su a lly g et m or e m a ch in es , w it h com m a n d-lin e soft w a r e it doesn t h a v e t o be. Sim ply t er m in a t e t h e offen din g pr ocess. Ca lm ly ex a m in e a n d r ect ify t h e pr oblem file or r ecor d w h ile bu sin ess a s u su a l t a k es pla ce a ll a r ou n d y ou . Y ou ca n g et by w it h fa r few er ser v er s if y ou don t h a v e t o con st a n t ly r est a r t t h em ! T h e a dm in ist r a t or s h a v e t h eir r ea son s, bu t pr ocess isola t ion is a ct u a lly a boon for dev eloper s a s w ell, beca u se isola t ed pr ocesses ca n be u sed t o t est ch a n g es in on es ow n code. In depen den t of y ou r ow n code, a com m a n d-lin e t ool ca n be pr ov en t o w or k or n ot w or k , r ig h t t h er e a t t h e com m a n d-lin e. Su ppor t a n d pr oblem -r esolu t ion is g r ea t ly sim plified w h en t h er es n o fu zzin ess a bou t w h ich code is a t fa u lt .

talkingpdf.org/the-command-line-reliability-never-goes-out-of-style/

2/4

9/27/13

Command-Line: Reliability Never Goes Out of Style | Talking PDF

Three Reasons why Command-Line Software Makes Sense for Servers


1. Fu n ct i on a l i sol a t i on m a kes for ea si er a dm i n i st r a t i on a n d m a xi m i zes ser v er u pt i m e Sin ce com m a n d-lin e a pplica t ion in st a n ces a r e com plet ely in depen den t en t it ies w it h clea r fu n ct ion a l defin it ion s of in pu t a n d ex pect ed ou t pu t , t h ey differ fr om t y pica l W in dow s a pplica t ion s w h ich n eed r eg u la r r est a r t s (W in dow s ser v er s a lso n eed r eg u la r r est a r t s, m in im a lly , a ft er ea ch u pda t e T u esda y ). W h en la u n ch in g pr ocesses fr om t h e com m a n d-lin e, y ou don t n eed t o st op t h e ser v er t o m a in t a in or u pda t e t h e a pplica t ion . Y ou don t ev en n eed t o st op t h e a pplica t ion ! 2. Sh or t er dev el opm en t cy cl es, ea si er t o code a n d debu g Sin ce com m a n d-lin e a pplica t ion s pr ov ide a v er y specific set of oper a t ion s; fa ilu r es t o ex ecu t e a r e r ea dily iden t ified. T h r ea din g , sh a r ed DLLs, sh a r ed code a n d ot h er h ou ses-of-ca r ds defy br ig h t lin es delin ea t in g fu n ct ion a l or per for m a n ce r espon sibilit ies. It s h a r der t o debu g a fu n ct ion t h a t r equ ir es dozen s or h u n dr eds of libr a r y ca lls a s com pa r ed t o on e ca ll, a n d t h a t s t r u e ev en if y ou r e r u n n in g pu r e .NET , du de . A n ex a m ple: A dev eloper is t a sk ed w it h pr odu cin g a ser v er pr ocedu r e t o fill a PDF for m . Usin g a t y pica l W in dow s libr a r y , t h e dev eloper h a s t o u n der st a n d, con t ex t u a lize a n d w r it e dozen s or h u n dr eds of libr a r y ca lls t o open t h e PDF, look for fields, ch oose a field, m odify t h e field, fin d t h e n ex t field, a n d so on . W h en som et h in g g oes w r on g , t r a ck in g dow n t h e pr oblem ca n m ea n a lot of w or k . Is t h e pr oblem in t h e libr a r y it self? In t h e dev eloper s code? It s h a r d t o t ell. W it h a com m a n d-lin e a pplica t ion , on e ca ll iden t ifies t h e for m a n d t h e da t a t o be loa ded a n d a n y opt ion s. It s ju st t h a t sim ple, so y ou g et t o focu s on w h a t t h e ov er a ll a pplica t ion is su pposed t o be a ccom plish in g r a t h er t h a n lea r n in g a ll a bou t h ow t o (for ex a m ple) popu la t e fields. Y es, if y ou r e n ot a UNIX , Lin u x or PHP dev eloper , y ou ll n eed t o pa ck a g e u p a st r in g , sh ell t o t h e com m a n d-lin e t h en h a n dle t h e r espon se. T h a t s a g ood t h in g . Com m a n d-lin e soft w a r e a llow s y ou t o focu s on bu sin ess log ic, a n d lea v e t h e g r u n t w or k in t h e ca r e of t est a ble, pr edict a ble, r elia ble, st a n da lon e soft w a r e t h a t ca n fit n ea t ly in t o a n y im plem en t a t ion so lon g a s y ou r e w illin g t o sh ell. 3. A n y dev el opm en t en v i r on m en t , m or e oper a t i n g sy st em s T o oper a t e com m a n d-lin e a pplica t ion s, sim ply pa ss pla in t ex t , pr odu cible by a n y pr og r a m m in g or scr ipt in g la n g u a g e. A com m a n d-lin e a pp doesn t ca r e if y ou r e g en er a t in g y ou r com m a n ds w it h PHP, C, Ja v a , V B or .NET . Or , for t h a t m a t t er , For t r a n , Pa sca l or ev en COBOL! Com m a n d lin e a pplica t ion s a r e en t ir ely a g n ost ic w it h r espect t o t h e ov er a ll dev elopm en t en v ir on m en t . T r y t h a t w it h V isu a l St u dio! A s for t h e oper a t in g sy st em , y ou g en er a lly h a v e m or e ch oices t h a n w it h a n y ot h er opt ion . Com m a n d-lin e soft w a r e is fr equ en t ly a v a ila ble n ot ju st for W in dow s bu t for Lin u x , Sola r is, A IX a n d m or e. Do y ou w a n t t o bet t h a t y ou ll n ev er w a n t t o deploy y ou r im plem en t a t ion on a differ en t set of h a r dw a r e, or t h a t t h e n ex t g u y w h o r u n s it w on t ?

Conclusion
Com m a n d-lin e soft w a r e is cost -effect iv e beca u se it s ea sier t o set u p, ea sier t o debu g , m or e r elia ble t o r u n a n d sim pler t o m a in t a in a n d a dm in ist er . T h e com m a n d-lin e ju st w or k s, a n d let s y ou spen d m or e t im e t h in k in g a bou t bu sin ess object iv es in st ea d of debu g g in g m icr o-lev el libr a r y ca lls. W h ich on e do y ou t h in k y ou r boss w a n t s y ou t o be doin g ? By Duff Johns on
talkingpdf.org/the-command-line-reliability-never-goes-out-of-style/ 3/4

9/27/13

Command-Line: Reliability Never Goes Out of Style | Talking PDF

Com m a n d-lin e A pplica t ion , T h r ea ds

talkingpdf.org/the-command-line-reliability-never-goes-out-of-style/

4/4

You might also like