<?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>Drupal Developer &#187; Architecture</title>
	<atom:link href="http://blog.eood.cn/category/architecture/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.eood.cn</link>
	<description>A decathlon Drupal developer &#38; programmer</description>
	<lastBuildDate>Thu, 29 Jul 2010 14:55:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>服务器端PHP多进程编程实战</title>
		<link>http://blog.eood.cn/server-side-php-progress-program-best-practice</link>
		<comments>http://blog.eood.cn/server-side-php-progress-program-best-practice#comments</comments>
		<pubDate>Fri, 02 Jul 2010 14:28:08 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Project Manament]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=1164</guid>
		<description><![CDATA[最近比较PHP跟python, Erlang 的特性，发现PHP有很多人们不常用到的特性。用PHP CLI可以实现很多不错的应用。比如做爬虫, 长期运行的计算脚本, 完全可以取代其他语言来做 服务器的运维。这对于熟悉PHP的人来说如虎添翼。 为什么PHP多进程很好? 网游服务器大部分都使用多线程而不是多进程的原因也在于进程比线程更加稳定。而且多线程适合现在多核服务器的应用场景，更能发挥多核运算的能力。进程的维护可以用很多操作系统级别的工具。Message Queue解决了多大部分线程通信问题。所以PHP多进程很适合做服务器端的计算密集型的应用。 据一家越南IT公司介绍，他们成功的把PHP后台多进程用在法律文件的分发、处理银行账户的金额这样的企业级的应用上。 使用后台PHP 进程可以不影响服务器同时处理网页的请求。这种后台进程一旦发生失败很容易查处原因进行恢复或者补救,所以健壮性更高。不同的进程相互隔离，更加高效，可以统一调度各个服务进程。 PHP 是目前应用最广泛的WEB开发语言，所以用PHP来做服务器端的应用可以降低成本。可以用现有人员、现有配置、甚至做到代码重用。 什么样的场景更适合用PHP后台多进程呢？比如邮件的分发、远程服务的调用、数据的聚合、计划任务、计算结果的缓存这些不需要立即返回的地方。 PHP单进程在某些地方完全可以达到目的，而且更加容易实现，不用考虑进程的同步问题，不用考虑数据的共享问题。 PHP CLI (SAPI SERVER API)命令行接口可以用来做CRON计划任务, 图形界面程序 (使用GTK库)。 PHP CLI 例子: php -f test.php php -r &#8220;echo time();&#8221; php -R as python style PHP读取命令行参数: #!/usr/bin/php -q &#60;?php echo &#8220;Test Arguments:\n&#8221;; echo $_SERVER["argc"].&#8221;\n&#8221;; echo $_SERVER["argv"][0].&#8221;\n&#8221;; ?&#62; PHP命令行接口标准输入输出: #!/usr/bin/php -q &#60;?php [...]]]></description>
		<wfw:commentRss>http://blog.eood.cn/server-side-php-progress-program-best-practice/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HTTPCLIENT in Erlang</title>
		<link>http://blog.eood.cn/httpclient-in-erlang</link>
		<comments>http://blog.eood.cn/httpclient-in-erlang#comments</comments>
		<pubDate>Wed, 26 May 2010 14:23:15 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Erlang]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=1096</guid>
		<description><![CDATA[inets:start(). http:request(post, {&#34;http://example.com/xmlrpc&#34;, [], &#34;application/x-www-form-urlencoded&#34;, &#34;get_groups&#34; }, [], [] ). inets:start(). http:request(get, {&#34;http://blog.eood.cn&#34;, []}, [], []).]]></description>
		<wfw:commentRss>http://blog.eood.cn/httpclient-in-erlang/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XMLRPC example in PHP</title>
		<link>http://blog.eood.cn/xmlrpc-example-in-php</link>
		<comments>http://blog.eood.cn/xmlrpc-example-in-php#comments</comments>
		<pubDate>Wed, 26 May 2010 14:22:33 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[xmlrpc]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=1094</guid>
		<description><![CDATA[$param=array(&#8220;user&#8221;=&#62;&#8221;test_user&#8221;,&#8221;host&#8221;=&#62;&#8221;example.com&#8221;,&#8221;password&#8221;=&#62;&#8221;some_password&#8221;); $request = xmlrpc_encode_request(&#8216;check_password&#8217;, $param, (array(&#8216;encoding&#8217; =&#62; &#8216;utf-8&#8242;))); $context = stream_context_create(array(&#8216;http&#8217; =&#62; array( &#8216;method&#8217; =&#62; &#8220;POST&#8221;, &#8216;header&#8217; =&#62; &#8220;Content-Type: text/xml\r\n&#8221; . &#8220;Content-Length: &#8220;.strlen($request), &#8216;content&#8217; =&#62; $request ))); $file = file_get_contents(&#8220;http://127.0.0.1:1234/RPC2&#8243;, false, $context); $response = xmlrpc_decode($file); if (xmlrpc_is_fault($response)) { print_r(&#8220;error&#8221;); } else { print_r($response); }]]></description>
		<wfw:commentRss>http://blog.eood.cn/xmlrpc-example-in-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Erlang xmlrpc example</title>
		<link>http://blog.eood.cn/erlang-xmlrpc-example</link>
		<comments>http://blog.eood.cn/erlang-xmlrpc-example#comments</comments>
		<pubDate>Wed, 26 May 2010 14:21:52 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Erlang]]></category>
		<category><![CDATA[xmlrpc]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=1092</guid>
		<description><![CDATA[Library: xmlrpc-1.13 But this library does not support domain, only support IP address, so do the following hacking: send(Socket, URI, Header, Payload) -&#62; [Host,_URI] = URI, Request = ["POST ", _URI, " HTTP/1.1\r\n", "Host: ", Host,"\r\n", "Content-Length: ", integer_to_list(lists:flatlength(Payload)), "\r\n", "User-Agent: Erlang XML-RPC Client 1.13\r\n", "Content-Type: text/xml\r\n", Header, "\r\n", Payload], gen_tcp:send(Socket, Request). Then you can [...]]]></description>
		<wfw:commentRss>http://blog.eood.cn/erlang-xmlrpc-example/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>最近-Erlang-XMPP-python</title>
		<link>http://blog.eood.cn/%e6%9c%80%e8%bf%91-erlang-xmpp-python</link>
		<comments>http://blog.eood.cn/%e6%9c%80%e8%bf%91-erlang-xmpp-python#comments</comments>
		<pubDate>Wed, 19 May 2010 13:23:38 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Life & Work]]></category>
		<category><![CDATA[Erlang]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/%e6%9c%80%e8%bf%91-4</guid>
		<description><![CDATA[最近在Erlang ejabberd基础上构建大规模的chat应用。 Erlang 非常适合做real time的C/S应用，比如 instant messaging,或者webgame 的server端。 据称某些应用从C转为Erlang架构之后,代码量减少了75%.这意味着开发效率的提高,Bug的减少。 Jabber 或者称为XMPP成为互联网的未来的标准。下一代的互联网将是实时的,多终端的,永远在线的。 回顾这几周,python写的网页信息分析工具,Python非常适合处理语言分析,scapy很轻松的将网页映射成结构化的数据结构,nlp处理语言包提供了大量的基于统计的算法,python的多线程处理也很优雅。假如将来做自动聊天的机器人,python必然是不二选择。]]></description>
		<wfw:commentRss>http://blog.eood.cn/%e6%9c%80%e8%bf%91-erlang-xmpp-python/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Something about Erlang and high concurrence architecture</title>
		<link>http://blog.eood.cn/something-about-erlang-and-high-concurrence-architecture</link>
		<comments>http://blog.eood.cn/something-about-erlang-and-high-concurrence-architecture#comments</comments>
		<pubDate>Sun, 09 May 2010 11:51:58 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Erlang]]></category>
		<category><![CDATA[YAWS]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=1069</guid>
		<description><![CDATA[The father of Erlang: http://www.sics.se/~joe/ Yaws: Because Yaws uses Erlang&#8217;s lightweight threading system, it performs well under high concurrency. A load test conducted in 2002 comparing Yaws and Apache found that with the hardware tested, Apache 2.0.39 with the worker MPM failed at 4,000 concurrent connections, while Yaws continued functioning with over 80,000 concurrent connections. [...]]]></description>
		<wfw:commentRss>http://blog.eood.cn/something-about-erlang-and-high-concurrence-architecture/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何提高敏捷开发效率</title>
		<link>http://blog.eood.cn/promote_develop_efficiency</link>
		<comments>http://blog.eood.cn/promote_develop_efficiency#comments</comments>
		<pubDate>Sun, 18 Apr 2010 02:49:14 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Life & Work]]></category>
		<category><![CDATA[Project Manament]]></category>
		<category><![CDATA[效率]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=1033</guid>
		<description><![CDATA[1. 尽可能分离前端和服务。例如Drupal PHP来做前端，JAVA/PYTHON/&#8230;来做服务。 2. 准确的估计功能工作量，避免造成资源分配不合理，相互之间不理解。 3. 单元测试，性能测试，功能测试，稳定性测试分离。 4. 测试环境的速度改善。]]></description>
		<wfw:commentRss>http://blog.eood.cn/promote_develop_efficiency/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to watch the real time bandwidth in Linux</title>
		<link>http://blog.eood.cn/how-to-watch-the-real-time-bandwidth-in-linux</link>
		<comments>http://blog.eood.cn/how-to-watch-the-real-time-bandwidth-in-linux#comments</comments>
		<pubDate>Mon, 22 Mar 2010 13:35:12 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[bandwidth]]></category>
		<category><![CDATA[iftop]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/?p=954</guid>
		<description><![CDATA[Link top command of Linux, you can watch the real time bandwidth using iftop command. You can also use netstat, nmap to see net status. How to install iftop: yum install iftop How to use iftop: iftop -i eth0]]></description>
		<wfw:commentRss>http://blog.eood.cn/how-to-watch-the-real-time-bandwidth-in-linux/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>慎用drupal中的cacherouter模块</title>
		<link>http://blog.eood.cn/%e6%85%8e%e7%94%a8drupal%e4%b8%ad%e7%9a%84cacherouter%e6%a8%a1%e5%9d%97</link>
		<comments>http://blog.eood.cn/%e6%85%8e%e7%94%a8drupal%e4%b8%ad%e7%9a%84cacherouter%e6%a8%a1%e5%9d%97#comments</comments>
		<pubDate>Tue, 29 Dec 2009 07:44:36 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[cacherouter]]></category>
		<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/articles/391</guid>
		<description><![CDATA[以下是开启此模块后的memcache的统计数据 Host Status Diagrams Cache Usage     Hits &#38; Misses Free: 107.2 MBytes (83.8%)      Hits: 94616 (74.5%) Used: 20.8 MBytes (16.2%)      Misses: 32394 (25.5%) Cache Information Current Items(total)    2443 (41663) Hits    94616 Misses    32394 Request Rate (hits, misses)    8.00 cache requests/second Hit Rate    5.96 cache requests/second Miss Rate    2.04 cache requests/second Set Rate    [...]]]></description>
		<wfw:commentRss>http://blog.eood.cn/%e6%85%8e%e7%94%a8drupal%e4%b8%ad%e7%9a%84cacherouter%e6%a8%a1%e5%9d%97/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>百万级高并发网站MySQL应用攻略</title>
		<link>http://blog.eood.cn/%e7%99%be%e4%b8%87%e7%ba%a7%e9%ab%98%e5%b9%b6%e5%8f%91%e7%bd%91%e7%ab%99mysql%e5%ba%94%e7%94%a8%e6%94%bb%e7%95%a5</link>
		<comments>http://blog.eood.cn/%e7%99%be%e4%b8%87%e7%ba%a7%e9%ab%98%e5%b9%b6%e5%8f%91%e7%bd%91%e7%ab%99mysql%e5%ba%94%e7%94%a8%e6%94%bb%e7%95%a5#comments</comments>
		<pubDate>Mon, 27 Jul 2009 05:53:42 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Architecture]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/articles/279</guid>
		<description><![CDATA[百万级高并发网站MySQL应用攻略 作者: 未知 在长时间的网站开发过程中，能作一个百万IP的网站对我来说真是一个新的挑战，由于本人的水平有限，所以一直就职于一个小公司，在这里也只是抱着重在参与的想法。在以后我所讲述到的内容知识点上如有不适之处请大家多多批评指教。 在一开始接触PHP接触MYSQL的时候就听不少人说：“Mysql就跑跑一天几十万IP的小站还可以，要是几百万IP就不行了”，原话不记得 了，大体就是这个意思。一直也没有好的机会去验证这个说法，一是从没有接手过这么大流量的网站，二是平时工作也比较忙，懒得去管这些，反正现在用不着，抱 着这个想法把这个问题一直留到了最近，才把这个问题搞明白。 就在前几天公司旗下一网站(由于这是公司的商业内容我就不说是那个网站了，免得有兄弟说是AD)以下简称A站，这A站在年后流量猛增从一天的七八十万猛跑到了好几百万的IP，一天下来接近一千万的Pv让整个服务器在高压下超负荷的工作着，时不时的服务就出现当机。 最首先反映出情况的是数据统计，一天下来一个数据也没有统计上，原来是mysql挂了。 本文就围绕这个问题来讲讲我们公司几个技术人员的解决方案。 1. Mysql服务器集群 由于是小公司在资金和成本上都有所限制，而且在技术上也没有几个技术员接触过，所以这个方法自然就让大伙否决了。 这里说说我个人的理解!做集群不但添加资费的开销，而且在技术上也有很大的挑战，对于我们公司目前的情况是不大现实的。集群无非就是把一台服务器的压力转接到两台或是多台服务器上，我是这么理解的，也许我理解有误，还请大家指教。 2. 分而治之 这个方法和集群差不多，不过是把统计的代码放在不同的服务器上跑，由于公司有不少配置低的服务器跑几万到几十万IP还是没有问题的，我们可以把几百万流量分成十来个几十万的量分而统计。 优点：充分的利用了现在的资源，解决了目前的问题。 缺点：这样的方法不是长久之计，迟早还是会出问题的。而且在统计数据的时候比较麻烦。 3. 统计代码的修改 由于之前采用的是在插入数据之前加以判断，这个IP是否存在，来路等的处理，无形中增加了服务器的压力，所以大伙把统计代码改成来一个就插入数据库，不管三七二十一等以后在处理。 这个方法基本上把当天的数据保留下来了，可是在处理的时候由于数据量的庞大，来来回回还是把服务器跑死了，而且在插入的时候由于当时设计数据结构的时候留有的索引，也大大的消耗了不少的服务器资源。 那么把索引去掉到最后处理的时候又是老慢的，得不偿失。 4. 统计方式的修改 最后这一个方法，效果非常的明显。那是什么方法呢! 这里就主要介绍这个方法： A、 保留原用的数据结构不变，并把所有的数据按一定的结构存入文件。 结构：可以是xml,json，也可以是你自己想的任何有规律的数据排放。 例如 1 221.2.70.52,http://www.baidu.com,windowxp\r\n 2 221.2.70.52,http://www.baidu.com,windowxp\r\n 写入文件:fopen，fwrite??no 这里介绍一个非常好用的技巧，也许大家都知道，但是像我这样的菜鸟大概都不知道，那就是用error_log，这不是写错误日志的吗?对就是他，非常方便。 error_log(&#8220;内容&#8221;, 3, &#8220;/date.dat&#8221;); 这里我就不说他的具体用了，不明白的朋友可以查一下手册。 B、数据文件的命名 为什么这里要讲文件的命名呢?如果就一味的把数据的写入文件不作任何的处理那么他和直接插入数据库有多大的区别呢?那么我们所作的一切都是无用功了。 首先是在时间的利用上:date(‘YmdH’)得到的值是如：2008121112这有什么好入，这样一来这个数据就是一个小时一个文件必免了文件过大，而且不用去判断自动生成。 IP的应用：由于在很多数据上都是一个IP操作的，所以把相同IP的数据放在一个文件里在后面的处理就非常方便处理。请看后面的介绍，这里我们取IP成三位为文件名字的一部分。 C、 数据的导入处理 通过以上两位的操作当天的数据会一个不少的保留下来，接下来怎么处理其实并不是很重要了。但是这里还是讲讲我的想法。 入库前处理： 前面讲到把IP三位相同的放一个文件就是为了入库前到它们进行处理，首先可以用最笨的方法把数据拆成N个数据。在进行重复数据的删除。 如果一个IP浏览多页那么PV在这里就可以得到统计，并把访问的页面进行处理，组成新的数据。 导入方法： 这里要介绍一下数据的导入方法 $sql [...]]]></description>
		<wfw:commentRss>http://blog.eood.cn/%e7%99%be%e4%b8%87%e7%ba%a7%e9%ab%98%e5%b9%b6%e5%8f%91%e7%bd%91%e7%ab%99mysql%e5%ba%94%e7%94%a8%e6%94%bb%e7%95%a5/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
