<?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/"
	>

<channel>
	<title>Nick Zalabak - techwhizbang &#187; memcached</title>
	<atom:link href="http://techwhizbang.com/tag/memcached/feed/" rel="self" type="application/rss+xml" />
	<link>http://techwhizbang.com</link>
	<description>my work, life, and ideas</description>
	<lastBuildDate>Thu, 08 Mar 2012 06:07:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Session Store Strategy Using Memcached</title>
		<link>http://techwhizbang.com/2009/12/memcache-session-store/</link>
		<comments>http://techwhizbang.com/2009/12/memcache-session-store/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 01:59:27 +0000</pubDate>
		<dc:creator>techwhizbang</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[session storage]]></category>

		<guid isPermaLink="false">http://techwhizbang.com/?p=65</guid>
		<description><![CDATA[It is becoming increasingly popular to mix technologies, frameworks, and languages to power a web site. So what happens when you want to share session data between some permutation of a Ruby, PHP, .NET, Python, Java web framework? Well of course using cookies is the first thing that should pop into your head, and with [...]]]></description>
			<content:encoded><![CDATA[<p>It is becoming increasingly popular to mix technologies, frameworks, and languages to power a web site. So what happens when you want to share session data between some permutation of a Ruby, PHP, .NET, Python, Java web framework? Well of course using cookies is the first thing that should pop into your head, and with good reason, that is the way it ought to be. It should be as simple and stateless as possible. However, we all know that many applications store objects in their sessions and that makes it impossible to use cookies. What are your options?</p>
<p>Option 1:</p>
<p>Buckling down and incurring the cost of simplifying all of your session data suitable for cookies is one option, but tricky and difficult to do for many applications storing objects in session.</p>
<p>Option 2:</p>
<p>You might consider some RESTful SOA to talk between your variable stack of frameworks, but the cost of doing that is two fold. First, you must consider the security constraints of how the services would be consumed and restrict that to internal consumption to prevent leaking sensitive data. Second, it would increase the chattiness between the apps which could negatively impact performance if not done just right.</p>
<p>Option 3:</p>
<p>Storing session data in a shared database? Eh, no. Locking and transactional problems of a database shared between many applications is a recipe for disaster.</p>
<p>Option 4:</p>
<p>Memcached! OK, hear me out on on this one. Here are some of the advantages of using Memcached:</p>
<p>a.) Distributed high availability server<br />
b.) Zero cross communication between the various applications for session data<br />
c.) Memcached can support serialized objects, XML, YAML, and basically whatever<br />
d.) Legacy application session stores can continue working almost the same only with a new hook to save and retrieve shared session data<br />
e.) Memcached server cluster can be setup behind your firewall reducing any possibility of leaking sensitive session data to the outside world<br />
f.) Minimizing complexity of security implementation (ie if a service based approach were used for cross-app session communication through services == more overhead)<br />
g,) Chances are if you are using Ruby, PHP, or Python you already have Memcached as part of your architecture and if you don&#8217;t then it is a double bonus because of the added benefits that are yet to be realized for the new power of caching at your fingertips.</p>
<p>So here are some disadvantages:</p>
<p>a.) The language(s) your are using don&#8217;t have any open source support for communication with Memcached yet and you aren&#8217;t ready to incur the cost of developing it yourself<br />
b.) Your organization prevents the use of this technology for whatever crazy reason<br />
c.) Some will contend that if the Memcached server crashes your session data will be lost (same deal when your application servers crash though)</p>
<p>There are probably more disadvantages, but I am here promoting the use of Memcached so it is a <em>little </em>biased. Here are some visualizations of this idea. I put together a flow and sequence diagram. The underlying concept is that the all of the applications would need to read and write to a common cookie representing the key to look up the session data from Memcached.</p>
<div id="attachment_68" class="wp-caption aligncenter" style="width: 492px"><a href="http://techwhizbang.com/wp-content/uploads/2009/12/session_store_flow.jpg"><img class="size-full wp-image-68" title="session_store_flow" src="http://techwhizbang.com/wp-content/uploads/2009/12/session_store_flow.jpg" alt="Memcached Session Store" width="482" height="609" /></a><p class="wp-caption-text">Memcached Session Store</p></div>
<p><a href="http://techwhizbang.com/wp-content/uploads/2009/12/session_store_sequence.jpg"><img class="aligncenter size-full wp-image-69" title="Memcached Session Store" src="http://techwhizbang.com/wp-content/uploads/2009/12/session_store_sequence.jpg" alt="Memcached Session Store" width="578" height="533" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://techwhizbang.com/2009/12/memcache-session-store/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.702 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-20 10:46:20 -->

