<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/"
>

<channel>
	<title>Solution Hacker &#187; session</title>
	<atom:link href="http://www.solutionhacker.com/tag/session/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.solutionhacker.com</link>
	<description>This blog provides solutions for enterpreneurs!</description>
	<lastBuildDate>Mon, 06 Feb 2012 07:19:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=213</generator>
<!-- podcast_generator="Blubrry PowerPress/2.0.4" -->
	<itunes:summary>This blog provides solutions for enterpreneurs!</itunes:summary>
	<itunes:author>Solution Hacker</itunes:author>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://www.solutionhacker.com/wp-content/plugins/powerpress/itunes_default.jpg" />
	<itunes:subtitle>This blog provides solutions for enterpreneurs!</itunes:subtitle>
	<image>
		<title>Solution Hacker &#187; session</title>
		<url>http://www.solutionhacker.com/wp-content/plugins/powerpress/rss_default.jpg</url>
		<link>http://www.solutionhacker.com</link>
	</image>
		<item>
		<title>Session Management – Part 1</title>
		<link>http://www.solutionhacker.com/implement-your-idea/build-your-website/session-management-part-1/</link>
		<comments>http://www.solutionhacker.com/implement-your-idea/build-your-website/session-management-part-1/#comments</comments>
		<pubDate>Wed, 29 Dec 2010 06:36:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Scale]]></category>
		<category><![CDATA[Site Building]]></category>
		<category><![CDATA[cookie]]></category>
		<category><![CDATA[Keep-Alive]]></category>
		<category><![CDATA[persistence connection]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/?p=234</guid>
		<description><![CDATA[<p><strong>Session management </strong>is one of the key topics that all serious web developers and architects need to master with. This article will go through several key topics with you. They are:</p>
<ul>
	<li><strong>Persistence vs non-persistence web connection</strong> - web performance!</li>
	<li><strong>Concerns of using cookie</strong> - security and size limitations</li>
	<li><strong>Server side session management challenges</strong> in <strong>scalable</strong> web application</li>
	<li><strong>Achieve linear scalability through stateless servers </strong>- start moving the session to the client</li>
</ul>
<p>Today, I will start walking through all these topics at a high level. A series of articles will be written to further develop on each topic if necessary. Lets start!</p>
<p><!--more--></p>
<h3><strong>Persistence vs non-persistence web connection</strong></h3>
<ol>
	<li>Before HTTP 1.1, HTTP is a <strong>stateless</strong> protocol that doesn&#39;t maintain persistence connection. Each request made by a Web browser, for an image, an HTML page, or other Web object, is made via a <strong>new</strong> connection.</li>
	<li>HTTP 1.1 introduced persistence connection (ie. <strong>Keep-Alive</strong>) that Web browser can established a <strong>single</strong> connection, through which multiple requests could be made.</li>
	<li>But before HTTP 1.1, how can state maintain across <strong>stateless</strong> HTTP request?<br />
		<ul>
			<li>Normally, we keep the <strong>session</strong> in the server side and provide the <strong>session id</strong> to the client that can be used to link subsequent requests to the same session.</li>
			<li>Normally, client (often time web client) will store the session id in <strong>cookie</strong>.</li>
			<li>However, if the cookie is disabled, the session id will normally embedded in the URL (ie <strong>URL Rewriting</strong>).</li>
		</ul>
	</li>
</ol>
<h3><strong>Concerns of using cookie</strong></h3>
<p>What do we need to pay attention when we store info in cookie?</p>
<ol>
	<li>Size limitation and security concerns.</li>
	<li>How long cookie can last? Default = expired when browser exits. In Java, you can do <strong>cookie.setMaxAge(int)</strong> with long future date if you want to keep the info lasting long in the cookie. If you do <strong>setMaxAge(0)</strong>, it will void the cookie.</li>
	<li>Normally, we don&#39;t keep all state info in cookie as the information could be sensitive and we are not able to protect it because it sits in the clients&#39; filesystem. Apart from that, there has limitation in size as well. For these two concerns, we normally just store the session id in the cookie and keep the session in the server side. This approach can save us bandwidth as well.</li>
</ol>
<h3><strong>Server side session management challenges</strong></h3>
<p>At the first glance, session in server side sounds like a great solution. However, when it comes to scale, it always raises the concerns. Imagine you need to replicate client session state across multiple servers to achieve high availability. Both the replication time and memory resource limit will cause your system not able to scale linearly. To solve or minimize this, we selectively pick what kind of info we store in the session, use <strong>sticky</strong> session to avoid one session replication across all the machine or even try to store the state to the client if possible like using rich client UI (ex. <strong>Flex</strong> and <strong>Silverlight</strong>). <span style="color: rgb(0, 128, 0);">A post will be written about this topic later on.</span></p>
<h3>Transient vs Persistent State</h3>
<ol>
	<li>Session in the server can be timed out (~30 minute inactive)</li>
	<li>Session in the server can be persisted in file across Tomcat restart.</li>
	<li><strong>Persistent state</strong> should be stored in database.</li>
	<li>Object putting in session should be <strong>Serializable</strong></li>
	<li>Avoid putting too much info in the session b/c we don&#39;t want to put too much baggage during <strong>session replication</strong>. One server crash b/c of memory depletion can further spread across to other servers via session replication. Not Good! Should we reconsider storing session in client? This <a href="http://dharmeshmistry.wordpress.com/2008/07/18/client-side-session-management/">article</a> talks about it.</li>
	<li>Session replication is needed to support failover. Sticky session for simplicity but suffered data lost when the box is down. We can tell one or two servers as its backup to avoid the session lost. To go for sticky session approach, we need to identify the &#34;sticky&#34; part. What kind of thing we can use to link separate requests? Use <strong>IP address</strong> can potentially overload a box because some Internet service providers use a set of proxy servers to deal with many clients. <span style="color: rgb(0, 128, 0);">This subject can be further developed. We will go back to it later!</span></li>
</ol>
]]></description>
			<content:encoded><![CDATA[<p><strong>Session management </strong>is one of the key topics that all serious web developers and architects need to master with. This article will go through several key topics with you. They are:</p>
<ul>
<li><strong>Persistence vs non-persistence web connection</strong> &#8211; web performance!</li>
<li><strong>Concerns of using cookie</strong> &#8211; security and size limitations</li>
<li><strong>Server side session management challenges</strong> in <strong>scalable</strong> web application</li>
<li><strong>Achieve linear scalability through stateless servers </strong>- start moving the session to the client</li>
</ul>
<p>Today, I will start walking through all these topics at a high level. A series of articles will be written to further develop on each topic if necessary. Lets start!</p>
<p><span id="more-234"></span></p>
<h3><strong>Persistence vs non-persistence web connection</strong></h3>
<ol>
<li>Before HTTP 1.1, HTTP is a <strong>stateless</strong> protocol that doesn&#39;t maintain persistence connection. Each request made by a Web browser, for an image, an HTML page, or other Web object, is made via a <strong>new</strong> connection.</li>
<li>HTTP 1.1 introduced persistence connection (ie. <strong>Keep-Alive</strong>) that Web browser can established a <strong>single</strong> connection, through which multiple requests could be made.</li>
<li>But before HTTP 1.1, how can state maintain across <strong>stateless</strong> HTTP request?
<ul>
<li>Normally, we keep the <strong>session</strong> in the server side and provide the <strong>session id</strong> to the client that can be used to link subsequent requests to the same session.</li>
<li>Normally, client (often time web client) will store the session id in <strong>cookie</strong>.</li>
<li>However, if the cookie is disabled, the session id will normally embedded in the URL (ie <strong>URL Rewriting</strong>).</li>
</ul>
</li>
</ol>
<h3><strong>Concerns of using cookie</strong></h3>
<p>What do we need to pay attention when we store info in cookie?</p>
<ol>
<li>Size limitation and security concerns.</li>
<li>How long cookie can last? Default = expired when browser exits. In Java, you can do <strong>cookie.setMaxAge(int)</strong> with long future date if you want to keep the info lasting long in the cookie. If you do <strong>setMaxAge(0)</strong>, it will void the cookie.</li>
<li>Normally, we don&#39;t keep all state info in cookie as the information could be sensitive and we are not able to protect it because it sits in the clients&#39; filesystem. Apart from that, there has limitation in size as well. For these two concerns, we normally just store the session id in the cookie and keep the session in the server side. This approach can save us bandwidth as well.</li>
</ol>
<h3><strong>Server side session management challenges</strong></h3>
<p>At the first glance, session in server side sounds like a great solution. However, when it comes to scale, it always raises the concerns. Imagine you need to replicate client session state across multiple servers to achieve high availability. Both the replication time and memory resource limit will cause your system not able to scale linearly. To solve or minimize this, we selectively pick what kind of info we store in the session, use <strong>sticky</strong> session to avoid one session replication across all the machine or even try to store the state to the client if possible like using rich client UI (ex. <strong>Flex</strong> and <strong>Silverlight</strong>). <span style="color: rgb(0, 128, 0);">A post will be written about this topic later on.</span></p>
<h3>Transient vs Persistent State</h3>
<ol>
<li>Session in the server can be timed out (~30 minute inactive)</li>
<li>Session in the server can be persisted in file across Tomcat restart.</li>
<li><strong>Persistent state</strong> should be stored in database.</li>
<li>Object putting in session should be <strong>Serializable</strong></li>
<li>Avoid putting too much info in the session b/c we don&#39;t want to put too much baggage during <strong>session replication</strong>. One server crash b/c of memory depletion can further spread across to other servers via session replication. Not Good! Should we reconsider storing session in client? This <a href="http://dharmeshmistry.wordpress.com/2008/07/18/client-side-session-management/">article</a> talks about it.</li>
<li>Session replication is needed to support failover. Sticky session for simplicity but suffered data lost when the box is down. We can tell one or two servers as its backup to avoid the session lost. To go for sticky session approach, we need to identify the &quot;sticky&quot; part. What kind of thing we can use to link separate requests? Use <strong>IP address</strong> can potentially overload a box because some Internet service providers use a set of proxy servers to deal with many clients. <span style="color: rgb(0, 128, 0);">This subject can be further developed. We will go back to it later!</span></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/implement-your-idea/build-your-website/session-management-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Remoting and Session Management</title>
		<link>http://www.solutionhacker.com/data-intelligence/report/flex-remoting-and-session-management/</link>
		<comments>http://www.solutionhacker.com/data-intelligence/report/flex-remoting-and-session-management/#comments</comments>
		<pubDate>Sun, 22 Jun 2008 10:10:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Report]]></category>
		<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/2008/06/22/flex-remoting-and-session-management/</guid>
		<description><![CDATA[<h2>Power of BlazeDS</h2>
<p>Recently, I found out that Adobe has released BlazeDS (subset of LiveCycleDS) that has 4 main advantages:</p>
<ol>
    <li>AS3 to Java object communication (no XML passes back and forth is needed!)</li>
    <li>Boost up performance b/c AMF is a binary protocol</li>
    <li>Built-in proxy support that gets around the cross domain security issue from Flex in ease.</li>
    <li>Allow push messaging</li>
</ol>
<p>I have followed the guideline and set it up. Now my Flex application can call my Java object method without passing xml back and forth. It is awesome! During the setup process, you may experience your flex cannot find the destination set up in the server.</p>
<div class="content"><blockquote>
<p>The error &#8220;[MessagingError message=&#8217;Destination &#8216;SomeBean&#8217; either does not exist or the destination has no channels defined (and the application does not define any default channels.)&#8217;]&#8221;.</p>
</blockquote></div>
<p>The trick here is to add a services argument to the mxmlc call, something of the form below should do the trick!&#160;</p>
<blockquote>
<p>-services &#8220;[local path to your java project]/WEB-INF/flex/services-config.xml&#8221;</p>
</blockquote>
<p>Now you may start enjoying how AS3 talks to your Java Object. However, if&#160; we bypass the Servlet layer in the code, how can we carry session across remote method calls? Great that I have found out how to handle it via this <a href="http://sujitreddyg.wordpress.com/2008/05/16/session-data-management-in-flex-remoting/">article</a>. In short, you can access Session from your Java object via:</p>
<blockquote>
<p>FlexContext.getFlexSession()</p>
</blockquote>
<p>Here is the quote I got from the <a href="http://livedocs.adobe.com/blazeds/1/blazeds_devguide/">BlazeDS developer guide</a>.</p>
<blockquote>
<p>The FlexContext class is useful for getting access to the session and the HTTP pieces of the session, such as the HTTP servlet request and response. This lets you access HTTP data when you use a Flex application in the context of a larger web application where other classes, such as JSPs or Struts actions, might have stored information.</p>
<p>The FlexSession class provides access to an ID and also provides <samp class="codeph">setAttribute</samp> and <samp class="codeph">getAttribute</samp> functionality. This is useful for storing data on the server that doesn't have to go back to the client. However, FlexSession is not cluster-aware; if a client connects to a different server in the cluster, the client receives a new FlexSession. Nothing stored in the FlexSession attributes is persisted for clustering purposes. The FlexSessionListener class is useful for monitoring who is connected. You add a listener by using the static method to track new connections being made. You receive a reference to the session that was added. Each session can then report when it is destroyed to those same listeners. You use this for monitoring connections that close, and also to clean up resources.</p>
</blockquote>
<p>When I looked into the source of FlexContext, I noticed that it leverages <strong>ThreadLocal </strong>to store context info like request, response and session.</p>
<pre name="code" class="java">
    private static ThreadLocal sessions = new ThreadLocal();  
    /**
     * The FlexSession for the current request.  Available for users.
     */
    public static FlexSession getFlexSession()
    {
        return (FlexSession)sessions.get();
    }
</pre>
<h2>Reference</h2>
<p>Below are some of the useful references I have read so far:</p>
<ol>
    <li><a href="http://jim-boone.com/2008/04/10/ria-prototype-client-using-blazeds-messaging-and-jms-j2ee-server/#more-33">Jim Boone's Blog</a></li>
</ol>
<p>&#160;</p>]]></description>
			<content:encoded><![CDATA[<h2>Power of BlazeDS</h2>
<p>Recently, I found out that Adobe has released BlazeDS (subset of LiveCycleDS) that has 4 main advantages:</p>
<ol>
<li>AS3 to Java object communication (no XML passes back and forth is needed!)</li>
<li>Boost up performance b/c AMF is a binary protocol</li>
<li>Built-in proxy support that gets around the cross domain security issue from Flex in ease.</li>
<li>Allow push messaging</li>
</ol>
<p>I have followed the guideline and set it up. Now my Flex application can call my Java object method without passing xml back and forth. It is awesome! During the setup process, you may experience your flex cannot find the destination set up in the server.</p>
<div class="content">
<blockquote>
<p>The error &ldquo;[MessagingError message=&rsquo;Destination &lsquo;SomeBean&rsquo; either does not exist or the destination has no channels defined (and the application does not define any default channels.)&rsquo;]&rdquo;.</p>
</blockquote>
</div>
<p>The trick here is to add a services argument to the mxmlc call, something of the form below should do the trick!&nbsp;</p>
<blockquote>
<p>-services &ldquo;[local path to your java project]/WEB-INF/flex/services-config.xml&rdquo;</p>
</blockquote>
<p>Now you may start enjoying how AS3 talks to your Java Object. However, if&nbsp; we bypass the Servlet layer in the code, how can we carry session across remote method calls? Great that I have found out how to handle it via this <a href="http://sujitreddyg.wordpress.com/2008/05/16/session-data-management-in-flex-remoting/">article</a>. In short, you can access Session from your Java object via:</p>
<blockquote>
<p>FlexContext.getFlexSession()</p>
</blockquote>
<p>Here is the quote I got from the <a href="http://livedocs.adobe.com/blazeds/1/blazeds_devguide/">BlazeDS developer guide</a>.</p>
<blockquote>
<p>The FlexContext class is useful for getting access to the session and the HTTP pieces of the session, such as the HTTP servlet request and response. This lets you access HTTP data when you use a Flex application in the context of a larger web application where other classes, such as JSPs or Struts actions, might have stored information.</p>
<p>The FlexSession class provides access to an ID and also provides <samp class="codeph">setAttribute</samp> and <samp class="codeph">getAttribute</samp> functionality. This is useful for storing data on the server that doesn&#8217;t have to go back to the client. However, FlexSession is not cluster-aware; if a client connects to a different server in the cluster, the client receives a new FlexSession. Nothing stored in the FlexSession attributes is persisted for clustering purposes. The FlexSessionListener class is useful for monitoring who is connected. You add a listener by using the static method to track new connections being made. You receive a reference to the session that was added. Each session can then report when it is destroyed to those same listeners. You use this for monitoring connections that close, and also to clean up resources.</p>
</blockquote>
<p>When I looked into the source of FlexContext, I noticed that it leverages <strong>ThreadLocal </strong>to store context info like request, response and session.</p>
<p><pre><pre name="code" class="java">
&nbsp;&nbsp;&nbsp;&nbsp;private static ThreadLocal sessions = new ThreadLocal();&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;/**
&nbsp;&nbsp;&nbsp;&nbsp; * The FlexSession for the current request.&nbsp;&nbsp;Available for users.
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;public static FlexSession getFlexSession()
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return (FlexSession)sessions.get();
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre></pre></p>
<h2>Reference</h2>
<p>Below are some of the useful references I have read so far:</p>
<ol>
<li><a href="http://jim-boone.com/2008/04/10/ria-prototype-client-using-blazeds-messaging-and-jms-j2ee-server/#more-33">Jim Boone&#8217;s Blog</a></li>
</ol>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/data-intelligence/report/flex-remoting-and-session-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

