<?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>超群.com的博客 &#187; Open Source</title>
	<atom:link href="http://www.fuchaoqun.com/tag/open-source/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fuchaoqun.com</link>
	<description></description>
	<lastBuildDate>Thu, 08 Sep 2011 15:08:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>ChinaUnix网络优化论坛归来</title>
		<link>http://www.fuchaoqun.com/2009/01/cu-net-opt-salon/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cu-net-opt-salon</link>
		<comments>http://www.fuchaoqun.com/2009/01/cu-net-opt-salon/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 03:56:39 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[Arch]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[chinaunix]]></category>
		<category><![CDATA[load balance]]></category>
		<category><![CDATA[lvs]]></category>
		<category><![CDATA[nginx]]></category>
		<guid isPermaLink="false">http://chaoqun.17348.com/?p=129</guid>
		<description><![CDATA[本博客所有原创文章采用知识共享署名-非商业性使用-相同方式共享，转载请保留链接http://chaoqun.17348.com/2009/01/cu-net-opt-salon/ 特意把调休放在1.9，主要是想去听听CU组织的网络优化论坛，报名的时候有点意外，貌似丢失了报名信息，和组织者沟通了一下，感谢周平同学的热心帮助，说到的时候找他就可以，去的时候其实也没有查邀请函什么的，还给了件CU的T-Shirt，甚是感谢，一般这种开源技术研讨会都是很开放的。 首先是TOM网的曹刚带来的“浅析系统架构”，主要讲的是Myspace和SOHU社区架构的演变过程，基本的内容可以参考构建可扩展网络应用的七个步骤，一般他们的历程都是从第一步到第四步，大体上差不多，我这里列举这个关键词： 64位：Myspace为了让服务器管理更多的内容，操作系统由32位升级到64位，我们都知道32位的操作系统最多支持4G内存（当然有方法可以实现超过4G，不推荐。），64位操作系统理论上支持4G个G，估计我是看不到用完的那天，这里要注意的是32位操作系统下，一个处理器最多处理2G内存，所以如果是Memcached服务器，不要一个进程给超过2G内存，浪费。好的做法是多开几个服务，或者直接把Memcached服务器和APP服务器合二为一，很多公司都这样。 分表：论坛的特点是数据一般是按照板块分组，所以对于论坛这样的应用来说，最好是按照板块ID分表甚至分库分机器。 板块帖子列表页：论坛的特性是新帖子、新更新的帖子排在最前面，所以可能的情况是每次刷新的时候页面都在变，SOHU社区的做法是把板块新帖子保持在一个链表里面，链表的特点是插入和删除都很快，问题是查询的时候只能遍历。 其实对于一个论坛板块来说，热门的帖子不会太多，估计大家也就翻前几页，大可以把这个数据放进缓存中，比如维护一个队列，最新的500个帖子ID，帖子Title，新帖子放在最前面，自动顶掉最后一个，大可以用数组而不用链表，虽然插入的时候慢点，读取的时候却不用遍历链表。 对于跟帖数据，一般都是按照时间顺序排列，新增加的帖子自动在最后，压力不会很大。 google去搜一下Carp算法，一致性哈希算法consistent hashing（可以参考http://tech.idv2.com/2008/08/17/memcached-pdf/），Amazon S3 环形算法（是不是就是consistent hashing?不知）。 曹刚最后做了个总结，个人觉得：熟悉业务需求应该是核心。 第二位演讲者是来自占座网的吴炳锡，讲的是LVS和Nginx的负载均衡，这块以前只是从资料上看过，接触比较少，不过炳锡的介绍深入浅出，以前觉得LVS晦涩难懂，不敢动手，听完之后无知者无畏了，有机会试试看去。其实很多事情都这样，看上去挺难，做起来就容易了，下面是几个关键字： DR模式：LVS有NAT、TUN、DR模式，推荐使用DR模式，更多的信息去google吧。 LVS-&#62;Nginx-&#62;Squid：组合的模式，LVS是四层的转发，Nginx是七层的转发，可以支持URL规则的转发，组合起来用就可以随心所欲了。 性能：Nginx的性能和LVS NAT模式相当，都是很好的解决方案，熟悉哪个就用哪个吧，性能都不是问题。 keepalived：LVS居家旅行、杀人灭口必配武器。 搜房网：搜房网前端采用LVS做负载均衡，中间用Nginx做URL负载均衡，动态的URL跳到App服务器，静态的URL跳转到Squid服务器。 第三位演讲者来自某个赞助商，感谢他们对活动的赞助，就不做广告了，一句话概括：适合钱多人傻。 第四位演讲者来自SOHU的MySQL DBA叶金荣，报告的内容网上大多有，这里也列出一些关键字： 发现问题：系统响应慢、load avg &#62;=5、IO wait &#62;= 10、swap使用情况、mysql status、mysql report、mysql 5.1 profline xfs：如果可能，mysql数据文件系统分区采用xfs，效果高30％～50％ innodb_buffer_pool_size：如果是专用的数据库服务器，设定为内存的80％吧 MyIsam适合低并发、低更新、高读取的需求，InnoDB适合高并发、高更新、高读取的需求，MyIsam读取的速度比InnoDB快许多。 Explain：查询检查、查询优化 联合索引：貌似MySQL一次查询只用到一个索引，联合索引要注意先后顺序的问题，“左派”比较吃香。 字段按需配置，能用TinyINT的不用INT，字段越短越好，具体差别可以参见：http://chaoqun.17348.com/2008/11/mysql-data-types-int/ 把大表拆成小表，如果表字段里面有Text，尽量拆开吧。 缩短事务周期 字符型的字段，最好采用前缀索引。 复杂的查询拆成小的简单的查询，比如用循环查询替代。这点不敢苟同，还是按照自己的业务测试一下吧。一条sql语句总比N条要快吧，除非有问题。 left join：把条目数少的放左边，如果你了解left join的话，这个是肯定的。 实时备份：用slave做实时备份吧，一个slave就是一个备份。 第五个演讲最为精彩，走了的人实在可惜，掌声和笑声不断，田逸这个家伙说话太有意思的，有机会要认识一下。讲的是CDN方面的事情，关键字：策略，技术很重要，策略更重要。 昨天的网络优化论坛受益匪浅，演讲者都有丰富的经验，其实网站架构就那么点事情，多分享才能共同进步，不过从互动环节可以看出国内做技术的对这方面关注还是比较少，有些问题比较原始，多关注一些就不会那样了。 PS:报告盖茨：我上周四叛逃到Linux了。]]></description>
			<content:encoded><![CDATA[<blockquote><p>本博客所有原创文章采用<a href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/" target="_blank"><span style="color: #356aa0;">知识共享署名-非商业性使用-相同方式共享</span></a>，转载请保留链接<a href="http://chaoqun.17348.com/2009/01/cu-net-opt-salon/">http://chaoqun.17348.com/2009/01/cu-net-opt-salon/</a></p></blockquote>
<p>特意把调休放在1.9，主要是想去听听CU组织的网络优化论坛，报名的时候有点意外，貌似丢失了报名信息，和组织者沟通了一下，感谢周平同学的热心帮助，说到的时候找他就可以，去的时候其实也没有查邀请函什么的，还给了件CU的T-Shirt，甚是感谢，一般这种开源技术研讨会都是很开放的。</p>
<p>首先是TOM网的曹刚带来的“浅析系统架构”，主要讲的是Myspace和SOHU社区架构的演变过程，基本的内容可以参考<a href="http://chaoqun.17348.com/2008/09/7-stages-scaling-of-web-apps/" target="_blank">构建可扩展网络应用的七个步骤</a>，一般他们的历程都是从第一步到第四步，大体上差不多，我这里列举这个关键词：</p>
<ul>
<li>64位：Myspace为了让服务器管理更多的内容，操作系统由32位升级到64位，我们都知道32位的操作系统最多支持4G内存（当然有方法可以实现超过4G，不推荐。），64位操作系统理论上支持4G个G，估计我是看不到用完的那天，这里要注意的是32位操作系统下，一个处理器最多处理2G内存，所以如果是Memcached服务器，不要一个进程给超过2G内存，浪费。好的做法是多开几个服务，或者直接把Memcached服务器和APP服务器合二为一，很多公司都这样。</li>
<li>分表：论坛的特点是数据一般是按照板块分组，所以对于论坛这样的应用来说，最好是按照板块ID分表甚至分库分机器。</li>
<li>板块帖子列表页：论坛的特性是新帖子、新更新的帖子排在最前面，所以可能的情况是每次刷新的时候页面都在变，SOHU社区的做法是把板块新帖子保持在一个链表里面，链表的特点是插入和删除都很快，问题是查询的时候只能遍历。
<p>其实对于一个论坛板块来说，热门的帖子不会太多，估计大家也就翻前几页，大可以把这个数据放进缓存中，比如维护一个队列，最新的500个帖子ID，帖子Title，新帖子放在最前面，自动顶掉最后一个，大可以用数组而不用链表，虽然插入的时候慢点，读取的时候却不用遍历链表。</p>
<p>对于跟帖数据，一般都是按照时间顺序排列，新增加的帖子自动在最后，压力不会很大。</li>
<li>google去搜一下<a href="http://www.google.cn/search?q=carp" target="_blank">Carp算法</a>，一致性哈希算法consistent hashing（可以参考<a href="http://tech.idv2.com/2008/08/17/memcached-pdf/" target="_blank">http://tech.idv2.com/2008/08/17/memcached-pdf/</a>），Amazon S3 环形算法（是不是就是consistent hashing?不知）。</li>
</ul>
<p>曹刚最后做了个总结，个人觉得：熟悉业务需求应该是核心。</p>
<p>第二位演讲者是来自占座网的吴炳锡，讲的是LVS和Nginx的负载均衡，这块以前只是从资料上看过，接触比较少，不过炳锡的介绍深入浅出，以前觉得LVS晦涩难懂，不敢动手，听完之后无知者无畏了，有机会试试看去。其实很多事情都这样，看上去挺难，做起来就容易了，下面是几个关键字：</p>
<ul>
<li>DR模式：LVS有NAT、TUN、DR模式，推荐使用DR模式，更多的信息去google吧。</li>
<li>LVS-&gt;Nginx-&gt;Squid：组合的模式，LVS是四层的转发，Nginx是七层的转发，可以支持URL规则的转发，组合起来用就可以随心所欲了。</li>
<li>性能：Nginx的性能和LVS NAT模式相当，都是很好的解决方案，熟悉哪个就用哪个吧，性能都不是问题。</li>
<li><a href="http://www.keepalived.org/" target="_blank">keepalived</a>：LVS居家旅行、杀人灭口必配武器。</li>
<li>搜房网：搜房网前端采用LVS做负载均衡，中间用Nginx做URL负载均衡，动态的URL跳到App服务器，静态的URL跳转到Squid服务器。</li>
</ul>
<p>第三位演讲者来自某个赞助商，感谢他们对活动的赞助，就不做广告了，一句话概括：适合钱多人傻。</p>
<p>第四位演讲者来自SOHU的MySQL DBA叶金荣，报告的内容网上大多有，这里也列出一些关键字：</p>
<ul>
<li>发现问题：系统响应慢、load avg &gt;=5、IO wait &gt;= 10、swap使用情况、mysql status、mysql report、mysql 5.1 profline</li>
<li>xfs：如果可能，mysql数据文件系统分区采用xfs，效果高30％～50％</li>
<li>innodb_buffer_pool_size：如果是专用的数据库服务器，设定为内存的80％吧</li>
<li>MyIsam适合低并发、低更新、高读取的需求，InnoDB适合高并发、高更新、高读取的需求，MyIsam读取的速度比InnoDB快许多。</li>
<li>Explain：查询检查、查询优化</li>
<li>联合索引：貌似MySQL一次查询只用到一个索引，联合索引要注意先后顺序的问题，“左派”比较吃香。</li>
<li>字段按需配置，能用TinyINT的不用INT，字段越短越好，具体差别可以参见：<a href="http://chaoqun.17348.com/2008/11/mysql-data-types-int/" target="_blank">http://chaoqun.17348.com/2008/11/mysql-data-types-int/</a></li>
<li>把大表拆成小表，如果表字段里面有Text，尽量拆开吧。</li>
<li>缩短事务周期</li>
<li>字符型的字段，最好采用前缀索引。</li>
<li>复杂的查询拆成小的简单的查询，比如用循环查询替代。这点不敢苟同，还是按照自己的业务测试一下吧。一条sql语句总比N条要快吧，除非有问题。</li>
<li>left join：把条目数少的放左边，如果你了解left join的话，这个是肯定的。</li>
<li>实时备份：用slave做实时备份吧，一个slave就是一个备份。</li>
</ul>
<p>第五个演讲最为精彩，走了的人实在可惜，掌声和笑声不断，田逸这个家伙说话太有意思的，有机会要认识一下。讲的是CDN方面的事情，关键字：策略，技术很重要，策略更重要。</p>
<p>昨天的网络优化论坛受益匪浅，演讲者都有丰富的经验，其实网站架构就那么点事情，多分享才能共同进步，不过从互动环节可以看出国内做技术的对这方面关注还是比较少，有些问题比较原始，多关注一些就不会那样了。</p>
<p>PS:报告盖茨：我上周四叛逃到Linux了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2009/01/cu-net-opt-salon/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>OpenSlopeOne: An Open Source Project implementing Slope One in PHP&amp;MySQL</title>
		<link>http://www.fuchaoqun.com/2008/09/openslopeone-open-source-php-mysql/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=openslopeone-open-source-php-mysql</link>
		<comments>http://www.fuchaoqun.com/2008/09/openslopeone-open-source-php-mysql/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 15:37:34 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[Data Mining]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Collaborative filtering]]></category>
		<category><![CDATA[openslopeone]]></category>
		<category><![CDATA[slope one]]></category>
		<guid isPermaLink="false">http://chaoqun.17348.com/?p=68</guid>
		<description><![CDATA[About OpenSlopeOne OpenSlopeOne is an implementation of Slope One based on PHP&#38;MySQL, it&#8217;s an open source project under GPL V3. It aims to a fast way to use Slope One with PHP&#38;MySQL, and it can handle tons of data. It&#8217;s localed on Google Code:     http://code.google.com/p/openslopeone/ You can get the latest code here:     svn [...]]]></description>
			<content:encoded><![CDATA[<p><strong>About OpenSlopeOne</strong></p>
<p>OpenSlopeOne is an implementation of Slope One based on PHP&amp;MySQL, it&#8217;s an open source project under GPL V3.</p>
<p>It aims to a fast way to use Slope One with PHP&amp;MySQL, and it can handle tons of data.</p>
<p>It&#8217;s localed on Google Code:</p>
<p>    <a href="http://code.google.com/p/openslopeone/" target="_blank">http://code.google.com/p/openslopeone/</a></p>
<p>You can get the latest code here:</p>
<p>    svn checkout https://openslopeone.googlecode.com/svn/trunk/openslopeone</p>
<p>it uses Zend_Db as its database layer.PHP5&amp;MySQL5 or higher.</p>
<p><strong>About Slope One</strong></p>
<p>Slope One is a family of algorithms used for <a href="http://en.wikipedia.org/wiki/Collaborative_filtering" target="_blank">Collaborative filtering</a> introduced in Slope One Predictors for Online Rating-Based Collaborative Filtering by <a href="http://www.daniel-lemire.com/fr/abstracts/SDM2005.html" target="_blank">Daniel Lemire</a> and Anna Maclachlan.</p>
<p>You can check <a href="http://en.wikipedia.org/wiki/Slope_One" target="_blank">http://en.wikipedia.org/wiki/Slope_One</a> to know more about Slope One.</p>
<p><strong>What&#8217;s the difference between OpenSlopeOne and Vogoo?</strong></p>
<p>As you know,there is also another implementation of Slope One based on PHP&amp;MySQL:<a href="http://sourceforge.net/projects/vogoo" target="_blank">Vogoo</a></p>
<p>What&#8217;s the difference?</p>
<p>OpenSlopeOne aims to a fast way to use Slope One with PHP&amp;MySQL, so it cares more about performance.</p>
<p>OpenSlopeOne has two modes to init the slope one table, one is based on pure PHP, the other is based on MySQL procedure, as you know, it will be much faster, and you can use it with any other programming language.</p>
<p>the bottleneck of Vogoo(read the source code of cronslope.php Line 70~Line 150, version 2.2) is to check whether the record exits or not. If there is tons of data, the performance is very bad.</p>
<p>In OpenSlopeOne, first I get distinct item ids, then foreach item id, i calculate the slope one of it. I do not have to check whether if it exits, and i am faster.</p>
<p><strong>Installation</strong></p>
<p>1. Modify the config ini file: config.ini.php</p>
<p>   ; &lt;?php exit; ?&gt; DO NOT REMOVE THIS LINE<br />
   [database]<br />
   host                 = localhost ; database host name or ip<br />
   username             = root      ; database user name<br />
   password             =           ; user password<br />
   dbname               =           ; database name<br />
   port                 = 3306      ; database host port,3306 as default<br />
   adapter              = PDO_MYSQL ; PDO_MYSQL or MYSQLI</p>
<p>2. Create user&#8217;s rating table:</p>
<p>    CREATE TABLE IF NOT EXISTS `oso_user_ratings` (<br />
      `user_id` int(11) NOT NULL,<br />
      `item_id` int(11) NOT NULL,<br />
      `rating` decimal(14,4) NOT NULL default &#8217;0.0000&#8242;,<br />
      KEY `item_id` (`item_id`),<br />
      KEY `user_id` (`user_id`,`item_id`)<br />
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;</p>
<p>there is a sample data file:sample.data, you can load it into the table</p>
<p>    load data infile &#8216;sample.data&#8217; into table oso_user_ratings;</p>
<p>3. Create slope one table:</p>
<p>    CREATE TABLE IF NOT EXISTS `oso_slope_one` (<br />
      `item_id1` int(11) NOT NULL,<br />
      `item_id2` int(11) NOT NULL,<br />
      `times` int(11) NOT NULL,<br />
      `rating` decimal(14,4) NOT NULL<br />
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;</p>
<p><strong>Usage<br />
</strong><br />
The main also the only PHP file is OpenSlopeOne.php, you must include it in your own PHP file:</p>
<p>    require &#8216;./OpenSlopeOne.php&#8217;;</p>
<p>    $openslopeone = new OpenSlopeOne();</p>
<p>1. Init the slope one table:</p>
<p>before you get the recommendtion, you must pre-computation the slope one table.</p>
<p>    $openslopeone-&gt;initSlopeOneTable($factory);</p>
<p>you can specify the mode use &#8216;PHP&#8217; or &#8216;MySQL&#8217;,If you user &#8216;PHP&#8217; mode, it&#8217;s a pure php implementation, and it might be very slow when there is tons of data.You can also use &#8216;MySQL&#8217; mode, it&#8217;s based on mysql procedure, and it will be mutch faster.</p>
<p>If you have tons of data to pre-computation, a good advice is that you do not index any colum on oso_slope_one before it done.</p>
<p>2. Get recommended items by item&#8217;s id</p>
<p>    $recommendedItems = $openslopeone-&gt;getRecommendedItemsById(9527);</p>
<p>3. Get recommended items by user&#8217;s id</p>
<p>    $recommendedItems = $openslopeone-&gt;getRecommendedItemsByUser(30002);<br />
<strong>About Author</strong></p>
<p>I am a PHP programmer in China, my blog:http://chaoqun.17348.com, mostly written in Chinese.</p>
<p>You can contack me with gtalk or mail:fuchaoqun@gmail.com</p>
<p>Welcom to any bug and advice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2008/09/openslopeone-open-source-php-mysql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
