<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Who&#8217;s Online with PHP and Memcached</title>
	<atom:link href="http://www.deshong.net/2007/09/whos-online-with-php-and-memcached/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.deshong.net/2007/09/whos-online-with-php-and-memcached/</link>
	<description></description>
	<lastBuildDate>Sun, 19 Jun 2011 01:18:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19719</generator>
	<item>
		<title>By: Insolence</title>
		<link>http://www.deshong.net/2007/09/whos-online-with-php-and-memcached/comment-page-1/#comment-9</link>
		<dc:creator>Insolence</dc:creator>
		<pubDate>Mon, 19 May 2008 07:27:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.deshong.net/?p=46#comment-9</guid>
		<description>I know this is a bit outdated of a post at this point.  But I&#039;d like to add with some experience with memcached that this approach is a simple way to get memcahed running but does not provide (as others have mentioned) a secure and safe environment for users and sessions in a large server environment.

In addition and in response to Radarek, memcached is needed in very high traffic websites, no database or amount of servers can keep up with the major social networking websites, which is why this technique now exists and is getting more and more popular.  Even without non transactional support, databases crumble under even only hundreds of hits per second (which typically can mean tens of thousands of queries per second).

Anyway, this is a nice quick tutorial I came across awhile back and was in my bookmarks and thought I&#039;d comment on.  Cheers</description>
		<content:encoded><![CDATA[<p>I know this is a bit outdated of a post at this point.  But I&#8217;d like to add with some experience with memcached that this approach is a simple way to get memcahed running but does not provide (as others have mentioned) a secure and safe environment for users and sessions in a large server environment.</p>
<p>In addition and in response to Radarek, memcached is needed in very high traffic websites, no database or amount of servers can keep up with the major social networking websites, which is why this technique now exists and is getting more and more popular.  Even without non transactional support, databases crumble under even only hundreds of hits per second (which typically can mean tens of thousands of queries per second).</p>
<p>Anyway, this is a nice quick tutorial I came across awhile back and was in my bookmarks and thought I&#8217;d comment on.  Cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Radarek</title>
		<link>http://www.deshong.net/2007/09/whos-online-with-php-and-memcached/comment-page-1/#comment-8</link>
		<dc:creator>Radarek</dc:creator>
		<pubDate>Fri, 28 Sep 2007 13:35:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.deshong.net/?p=46#comment-8</guid>
		<description>And some calculations:

1000 users online at one time, every people make 1request/s so you have 1000requests/s (it is very huge value, believe me :)).

If you query database only one per 2 minutes you have only: 2000 (1 select, 1 update) queries per 2 minutes = 16.66 queries/s. You can set time to 5min and have only 6.66 queries/s. Use simple table with non transactional support (MyIsam in mysql) and performance will be ok :).</description>
		<content:encoded><![CDATA[<p>And some calculations:</p>
<p>1000 users online at one time, every people make 1request/s so you have 1000requests/s (it is very huge value, believe me <img src='http://www.deshong.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).</p>
<p>If you query database only one per 2 minutes you have only: 2000 (1 select, 1 update) queries per 2 minutes = 16.66 queries/s. You can set time to 5min and have only 6.66 queries/s. Use simple table with non transactional support (MyIsam in mysql) and performance will be ok <img src='http://www.deshong.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Radarek</title>
		<link>http://www.deshong.net/2007/09/whos-online-with-php-and-memcached/comment-page-1/#comment-7</link>
		<dc:creator>Radarek</dc:creator>
		<pubDate>Fri, 28 Sep 2007 13:27:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.deshong.net/?p=46#comment-7</guid>
		<description>Sorry, but I don&#039;t like your solution :). First you rejected solution with database because of performance (many sql queries). But you gave solution for this problem: do not query database for each request, byt only from time to time ;) (2 minutes sounds reasonably for me).

So, why I think that your approach is bad? There is some &#039;race condition&#039; problem. If there will be many concurrent request in one time it could cause that some information won&#039;t be saved in memcache. Another problem will be for many users online. Assumie that your array with users activity information has 500kb. Your php script must retrieve 500kb from memcache and put it back. For many requests/s it could be bottleneck.</description>
		<content:encoded><![CDATA[<p>Sorry, but I don&#8217;t like your solution <img src='http://www.deshong.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . First you rejected solution with database because of performance (many sql queries). But you gave solution for this problem: do not query database for each request, byt only from time to time <img src='http://www.deshong.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  (2 minutes sounds reasonably for me).</p>
<p>So, why I think that your approach is bad? There is some &#8216;race condition&#8217; problem. If there will be many concurrent request in one time it could cause that some information won&#8217;t be saved in memcache. Another problem will be for many users online. Assumie that your array with users activity information has 500kb. Your php script must retrieve 500kb from memcache and put it back. For many requests/s it could be bottleneck.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brian</title>
		<link>http://www.deshong.net/2007/09/whos-online-with-php-and-memcached/comment-page-1/#comment-6</link>
		<dc:creator>brian</dc:creator>
		<pubDate>Tue, 25 Sep 2007 23:47:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.deshong.net/?p=46#comment-6</guid>
		<description>Robert, absolutely!  Thing here is that it&#039;s okay for process to be &quot;lossy.&quot;  Great feedback...some follow-up here.

Bottom line here is that it&#039;s not a super-critical operation; it&#039;s never going to be 100% accurate, but, in my opinion, that&#039;s the nature of &quot;Who&#039;s Online&quot; functionality.  Accuracy is more important when something like, say, web-based instant messaging comes into play.  If you IM a person that&#039;s supposedly online, but they&#039;re not, you&#039;ll never get a response back, so it&#039;s misleading.

In my opinion, it&#039;s far better to store this data in Memcached rather than a database.  That said, in our case, we are placing this data into the database in our back end batch processing script, but that&#039;s just to support a certain accessory page.

Remember the goal here...keep those operations off of the database.  For our needs, this works really, really well because it doesn&#039;t have to be 100% accurate.  That said, it&#039;s done a damn good job so far.  The lossy nature of it may be more apparent with thousands of users online, though, but we&#039;re not there yet.</description>
		<content:encoded><![CDATA[<p>Robert, absolutely!  Thing here is that it&#8217;s okay for process to be &#8220;lossy.&#8221;  Great feedback&#8230;some follow-up here.</p>
<p>Bottom line here is that it&#8217;s not a super-critical operation; it&#8217;s never going to be 100% accurate, but, in my opinion, that&#8217;s the nature of &#8220;Who&#8217;s Online&#8221; functionality.  Accuracy is more important when something like, say, web-based instant messaging comes into play.  If you IM a person that&#8217;s supposedly online, but they&#8217;re not, you&#8217;ll never get a response back, so it&#8217;s misleading.</p>
<p>In my opinion, it&#8217;s far better to store this data in Memcached rather than a database.  That said, in our case, we are placing this data into the database in our back end batch processing script, but that&#8217;s just to support a certain accessory page.</p>
<p>Remember the goal here&#8230;keep those operations off of the database.  For our needs, this works really, really well because it doesn&#8217;t have to be 100% accurate.  That said, it&#8217;s done a damn good job so far.  The lossy nature of it may be more apparent with thousands of users online, though, but we&#8217;re not there yet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Sanders</title>
		<link>http://www.deshong.net/2007/09/whos-online-with-php-and-memcached/comment-page-1/#comment-5</link>
		<dc:creator>Robert Sanders</dc:creator>
		<pubDate>Tue, 25 Sep 2007 23:30:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.deshong.net/?p=46#comment-5</guid>
		<description>There is a pretty significant and obvious race condition here, in that the read-modify-write cycle of the online users array may be occurring from many sessions at once.

You may have 5 reads, then 5 modifies, then 5 writes.  So only 1 user will be added to the array.

If it&#039;s okay to have this be &quot;lossy&quot;, then that may not be a tragedy.  But it&#039;s definitely an unsafe operation unless you implement some locking.  Which is of course more expensive.

There&#039;s also the issue that if you&#039;re using a cluster of memcache servers and you experience an outage on the one to which your cache key hashes, you will lose the online user list because the memcache client library will failover to the next available server.  When the failed server comes back online, you will lose the online user list again, perhaps picking up the very old stale copy (if the outage was just a network partition).  memcache restarts will lose the data, as will memory pressure from other cache entries.  There&#039;s no way to tell memcached to treat an entry as permanent.

In general, it&#039;s a bad idea to store data only in memcached.  It&#039;s mem*cache*d, not mem*store*d.

And not doing locking is one of the reasons why memcached is faster than a RDBMS :-)</description>
		<content:encoded><![CDATA[<p>There is a pretty significant and obvious race condition here, in that the read-modify-write cycle of the online users array may be occurring from many sessions at once.</p>
<p>You may have 5 reads, then 5 modifies, then 5 writes.  So only 1 user will be added to the array.</p>
<p>If it&#8217;s okay to have this be &#8220;lossy&#8221;, then that may not be a tragedy.  But it&#8217;s definitely an unsafe operation unless you implement some locking.  Which is of course more expensive.</p>
<p>There&#8217;s also the issue that if you&#8217;re using a cluster of memcache servers and you experience an outage on the one to which your cache key hashes, you will lose the online user list because the memcache client library will failover to the next available server.  When the failed server comes back online, you will lose the online user list again, perhaps picking up the very old stale copy (if the outage was just a network partition).  memcache restarts will lose the data, as will memory pressure from other cache entries.  There&#8217;s no way to tell memcached to treat an entry as permanent.</p>
<p>In general, it&#8217;s a bad idea to store data only in memcached.  It&#8217;s mem*cache*d, not mem*store*d.</p>
<p>And not doing locking is one of the reasons why memcached is faster than a RDBMS <img src='http://www.deshong.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: php</title>
		<link>http://www.deshong.net/2007/09/whos-online-with-php-and-memcached/comment-page-1/#comment-2</link>
		<dc:creator>php</dc:creator>
		<pubDate>Sat, 22 Sep 2007 07:02:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.deshong.net/?p=46#comment-2</guid>
		<description>Some example please :)</description>
		<content:encoded><![CDATA[<p>Some example please <img src='http://www.deshong.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: developercast.com &#187; Brian Deshong&#8217;s Blog: Who&#8217;s Online with PHP and Memcached</title>
		<link>http://www.deshong.net/2007/09/whos-online-with-php-and-memcached/comment-page-1/#comment-4</link>
		<dc:creator>developercast.com &#187; Brian Deshong&#8217;s Blog: Who&#8217;s Online with PHP and Memcached</dc:creator>
		<pubDate>Fri, 21 Sep 2007 21:05:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.deshong.net/?p=46#comment-4</guid>
		<description>[...] Deshong has this new post on his blog today with an alternative method for doing the old standby &#8220;who&#8217;s [...]</description>
		<content:encoded><![CDATA[<p>[...] Deshong has this new post on his blog today with an alternative method for doing the old standby &#8220;who&#8217;s [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PHPDeveloper.org</title>
		<link>http://www.deshong.net/2007/09/whos-online-with-php-and-memcached/comment-page-1/#comment-3</link>
		<dc:creator>PHPDeveloper.org</dc:creator>
		<pubDate>Fri, 21 Sep 2007 20:15:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.deshong.net/?p=46#comment-3</guid>
		<description>&lt;strong&gt;Brian Deshong&#039;s Blog: Whos Online with PHP and Memcached&lt;/strong&gt;</description>
		<content:encoded><![CDATA[<p><strong>Brian Deshong&#8217;s Blog: Whos Online with PHP and Memcached</strong></p>
]]></content:encoded>
	</item>
</channel>
</rss>

