TELKOM NIKA , Vol. 11, No. 10, Octobe r 2013, pp. 6 068 ~ 6 073   ISSN: 2302-4 046           6068      Re cei v ed Ma rch 2 4 , 2013;  Re vised July  12, 2013; Accepted July 2 3 ,  2013   An Architecture to Implement Event-Driven Web  Monitoring Systems      Gao Ying* 1 , Mu Lei 2 , Hao  Zhonghu 3 , Zheng Weiy a n g 4   1 School of Co mputer Scie nc e and En gi neer ing, Sout h C h i na Un iversit y  o f   T e chnolo g y  G uan gzh ou,  510 00 6, Chin a   2 Shang do ng Pr ovinci al C o mm unic a tions Pl an nin g   an d Desi g n  Institute Jina n, 2500 31, Ch i n a   3 School of Co mputer Scie nc e and En gi neer ing, Sout h C h i na Un iversit y  o f   T e chnolo g y  G uan gzh ou,  510 00 6, Chin a   4 Information C enter R&D D e p a rtment, Chin a  Souther n Air l i nes Com pan Limite d Guan g z hou, 51 04 06,  Chin a   *Corres p o ndi n g  author, e-ma i l : gao yi ng@sc ut.edu.cn, 13 9 531 96 967 @16 3 .com,  haoz ho ngh ud e @ 16 3.com, zheng w y @ csa ir.com      A b st r a ct  Traditional m o nitoring  system are bas ed on C/S  mode beca use  desktop software still has   inh e rent  adv a n tages  tho ugh  deskto p  soft w a re is re pl ac ed  by w eb  ap plicati ons  rap i dly i n   ma ny fi elds.   Meanw hi le, tra d itio nal  mo nito ring syste m use rel a tio nal  datab ase as  d a ta source, h o w ever, relatio n a datab ase  lacks  the ab ility to  process  influx  of quer ies  per  secon d . In this  pap er, w e  w ill  do a n  i n -de p t h   researc h  to design an archit ecture to im plem ent event-dr i ven web monit o ring system s.     Ke y w ords : ev ent-driv en, Co met, bay eux, Esper     Copy right  ©  2013 Un ive r sita s Ah mad  Dah l an . All rig h t s r ese rved .       1. Introduc tion  The mo st i m porta nt re q u irem ent of  moni tori ng  system i s  p r ocessin g  ev ents  (or  messag es) in  real-time o r  near re al-ti m e. Key  conside r ation s  fo r monitori ng  appli c ation s  are  latency, throu ghput an d co mplexity of th e logic requi red [1].  Low late ncy-appli c ation s  that rea c t in real -t ime to con d ition s  that occur (f ro m a few  milliseconds t o  a few seconds)  High  through put-ap p licatio ns th at p r o c e s s la rge  volu mes of m e ssage (bet wee n  10 00  to  1000 0 messa ges p e r seco nd)  Compl e x co mputation s -a pplication s  th at det e c t pat terns am ong  events, filter events,  aggregate  ti me o r  l ength  win d o w s of  events,  join  e v ent stream s,  trigger ba se d on absen ce o f   events etc.   To implem en t a real-time  or nea r re al-time web  monitori ng systems, the s e three   requi rem ents  must be met. Con s e quently , two proble m s app ear:     1.1. Ho w   to  Push Ne w   D a ta fr om Serv ers to Bro w sers Instantl y ?   It’s easy for d e sktop software to meet the re q u ire m e n t of low latency be cau s softwa r has an i nhe rent a d vanta ge in  pu shi ng in stant  mess ages to c lients  but diffic u lt for web  appli c ation s becau se tradi tional web  ap plicatio ns   are  re stri cted to  Req u e s t/Re s pon se p a ttern This limitatio n of HT TP protocol  l ead serve r s not b e  able to  pu sh data to  clie nts. That’ s  why   most monito ri ng syste m s a r e ba se d on  C/S mode th ough  web a p p licatio ns a r e  taking pla c e  of  desktop software  rapidly  in recent  years.     1.2. Ho w   to  Process  L a rge Volum es of  Mes s a ges  and P e rform  Com p lex Co nditi o n   Chec king Efficiently ?   Usually, appl ication s  u s e  relational d a taba se a s  data so urce.  However, relational   databa se a n d  SQL are  de signed fo r app lication s  in  which m o st d a ta is fairly stat ic and  co mpl e queri e are l e ss fre quent.  To ret r ieve d a ta from  da tabase, an a pplicati on mu st issue  a qu ery.  Always, usi n g relation al databa se in monitorin g   syst ems, you ne ed to periodi cally poll for state   cha nge s. Thi s  po or d e si g n  puts  a lot  of strain  on b o th we b serv er an d data b a se,  co sting  you   Evaluation Warning : The document was created with Spire.PDF for Python.
                               ISSN: 23 02-4 046   TELKOM NIKA  Vol. 11, No . 10, Octobe r 2013 : 606 8 –  6073   6069 CPU  cycl es,  band width, a nd a d e cre a se in pe rforma nce.  Datab a se trigg e rs ca n be u s e d  to  fire  in re spo n se to datab ase u pdate eve n ts  but they  tend  to be sl ow  an d often cann o t  easily pe rform  compl e con d ition  che c ki ng a nd i m ple m ent lo gic to  re act [2]. So  rel a tional  da tabase d o e s   not  apply to moni toring sy stem  in which influ x  of data need be pro c e ssed in a sh ort perio d.  This  pap er i s  going  to giv e  an i n tro d u c tion to ho w t o  solve the s e  pro b lem s  a n d  then  de sig n  an  architectu re t o  impleme n t event -d riven  web mo nitori ng syste m s.       2. Solutions and Primar y   Architec ture   2.1. COMET   To solve p r ob lem n INTRO D UCTYIO N, two metho d are wi dely ap plied [3]:     With the  h e lp  of pl ug-i n s (su c as flash ,  applet  or ActiveX) install e in  browse rs, se rvers  ca push ne w dat a instantly by so ckets [4] [5].    Client  bro w sers send  Aja x  [6] [7] requ est to  se rver  at reg u la r int e rvals to  che c k whethe r t h e   serve r  ha s go t new data [8].  Ho wever, th ese t w o m e thods  have  their o w p r oble m s. T h e first m e th od ha s   comp atibility issue be cau s e not all the browse rs  su pport the plu g -in s . The b e st co ndition  to   reali z e the  seco nd meth o d  is the p o lli ng interval are e qual to  the se rver’ s   update inte rv als ,   otherwise, it not only ca n’t meet the  real -tim e re quire ment s b u t also  re sul t s in waste  of  r e sour ces .   Re cently, a web ap pl ication mo d e l named  “Com et”  in whi c a long- lived  HTTP  conne ction all o ws we b se rvers to pu sh  data to bro w sers witho u t plug-in s is  more  popul ar. Spe c ific m e thod s of implem ent ing Comet fal l  into two  maj o categ o rie s :  stre aming  a n d   long pollin g [9].     2.2. Ev ent-Dr i v e n Archite c ture   In a world (such a s  monit o ring  system ) f illed with events and in stant com m u n icatio n,  traditional  da tabase i s  n o t  approp riate .  Con s e que n t ly, event-dri ven ar chite c t u re (EDA ) was   prop osed [1 0 ]. In an eve n t -driven  archi t ecture,  an  i m porta nt thin g ha ppe ns in side  or out si de   your b u si ne ss, which di sseminate s  im mediately to  all intereste d   partie s . Th e i n tere sted  pa rties   evaluate the  event, and  optionally t a ke  actio n . The event -driven actio n   may inclu d e  the  invocatio n  of  a  se rvice, t he tri gge ring  of a  bu sin e s s p r o c e ss.  A cla s sical E D works li ke a  databa se tu rned u p si de-d o wn. In stead  of stori ng t he data  and  run n ing  qu erie s, it allo ws  appli c ation s  to store que ri es an d ru n the data  thro ugh. With E D A, appli c ations  can tri g ger  action s when  event con d itions  o c cu r am ong event  streams, p e rf o r m compl e x condition  che c king  and impl em ent logi c to  rea c t qui ckly. So, EDA can b e   use d  to sol v e Problem  in   INTRODUCT I ON.    2.3. Primar y   Architec ture   On the  ba sis  of Com e t and  EDA, a  syst em  archite c tu re to im plem ent event-driv en web  monitori ng sy stem s ca n be  desig ned p r i m arily as Fig u re 1.           Figure 1. Primary archite c ture         Evaluation Warning : The document was created with Spire.PDF for Python.
TELKOM NIKA   ISSN:  2302-4 046     An Archite c tu re to Im plem e n t Event-Dri ven We b Moni toring System s (G ao Ying)  6070 This p r ima r y architectu re  can be divide d  into three pa rts:    The monito rin g  appli c ation s  for captu r ing  event strea m s.    The event-dri ven archite c ture for filte r in g,  analyzin and p r o c e ssi ng the  event  strea m s from  the monitori n g  appli c ation s     The we b app lication s  for showi ng re al-ti m e inform ati on to use r s. This pa rt incl ude s Com e t in  serve r  an d Comet in client  browse r.       3. An Actual  Application and Detailed Solution  We h a ve al re ady implem e n ted a  we b m onitorin g  syst em  by  the architecture said   above.  In this section, we will gi ve a detailed solu tion  by descri b ing  how to realize the monitori ng  system. Firstl y, we give the list of tools, method s, platforms o r  protocol s we use d  as follo wing  MyEc lipse6.5 with J D K1.6   Tomcat 6 (Co m et-Fri endly  serve r  Oracle (Yes.  Relational dat abase is  st ill used. We will  give the reason later)   Bay eux  (Prot o col for  Com e t)    Espe r (a light weig ht, embe ddabl e open  sou r ce imple m entation  of  EDA)  Some of the m  are familia r whil e othe rs are not. Secon d ly, we in trodu ce Baye ux and  Es per.    3.1. Ba y e ux  Protocol   The Bayeux  Protocol defines  usi n g long pollin g approach [11].  HTT P  requests sent from  the client are hold on  on the  se rver till the requests  can  be fully  answere d. This  protocol   provide s   a flexible, sal e a b le API ba se d aroun d a p ublish/su bscri be mo del. In  our  monito ri ng  system,  we  make  serve r   to be p ubli s h e r a nd  client  to be  su bscribe r . Me ssa ges  en cod e d  as  JSO N  obje c ts are ro uted via cha nnel s.   Server sid e   impleme n tations ne ed to  use n o n - bl ocking  IO  (NIO) to g u a r antee  an   efficient im plementation.   So we  cho o se tom c at  6 ( can b e   set to   sup port  NIO )  as  serve r . S o me   Java librarie s  need to be importe d. The y  are “C o m et d-api.ja r”, “Comet d-bayeu x.jar” and “j etty- until.jar”. T h e n  the  web  se rver  can  pu bl ish topi cs. F o r exam ple, t he follo wing   cod e  pu sh es a   JSO N  obje c t named  ”total”  via channel  “/Mana ge/cal” to Browsers:     ServletContext application= this .getServletContext();  Bayeux b= (B ayeux)application.getAttr ibute(Bayeux.DOJ OX_COMETD_BAYE UX);   Cha nnel c=b.getCh ann el(“/ Manag e/cal ,true );  // ……  c.publi s h ( u s e r Id,total,”total”);     To impleme n t  Comet at client side, we us e a Jav a Scri pt library-“doj o”. The n  client  bro w sers  can  sub s crib e in tereste d  topi cs from th e chann els. Fo example, the  followin g  co de  receives the  messag e the serve r  pu sh e d   <script src=”d ojo-rele ase - 1. 1.2\dojo\doj o.js”>  djCo nfig=”isDebug:fal s e,pa rse O nL oad:true”>  </ s c ript >   // ……  dojo.re qui re(“dojox.com etd ”);   dojox.com etd . init(“cometd );  dojox.com etd . sub s cribe (“/ Manag e/ca l , c urre ntPro c e s sor,”total ”);     3.2. Esper   Espe r i s  a   Java library th at ca n b e  i n tegrate d  into   multiple a ppli c ation s   devel oped  by  Java. In Esp e r, event can  be map, PO JO a nd XML.  Espe r offers an event p a ttern lang uag (EPL) to spe c ify expre ssi on-b a sed ev ent pattern  matchin g . Th is metho d  of event pro c e ssi ng   matche s exp e cted   seque n c e s   of pre s e n c e or ab se n c e of event s o r  com b i natio n s  of  events. E P L   can al so be  use d  to provide the wind o w s, agg re gati on, joining a nd analysi s  functio n s for  use  Evaluation Warning : The document was created with Spire.PDF for Python.
                               ISSN: 23 02-4 046   TELKOM NIKA  Vol. 11, No . 10, Octobe r 2013 : 606 8 –  6073   6071 with  stre ams  of events.  EPL ha s be en  d e sig ned  for si milarity with  t he SQ L q u e r y langu age.  F o r   example, an  event (POJO) is defined a s   publi c  cla s s CardEvent implement s Seri aliza b le{     private String  from;    private String  to;    private Do ubl e amount;     Then, the followin g  statem ent can b e   used to do som e  relevant sta t istics:     sele ct   c o unt(*) as  noOfCard, s um(amount) as  total,  avg(am ount) as  average   from CardEv ent.win:time(15 s e c ) ;     With the  hel p of EPL, E s per implem e n ts a  pe rfe c t EDA.  When  larg e influx   of event  strea m com e  to Esper, T he EPL state m ents p r ev io usly define d  judge  whethe r the event stream  matche s th EPL. This m e thod  of eve n t pro c e s si ng  match e s exp e cted  sequ en ce s of  pre s e n ce   or ab sen c of events or  combi nation s  of ev ents. Lastly, Esper  outputs PO JOs. In additi on,  Espe can  al so a c cess with  the  histo r ical  datab ase, a   databa se  em bedd ed i s   used to  en su re t he  con s i s ten c y of the data  with the extern al datab ase.  If nece s sary,  Espe can  combine  the d a ta  strea m  and hi stori c al data t o  do com p lex  processin g  (That’s  why we use d  Ora c l e ).     3.3. Detailed  Solution  On the ba sis  of Bayeux and Espe r, A detail ed sol u tion  can be d e si g ned a s  Figu re  2.          Figure 2. Det a iled solution       The fun c tions of compon en ts in the whol e system:     Monitori ng a pplication s  (such  as sca n n i ng eq uipme n t ) are  compo nents fo cap t uring   events.     Adapters: Th ey are respo n sibl e for de fining EPL st atements to  filter, analyze  and  pro c e ss the d a ta delivere d  from monito ri ng appli c atio ns.     Espe r Li sten er: Th ey are  desi gne d to  be a tta che d   with the  stat ement in  “Ad apters”,   whe n  the sta t ement evalu a tes to true,  “E sp er Li sten er”  will be tri ggered an output  P O JO s.    Acce sslaye r: It is for comm unicating with  the histori c al  databa se.     Comet Li sten er: This  com pone nt is for listening to Espe r com p o nents a nd re ceiving   POJOS from  the Espe r co mpone nts.   Evaluation Warning : The document was created with Spire.PDF for Python.
TELKOM NIKA   ISSN:  2302-4 046     An Archite c tu re to Im plem e n t Event-Dri ven We b Moni toring System s (G ao Ying)  6072   Comet Handl e:  A  thread  pool that con t ains several  thread s that is named “Come t   Han d le Th re ad”. Th ese thread re ceive  and ha ndle  asyn chrono u s  re que sts from the   client browse rs.    Web a ppli c ati on is for di spl a ying data on  browse rs.  The m o st i m portant i nnov ative point  of this  archite c t u re i s   co mbin g EDA  and  Comet to  impleme n t event-d riven we b monitori ng  system s.       4. Architectu r e Analy s is  4.1. Adv a ntages    Good p e rfo r mance   We di d expe riments to te st our mo nitori ng sy stem. T w o time  gap s we re record ed: the  time gap betwee n  monitoring appli c atio n and the ev ents we re p r oce s sed ove r  by Esper (si m ply  recorded a s  “process eve n t time gap”), the time gap betwee n  Espe r and di splaying data  to   use r s(record ed a s  “rea ct time gap”). The expe rim ents h a ve b een d one fo r 1000 time s.  We   sele cted rand omly 10 re cords an d sh ow  them in Table  1.      Table 1. 10 Reco rd s of 100 0 Times  No.  Process event time gap  React time gap   Time gap   1 25ms  119ms  144ms  2 17ms  121ms  138ms  3 20ms  110ms  130ms  4 15ms  107ms  122ms  5 17ms  119ms  136ms  6 19ms  105ms  124ms  7 17ms  104ms  121ms  8 24ms  110ms  134ms  9 25ms  103ms  128ms  10 27ms  117ms  144ms  Average  20.6ms  111.5ms  132.1ms      The average  time gap of the 10 record s is  13 2.1m s, and the ave r age time g a p  of the  1000 time s is 131.5ms  whi l e 50 EPL sta t ements a r i n clu ded in ou r system a nd  10 of them are   compl e x que ries. It mean s that the architecture we  desi gne d can  pro c e ss  eve n ts an d di spl a new  data to  client s in sta n tly. Good p e rform a n c e i s  the m o st i m porta nt adv antage  of this  architectu re.    Good  comp atibility  Espe r i s  light weig ht. It’s e a sy to  be i n tegrate d  into  the exi s ting a pplication s  d e velope d   by Java. Bay eux ca n be  u s ed to  any browsers  sup p o rted Ajax, a nd many  se rvlet-su ppo rting  and  NIO-su ppo rting se rvers.    No firewall res t ric t ions  The archite c t u re i s  ba sed  on stan da rd  H TTP  po rts (80  and 443 ) and  HTTP protocol. So,  it can wo rk b ehind the fire wall s.    4.2. Problem and Analy s is   Scalability Problem   In this archite c ture, the we b serve r  nee ds to kee p  a long co nne cti on with ea ch client to   achi eve serv er-pu s h. Whe n  the nu mbe r  of con c u r ren t  clients i s   sm all, this archit ecture  can  work  norm a lly. Ho wever,  when  the numbe r is very big,  it’s hard to load. In this  scena rio, loa d ing  balan ce a nd  clu s ter te chn o logy ca n be  con s id ere d   Evaluation Warning : The document was created with Spire.PDF for Python.
                               ISSN: 23 02-4 046   TELKOM NIKA  Vol. 11, No . 10, Octobe r 2013 : 606 8 –  6073   6073 5. Summarize and Prosp ects   This archite c t u re  uses Co met and  EDA to  imple m e n t an  event-d riven  web  m onitorin g   system. In fact, it can  be appli ed to many  we b  application s  of high rea l -time dem a nd.  Con s e quently , the archite c t u re introdu ce d in this pap e r  is valuabl e.   In write r s’ opi nion, Comet i s  o n ly an i n te rim te chn o log y  to reali z e t w o-way  com m utation   between web  servers  and browsers.  HT ML5 will  become stand ard of all browsers i n  the near  future. At that time, Comet in the archite c tu re  we de si gned  can b e  repla c ed by “Web so cket”.       Ackn o w l e dg ment  The Pap e r i s  supp orted  by Nation a l  Natural Science Fou n d a tion of Chi na No.  5120 4071;   Scien c an d Te chn o lo gy Plannin g  Proj ect  of Gu an gdon g Pro v ince  (201 2B01 010 0019 ). Mini stry of Edu c ati on Univer sity-Indu stry-Re s earch P r oje c t  of Gua ngd o n g   Province (20 10B090 400 5 35) an d The  Funda mental  Re sea r ch Fu nds fo r the  Central Universities  (201 12M 006 8).       Referen ces   [1]  Kim, Yan g  S o k. Usin g kn o w led ge  bas e fo r eve n t-drive n  sche dul in g of   w e b mo nitori ng s y stems .   Lecture N o tes i n  Co mp uter Scienc e . 200 9; 5692: 16 9-1 80.   [2]  Shans ha n Li, Jian Z h o u T r ansmitter Station Remot e  Monitor S y stem  Based on Br o w ser /Serve r   Structure.  T E LKOMNIKA Indones ian J ourn a l of Electrica l  Engi neer in g . 2013; 11( 3): 159 4-15 99.   [3]  Liji ng   Z han g, W e i Xio ng, Xu ehu i Xi an.  R e s earch  on  W eb- base d  R eal-tim e Mo nitori ng S y stem  on  SVG   and C o met.  T E LKOMNIKA Indon esia n Jour nal  of Electric al  Engin eeri n g . 2 012; 10( 5): 114 2-11 46.   [4]  Pohj a, Mikko. Server pus h fo w e ap pl icati ons via i n stant  messagi ng.  J ourn a l of W e b  Engin eeri n g 201 0; 9(3): 227 -242.   [5]  CHEN Ha ng,  Z H AO F ang. Impleme n tatio n  of  w e b insta n t  message s y s t em based  on  server push   techno lo g y  and   XMPP.  Co mp uter Engi ne erin g and D e si gn . 201 0; 31(5): 83 -88.   [6]  Z hou  Xu an,  W ang L i -fan g, JIANG Z e -ju n . Desi gn  an d Implem entat ion  of AJA X - base d  Instant   Messag i ng S y s t em.   Science T e chno logy  an d Engi ne erin g . 200 9; 9(2): 446 -449.   [7 L I  Xi an -j un , L I U  Bo , YU D an, MA Sh i - lo ng . Mix e d C / S and  B/S a r ch i t e c tu re  pa tte rn   b a se d   o n  AJAX Journ a l of Com puter App l i cati ons. 200 9; 19( 4): 1135- 11 38.   [8]  Yuan yu a n  Li ao , Z hen yu Z h an g, and  Yan q i n g  Yang. W e b Ap plicati ons B a se d on  Aja x  T e ch nol og a n d   Its Framew ork.   Communic a tio n s in Co mputer  and Infor m ati o n Scienc e . 201 2; 288(1): 3 20- 326.   [9]  XU  Xiu-h ua,  W E N Bi-lon g, LIU Da n-Jia ng,  BI  Shuo-b en. A  realiz atio n me thod  of inst ant messa gin g   base d  on  w e b.  Co mp uter Engi neer ing a nd D e sig n . 200 3; 24(7): 40-4 2 [10]  Lever agi ng  Ev ent Driv en  Arc h itectures  http:// onepi xel ahe a d .com/201 0/08 / 11/lever agi ng- event-dr i ven- architectures/.  [11]  T he Ba y e u x  S pecific ation  http://svn .Cometd . com/trunk/ba y eu x/ba ye u x .ht m l.    Evaluation Warning : The document was created with Spire.PDF for Python.