BUILD&HIGHLY&SCALABLE&ORACLE&ADF APPLICATIONS&

Post on 27-Jan-2022

6 views 0 download

transcript

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

BUILD  HIGHLY  SCALABLE  ORACLE  ADF  APPLICATIONS  Eugene  Fedorenko  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

Eugene  Fedorenko    Master  principal  R&D  architect  

adfpracGce-­‐fedor.blogspot.com  

@fisbudo  

2  

ABOUT  ME  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  3  

WHAT  IS  A  SCALABLE  APPLICATION  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  4  

HEALTHY  JAVA  EE  APPLICATION      Healthy      Unhealthy  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

AGENDA  

JVM  memory  management  

UI  Tree.  The  lifespan  of  ADF  Faces  components  

Memory  scopes.  The  lifespan  of  managed  beans  

ADF  Controller.  Task  flow  ini?a?on.  

ADF  Model.  The  lifespan  of  ADF  Bindings.  

ADF  BC.  The  lifespan  of  Business  Components  

GC  strategies.  Decision  matrix.  

JVM  scaling    

1  

2  

3  

4  

5  

5  

6  

7  

8  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  6  

START  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  7  

THE  HEAP  0    

Hard  Reference   SoZ  Reference   Weak  Reference  

java –Xms:4G –Xmx:8G  

-­‐Xms    

-­‐Xmx    

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  8  

GARBAGE  COLLECTOR  

Mark  

Sweep  

Reachable   SoZly  Reachable   Weakly  Reachable  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  9  

ADF  LAYERS  

ADF  Faces  

ADF  Bindings  

ADF  Data  Controls  

ADF  Task  Flows  

ADF  Business  Components  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  10  

JSF  LIFECYCLE  VS  ADF  PAGE  LIFECYCLE  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  11  

UI  TREE  LIFESPAN  •  Created  on  ini?al  page  request  •  Stored  in  FacesContext  un?l  refresh  or  redirect    

 

 public  class  EditViewBean  {              private    RichInputText  inputText;  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  12  

UI  COMPONENT  REFERENCE  •  Use  ComponentReference  to  hold  the  UI  component  reference  –  Serializable  –  Avoids  hard  references  to  UI  components  

•  Good  enough  for  any  memory  scope    

 

public  class  EditViewBean  {          private  ComponentReference  inputTextReference;                    public  void  setInputText(RichInputText  inputText)  {                inputTextReference  =                              ComponentReference.newUIComponentReference(inputText);          }            public  RichInputText  getInputText()  {                return  (inputTextReference  ==  null  ?  null  :  (RichInputText)  inputTextReference.getComponent());                          }      

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

AGENDA  

JVM  memory  management  

UI  Tree.  The  lifespan  of  ADF  Faces  components  

Memory  scopes.  The  lifespan  of  managed  beans  

ADF  Controller.  Task  flow  ini?a?on.  

ADF  Model.  The  lifespan  of  ADF  Bindings.  

ADF  BC.  The  lifespan  of  Business  Components  

GC  strategies.  Decision  matrix.  

JVM  scaling    

1  

2  

3  

4  

5  

13  

6  

7  

8  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  14  

BACKINGBEAN  SCOPE  •  Exists  for  the  dura?on  of  a  request  •  Each  region  or  declara?ve  component  has  its  own  instance  

 

 

 

Region1  

#{backingBeanScope.sampleBean}  

SampleTaskFlow  

Region2  

#{backingBeanScope.sampleBean}  

SampleTaskFlow  

Request  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  15  

REQUEST  SCOPE  •  Exists  for  the  dura?on  of  a  request  •  Only  one  instance  of  the  scope  across  the  request    

 

Region1  SampleTaskFlow  

Region2  

#{sampleBean}  

SampleTaskFlow  

Request  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  16  

VIEW  SCOPE  •  Lives  longer  than  request  •  Exists  un?l  naviga?on  to  another  view  •  Not  the  same  as  JSF  “View”  scope    

 

SampleTaskFlow  

#{viewScope.view1Bean}  

View1  

#{viewScope.mainPageBean}  

View1   View1   Method  Call1   View2  

#{viewScope.view2Bean}  

Request   Request  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  17  

FLASH  SCOPE  •  Lives  longer  than  request  •  Exists  across  a  single  view  transi?on  •  Survives  redirects    

 

Page  1  

#{flash.transi?onBean}  

Request   Request  

Page  2  

Redirect  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  18  

PAGEFLOW  SCOPE  •  Exists  for  the  dura?on  of  a  task  flow  •  Each  task  flow  has  its  own  instance    

 

SampleTaskFlow  View1  

#{pageFlowScope.sampleTaskFlowBean}  

View1   View1   Method  Call1   View2  

Request   Request  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  19  

SESSION  SCOPE  •  Exists  for  the  dura?on  of  a  user  session    

 

Hmp  Session  Page1  

#{userDataBean}  

Page2   Page2   TaskFlow  Call1   Page3  

Request   Request  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  20  

APPLICATION  SCOPE  •  Exists  for  the  dura?on  of  a  user  session    

 Applica?on  

User  Session1  

#{applica?onDataBean}  

User  Session2   User  Session3  

User  Session4   User  Session5   User  Session6  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

•  Available  for  GC  immediately  •  Used  to  serve  longer  scopes  

21  

NONE  SCOPE        <managed-­‐bean  id="__1">  

           <managed-­‐bean-­‐name>ServingBean</managed-­‐bean-­‐name>  

           <managed-­‐bean-­‐class>view.ServingBean</managed-­‐bean-­‐class>  

           <managed-­‐bean-­‐scope>none</managed-­‐bean-­‐scope>  

       </managed-­‐bean>  

       <managed-­‐bean  id="__2">  

           <managed-­‐bean-­‐name>FlowBean</managed-­‐bean-­‐name>  

           <managed-­‐bean-­‐class>view.FlowBean</managed-­‐bean-­‐class>  

           <managed-­‐bean-­‐scope>pageFlow</managed-­‐bean-­‐scope>  

               <managed-­‐property>  

                   <property-­‐name>servingBean</property-­‐name>  

                     <value>#{ServingBean}</value>  

               </managed-­‐property>  

       </managed-­‐bean>  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

AGENDA  

JVM  memory  management  

UI  Tree.  The  lifespan  of  ADF  Faces  components  

Memory  scopes.  The  lifespan  of  managed  beans  

ADF  Controller.  Task  flow  iniGaGon.  

ADF  Model.  The  lifespan  of  ADF  Bindings.  

ADF  BC.  The  lifespan  of  Business  Components  

GC  strategies.  Decision  matrix.  

JVM  scaling    

1  

2  

3  

4  

5  

22  

6  

7  

8  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

•  Immediate  –  Ac?vates  task  flow  on  ini?al  page  display  –  <…ac?va?on=”immediate”  …>  

•  Deferred  –  <…ac?va?on=”deferred”  …>    –  Applicable  for  Facelet  pages  only  (*.jsf)  –  Enables    lazy  task  flow  loading    

•  Condi?onal  –  <…ac?va?on=”condi?onal”  ac?ve=”#{ELExpression}”…>  –  Ac?vates  task  flow  if  #{ELExpression}  is  true  

<af:region  value=”#{bindings.  bv1.regionModel}”                                                id=”reg1"/>  

23  

ADF  TASK  FLOW  ACTIVATION  

 <taskFlow  id=”bv1”  taskFlowId=”/WEB-­‐INF/…”  

           ac?va?on=”deferred”  />  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  24  

ADF  LAYERS  

ADF  Faces  

ADF  Bindings  

ADF  Data  Controls  

ADF  Task  Flows  

ADF  Business  Components  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  25  

BINDINGS  IN  ADF  LIFECYCLE.  ADF  BINDING  FILTER  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  26  

BINDINGS  IN  ADF  LIFECYCLE.  RESTORE  VIEW  •  Restore  View  •  Apply  Request  Values  •  Process  valida?ons  •  Update  Model  Values    •  Invoke  Applica?on  •  Render  Response  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  27  

BINDINGS  IN  ADF  LIFECYCLE.  RESTORE  VIEW  •  Restore  View              -­‐  Init  Context                  -­‐  Prepare  Model  •  …  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  28  

BINDING  CONTAINER  AT  PREPARE  MODEL  •  Page  Parameters  •  Task  Flow  Parameters  

•  Executables  with  Refresh=prepareModel  – Iterators,  Invoke  Ac?ons      

•  Page  Template    

•  Task  Flow  bindings  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  29  

BINDINGS  IN  ADF  LIFECYCLE.  RENDER  RESPONSE  •  Restore  View  •  Apply  Request  Values  •  Process  valida?ons  •  Update  Model  Values    •  Invoke  Applica?on  •  Render  Response                    -­‐  Prepare  render  (render  Model)  

Refresh=renderModel  Refresh=default  (deferred)  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  30  

ADF  LAYERS  

ADF  Faces  

ADF  Bindings  

ADF  Data  Controls  

ADF  Task  Flows  

ADF  Business  Components  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

•  By  default  loads  all  components  immediately  •  Switch  to  lazy  components  loading  –  java  –D  jbo.load.components.lazily  =  true  –  LoadComponentsLazily  =  true  

31  

ADF  BC  AM  LOADING  

Applica?on  Module  

View  Object  

 Nested  Applica?on  Module  

 

En?ty  Cache  

 En?ty  Object  

 

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

   

ADF  BC  AM  POOL  

32  

U1   U2   U7   U4   U5   U3   U6   U9   U8  

Assigned  to  User  Session   Unassigned  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

ADF  BC  AM  POOL  

33  

   U0   U2   U7   U4   U5   U3   U6   U9   U8   U10   U11   U12   U13  

Recycle  Threshold  

U1  

Passiva?on  Ac?va?on  

Assigned  to  User  Session   Unassigned   In  Use  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

ADF  BC  AM  POOL  

34  

   U0   U2   U7   U4   U5   U3   U6   U9   U8   U10   U11   U12   U13  

Recycle  Threshold  

U1   U14   U15   U16  

Assigned  to  User  Session   Unassigned   In  Use  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

ADF  BC  AM  POOL  MONITOR  

35  

•  Scans  every  jbo.ampool.monitorsleepinterval  ms  

•  Removes  inac?ve  for  jbo.ampool.maxinacGveage  ms    AMs  

•  Tries  to  keep  the  range  jbo.ampool.minavailablesize  -­‐  jbo.ampool.maxavailablesize  

•  AMs  live  not  longer  than  jbo.ampool.Gmetolive  ms  –  Should  be  set  jbo.ampool.Gmetolive  =  -­‐1  

 

 

U0   U2   U7   U5   U3   U6   U9   U8   U10   U11   U12   U13   U1   U14   U15   U16  

Max  Available  Size  Min  Available  Size  

U4  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

ADF  BC  VIEW  OBJECTS  

36  

En?ty  Cache  

 En?ty  Object  

 

Row  Set  

Row  

View  Object  

Applica?on  Module  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

ADF  BC  VIEW  OBJECTS  

37  

 En?ty  Object  

 

Row  Set  

Row  

View  Object  

Applica?on  Module  

Query  Collec?on  Cache  

Query  Collec?on  

Default  Row  Set   Secondary  Row  Set  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

SHARED  QUERY  COLLECTION  POOL  MONITOR  

38  

•  Scans  every  jbo.qcpool.monitorsleepinterval  ms  

•  Removes  inac?ve  for  jbo.qcpool.maxinacGveage  ms    QCs  

•  Tries  to  keep  the  total  weight  below  jbo.qcpool.maxweight  

 

 En?ty  Object  

 

View  Object  

Applica?on  Module  

Query  Collec?on  Cache  

Query  Collec?on  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

ADF  BC  ENTITY  OBJECTS  

39  

•  En?ty  Cache  is    java.u?l.WeakHashMap  

•  Unmodified  en??es  are  weekly  referenced  

•  Modified  en??es  are  strongly  referenced  

 

  En?ty  Cache    

Unmodified  En?ty    

Modified  En?ty  

Query  Collec?on  

DB  Transac?on  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

AGENDA  

JVM  memory  management  

UI  Tree.  The  lifespan  of  ADF  Faces  components  

Memory  scopes.  The  lifespan  of  managed  beans  

ADF  Controller.  Task  flow  ini?a?on.  

ADF  Model.  The  lifespan  of  ADF  Bindings.  

ADF  BC.  The  lifespan  of  Business  Components  

GC  strategies.  Decision  matrix.  

JVM  scaling    

1  

2  

3  

4  

5  

40  

6  

7  

8  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  41  

GENERATIONAL  PARALLEL  GARBAGE  COLLECTOR  Nursery (Young Generation) Tenured (Old Generation)

Young  CollecGon  

Old  CollecGon  

Reachable   SoZly  Reachable   Weakly  Reachable   Garbage  

0

-Xns -Xmx

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  42  

CONCURRENT  GARBAGE  COLLECTOR:  MARK  

2.  Concurrent  Marking  

1.  IniGal  Marking  

3.  Precleaning  

4.  Final  Marking  

-Xns

-Xmx

Weakly  Reachable  SoZly  Reachable  Reachable   Garbage  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  43  

CONCURRENT  GARBAGE  COLLECTOR:  SWEEP  

1.  Sweep  first  half  

2.  Switch  halves  

3.  Sweep  second  half  

4.  Synchronize  

Reachable   SoZly  Reachable   Weakly  Reachable   Garbage  

-Xns

-Xmx

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  44  

GC  POLICIES  •  Parallel  Garbage  Collector  –  High  performance  between  collec?ons  –  Short  collec?on  dura?on  but  long  pauses  –  Good  for  applica?ons  with  high  throughput  requirement.  Batch  processing.  

•  Concurrent  Garbage  Collector  –  Sharing  CPU  between  GC  and  Java  threads  –  Long  collec?on  dura?on  but  short  pauses  –  Good  for  applica?ons  sensi?ve  to  long  pauses.  Transac?on  based  systems  

•  Single-­‐genera?onal  Garbage  Collector  –  All  garbage  is  collected  at  once  –  Good  for  set  of  stable  long  living  objects  

•  Two-­‐genera?onal  Garbage  Collector  –  Short-­‐living  objects  live  short  –  Good  for  applica?ons  with  large  number  of  temporary  objects  

 

 

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  45  

WHAT  IS  GOOD  FOR  ADF?  

Sensitive to long pauses?

Yes No

A lo

t of

tem

por

ary

obje

cts?

No

Yes

Generational Concurrent

-Xgc:gencon

Single Concurrent

-Xgc:singlecon

Generational Parallel

-Xgc:genpar

Single Parallel

-Xgc:singlepar

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

500  users  per  JVM  4g  Heap  

46  

VERTICAL  AND  HORIZONTAL  SCALING  

Copyright  ©  2014,  eProseed  and/or  its  affiliates.  All  rights  reserved.  |  Confiden?al  

Q&A  

JVM  memory  management  

UI  Tree.  The  lifespan  of  ADF  Faces  components  

Memory  scopes.  The  lifespan  of  managed  beans  

ADF  Controller.  Task  flow  ini?a?on.  

ADF  Model.  The  lifespan  of  ADF  Bindings.  

ADF  BC.  The  lifespan  of  Business  Components  

GC  strategies.  Decision  matrix.  

JVM  scaling    

1  

2  

3  

4  

5  

47  

6  

7  

8