0

ZK Session Memory Consumption

asked 2007-08-29 15:34:57 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4490829

By: hgrongst

Hi. We are a State Agency making an evaluation of several rich user interface frameworks. We have developed a set of evaluation criteria that we will use in the final selection of a framework. At this point we have reduced the candidates down to ZK, GWT and Wicket. Additionally, we are currently using JSF as our main view technology in front of a stack consisting of Spring and Hibernate as well as a layered architecture (view, services, domain, data access)

ZK looks like a very good candidate and our team agrees that it has a very capable set of components and the development paradigm are straight-forward.

One major challenge we face now, is understanding ZK's memory consumption.
Readings in this forum has caused concern. We have run several tests*(see below) that shows ZK using a relatively large amount of memory. During the tests we followed instructions to include directives to have ZK use the Servlet thread to avoid duplication, and we also followed other suggestions for tuning ZK.
We have read the threads in this forum where other users have raised questions in regards to memory and scaling. However, there doesn't seem to be any satisfactory explanation of these matters. In particular we would appreciate having the following questions answered.

1. How does ZK manage the memory for an application for a given user (session?) 2. In JSF, as an example, you can specify how many page views to cache when using the server side memory model. In Wicket, only the current page is kept in memory(according to discussion threads). How does ZK handle these issues?
Can you free up memory for components that are not on the current page? What is the design/architecture of ZK in this regard?
3. If memory consumption is already an "issue", is there plans to improve this in the near future?

We do understand that richness of components comes with a price, so we haven't ruled out using ZK; memory is cheap. However, we need to be able to understand this and how to calculate what our memory needs would be if we use ZK. Our current production environment is a WebSphere cluster with 4 instances of the WAS server behind two WEB servers which in turn sits behind a L4 switch. Each app server instance has 2GB of memory.
Thanks in advance.


* We ran this test on a WebSphere Application Server version 6.1.0.2 which sat on a Dual Core T2600 2.16 GHz 2GB RAM running WindowsXP. We used Apache JMeter
2.2 to simulate threads.

We built the same page JSF then in ZK (both pages accessed Spring beans from the Spring context and loaded data into lists) and used the JSF as an indicator to measure against (knowing this is not totaly fair nor scientific), but it servers as a reference. ZK crashed the server at about 240 users logging in to the page. With JSF memor increased but stabilized and the server did not crash.


We added a zk.xml to the web-inf folder with the following xml (However we're not sure if Zk automatically looks for zk.xml:

<?xml version="1.0" encoding="UTF-8"?>
<zk>
<system-config>
<disable-event-thread/>
</system-config>

<session-config>
<timeout-uri>/timeout.zul</timeout-uri>
</session-config>
</zk>


The code for the zul page follows below
-----------------------------------------
<?xml version="1.0" encoding="windows-1251"?> <?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<window title="Case Worker Menu">

<zscript>
import gov.utah.dhs.dspd.aims.biz.IPersonService;
import gov.utah.dhs.dspd.aims.biz.IConsumerService;
import gov.utah.dhs.dspd.aims.domain.Party;
import gov.utah.dhs.dspd.aims.domain.Person;
import gov.utah.dhs.dspd.aims.domain.Message;
import gov.utah.dhs.dspd.aims.dto.CaseLoadList;
import java.util.List;

Person currentUser = securityService.getCurrentUser();
int page = 0;
List messages = personService.doGetMessages(currentUser, page);
List caseLoad = consumerService.findCaseLoadList(currentUser.getId());
List users = personService.doFindUsers();

void add(){
System.out.println("Sending message: " + messageText.value);
System.out.println("CurrentUser: " + currentUser.formattedName);
System.out.println("CurrentUser: " + currentUser.id);
personService.doSendPersonMessage(currentUser.formattedName + ": " + messageText.value, currentUser.id);
Message m = new Message();
m.setMessage(messageText.value);
Listitem li = new Listitem();
li.setValue(m);

li.appendChild(new Listcell(messageText.value));
box.appendChild(li);
}

void showConsumer(){
System.out.println("Clicked on row");
CaseLoadList cl = (CaseLoadList) abc.selectedItem.value;
System.out.println("CaseLoad for " + cl.getId());
abc.setVisible(false);
myCaseLoad.setVisible(false);
consumerMain.setVisible(true);
cpd.setVisible(true);
}
</zscript>

<hbox >
<vbox >
<separator orient="vertical" spacing="10px" /> <label value="Messages for ${currentUser.formattedName}"/>
<groupbox width="258px" style="background-color: #74949b;">
<vbox>
<textbox id="messageText" width="248px" rows="3" />
<hbox>
<label value="To" />
<combobox autodrop="true">
<comboitem forEach="${users}" value="${each}" label="${each.name3}"/>
</combobox>
<button label="Send" width="36px" height="24px" onClick="add()" />
</hbox>
</vbox>
</groupbox>
<listbox id="box" multiple="true" >
<listhead >
<listheader label="Messages" width="250px" />

</listhead>
<listitem forEach="${messages}" value="${each}">
<listcell label="${each.message}" />
</listitem>
</listbox>
</vbox>

<vbox id="cl" >

<separator orient="vertical" spacing="10px" /> <label id="myCaseLoad" value="Case List" /> <label id="cpd" value="Consumer Personal Data" visible="false" />
<listbox id="abc" multiple="true" rows="5" >
<listhead>
<listheader label="HLCI" width="80px" />
<listheader label="Name" width="110px" sort="auto" />
<listheader label="D.O.B." width="80px" sort="auto" />
<listheader label="Gender" width="50px" sort="auto" />
<listheader label="Status" width="80px" sort="auto" />
<listheader label="Service Type" width="100px" sort="auto" />
<listheader label="Tasks" width="250px" />
</listhead>
<listitem forEach="${caseLoad}" value="${each}" onClick="showConsumer()"
>
<listcell label="${each.HLCI}" />
<listcell label="${each.formattedName}" />
<listcell label="${each.dob}" />
<listcell label="${each.gender}" />
<listcell label="${each.statusTypeID}" />
<listcell label="${each.disabilityType}" />
<listcell label="${each.tasks}" />
</listitem>
</listbox>
<groupbox id="consumerMain" visible="false" >

<hbox>
<groupbox id="addresses" >
<vbox>
Addresses
<label value="Residence: 123 Iowa Street" />
<label value="Mailing: P.O. Box 123, Salt Lake City UT 84120" />
</vbox>
</groupbox>
<groupbox id="phones" >
<vbox>
Telephones
<label value="Primary: 123-456-7890" />
<label value="Cell: 987-456-7890" />
</vbox>
</groupbox>
<groupbox id="statuses" >
<vbox>
Statuses
<label value="Intake 05-15-2007" />
<label value="Decision 05-19-2007" />
<label value="Waitlist 06-30-2007" />
</vbox>
</groupbox>
</hbox>
</groupbox>
</vbox>
</hbox>
<button label="JSF Version"
href="http://localhost:9080/usteps/faces/menus/CaseWorkerMenu.jsp" /> </window>

delete flag offensive retag edit

13 Replies

Sort by ยป oldest newest

answered 2007-08-30 02:33:34 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4492014

By: henrichen

Hi hgrongst,

>1. How does ZK manage the memory for an application for a given user
>(session?)

ZK kept the Java components in session for a given user.

>2. In JSF, as an example, you can specify how many page views to cache
>when
using the server side memory model. In Wicket, only the current page is kept in memory(according to discussion threads). How does ZK handle these issues?
Can you free up memory for components that are not on the current page? What is the design/architecture of ZK in this regard?

ZK kept only the current page (we call it a Desktop) in session memory. Whenever end users browse to another Desktop (URL) or close the browser, the ZK client engine at browser side will fire an event to notify the Desktop at the server side to destroy itself and the Desktop will be detached from the session. Besides that, whenever any single component is detached from the desktop (setParent(null) or setPage(null)), that component along with its children components is detached from the session. They will be GCed by Java VM automatically unless the application itself still hold some references to them. There are also SessionCleanup and DesktopCleanup interface that you can implement listeners to clean up whatever for the application specific memory. Please see our Developer's guide and Developer's reference guide for details.

You did not mention which version of ZK you are testing but there is a memory leak caused by BeanShell(used in zscript and onXxx) before version 2.4.1. We have fixed this memory leak issue in 2.4.1 (See bug 1736858)

>3. If memory consumption is already an "issue", is there plans to
>improve this
in the near future?

Our senior engineer Dennis Chen is handling this and we have pinpoint some bottleneck, so you will see some performance boost on our next major release(expect to be released next couple weeks). He will also publish some articles regarding memory consumption and performance tuning. If you provide us your email, he might update you some information beforehand (Please send email to dennischen AT zkoss DOT org).

>... However we're not sure if Zk automatically looks for zk.xml

Yes. ZK read the zk.xml automatically. And the syntax for <disable-event-thread> is correct.

BTW, though <zscript> is good when prototyping but it is much slower than compiled Java class. If possible, it is better to rewrite them. The same condition applies to onXxx. For details please refer our performance section in Developer's guide.

We will see if we can use your example codes and do some experiment here.

I hope the above information is helpful. Should you have other questions, please don't hesitate on asking. We think that is why open source rocks. Good ideas are sparked in fully open discussion.

/henri


link publish delete flag offensive edit

answered 2007-08-30 14:45:31 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4492845

By: hgrongst

Thanks Henri, your response was very helpful and I will look further into understanding the memory clean-up techniques you referred to in the dev materials.

link publish delete flag offensive edit

answered 2008-11-19 05:06:46 +0800

afigueroa gravatar image afigueroa
9

What Security Framework you are planning for the application?

link publish delete flag offensive edit

answered 2008-11-19 13:54:08 +0800

ibsolution gravatar image ibsolution
468 1 1 6

btw do not forget to accommodate old component that zk has.

i hope for next major version i can also use that

Regards,

Andy Susanto

link publish delete flag offensive edit

answered 2012-08-09 13:41:09 +0800

vinayakshukre gravatar image vinayakshukre
36

updated 2012-08-09 13:42:27 +0800

Hello,

I understand that this thread is 5 year old but I still want to raise my issues related to same topic.
We are trying to evaluate ZK for writing our enterprise application where we want to support 10000 concurrent users. For evaluation purpose, we have written a ZUL page which looks like MS Outlook screen. ( With ZK, I must tell that it was quite easy to develop this page.) This page has components like Grid ( for showing list of emails), accordion menu, tree,many icons, window, labels, textbox, radio buttons, checkboxes used in it. Page is showing 200 rows of emails with 5 columns.
We are using StresStimulus extension of Fiddler to hit this web application which is deployed in Tomcat 6.x with min memory 500Mb and max memory 1 GB. We are hitting this URL 5 times in a second and then we have delay of 2 seconds and again hitting URL 5 times. we want to repeat this case 2000 times. Session timeout time is 1 hour. After hitting this URL for 170 times, tomcat went out of memory. This means that only 850 concurrent sessions were created. My web app has no back end data structure so its only ZK component objects those are present in memory. Each session roughly taking around 1Mb memory. This is not acceptable number. So for 10000 users it will require 10 GB memory just for serving UI.
We are not using any ZScript and even event thread is disabled. So can you suggest us what is wrong in our code. If you want I can post my ZUL page. Please guide me to minimize this memory footprint.
We are using ZK 6.1 nightly build for doing this test with JDK 1.6.

Thanks in advance.

link publish delete flag offensive edit

answered 2012-08-09 16:30:24 +0800

jj gravatar image jj
638 3

This may not answer your question, but have you thought about hardware/OS scaling? You need about 10 instances to achieve your performance requirements.
Sometimes it is helpful to think ZK as a Virtual Desktop. The cost of hardware is probably easily offset by ease of development.

link publish delete flag offensive edit

answered 2012-08-09 20:04:01 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2012-08-09 20:08:33 +0800

100% agree with jj.

zk is java on serverside (most). Sure, each component is a java object and needs memory. But this technology gives you the full access to all the java frameworks and java technologies and patterns out there. I will never miss it. So today it's very cheap to scale out the application on several servers. 10.000 users a 30$/month = 300.000$/month = a lot of servers. :-)

best
Stephan

PS: There are a few things you can do in the EE version to decrease the memory like yourComponent.setStubonly("true") for not interactive used components. SetStubonly reduces memory but you have restricted acces in the controller to it.

link publish delete flag offensive edit

answered 2012-08-13 06:37:01 +0800

vinayakshukre gravatar image vinayakshukre
36

Thanks for your reply.

I have already tried setStubonly("true") option. But looks like if I remove grid from UI then memory footprint is much less. If I take a approach of writing my own grid as custom zk component then will that be a wise decision ?
( I understand that issue is not with ZK but with server side java architecture of it. )

link publish delete flag offensive edit

answered 2012-08-13 08:09:28 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

You can try to declare several used components as 'native' means it would be handled as pure html code. So it should reduce the memory too.

link publish delete flag offensive edit

answered 2012-08-13 09:42:48 +0800

vinayakshukre gravatar image vinayakshukre
36

Ok. Let me explore this native stuff. Will get back to your guidance shortly. Thanks again.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2007-08-29 15:34:57 +0800

Seen: 1,422 times

Last updated: Apr 18 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More