<?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>MySQL and MongoDB DBA</title>
	<atom:link href="http://www.realzyy.com/?feed=rss2&#038;p=1191" rel="self" type="application/rss+xml" />
	<link>http://www.realzyy.com</link>
	<description>Alipay, Hangzhou</description>
	<lastBuildDate>Mon, 13 May 2013 13:20:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>How Much Network Traffic Does A MySQL Query Consume?</title>
		<link>http://www.realzyy.com/?p=1571</link>
		<comments>http://www.realzyy.com/?p=1571#comments</comments>
		<pubDate>Fri, 29 Mar 2013 03:40:15 +0000</pubDate>
		<dc:creator>realzyy</dc:creator>
				<category><![CDATA[Database Theory]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL Internals]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[consume]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[traffic]]></category>

		<guid isPermaLink="false">http://www.realzyy.com/?p=1571</guid>
		<description><![CDATA[Have you ever wondered how much network traffic was caused by a query with a  specific data set? In this post, I would like to share some research I did for stress testing network. During the whole test, I used mysqlslap to simulate a kv query. it&#8217;s like the following SQL: SELECT UUID() as data1, UUID() as data2, UUID() [...]]]></description>
				<content:encoded><![CDATA[<p style="text-align: left;">Have you ever wondered how much network traffic was caused by a query with a  specific data set? In this post, I would like to share some research I did for stress testing network. During the whole test, I used mysqlslap to simulate a kv query. it&#8217;s like the following SQL:</p>
<pre class="brush: sql; gutter: true">SELECT UUID() as data1, UUID() as data2, UUID() as data3, UUID() as data4, 
UUID() as data5, UUID() as data6, UUID() as data7, UUID() as data8, 
UUID() as data9, UUID() as data10, UUID() as data11, UUID() as data12, 
UUID() as data13, UUID() as data14, UUID() as data15, UUID() as data16,
UUID() as data17, UUID() as data18, UUID() as data19, UUID() as data20,
UUID() as data21, UUID() as data22, UUID() as data23, UUID() as data24,
UUID() as data25, UUID() as data26, UUID() as data27, UUID() as data28,
UUID() as data29, UUID() as data30, UUID() as data31, UUID() as data32</pre>
<p style="text-align: left;">It has 32 fileds, and every one of them is 36 bytes long, which makes the whole record 1152 bytes.</p>
<p style="text-align: left;">MySQL can hardly utilize  all the cpu and network traffic, so I started four MySQL instances on one machine and four clients remotely. After warm-up period, I captured realtime network traffic with &#8216;sar -n DEV&#8217;:<br />
<a href="http://www.realzyy.com/wp-content/uploads/2013/03/network.png"><img class="aligncenter size-full wp-image-1603" alt="network" src="http://www.realzyy.com/wp-content/uploads/2013/03/network.png" width="642" height="77" /></a>QPS for each instance are 12823, 12936, 13153 and 13123. Basicly 2370 byte per query.</p>
<p style="text-align: left;">We all know its original size is just 1152 bytes, so that&#8217;s a surprisingly expensive query! Let&#8217;s dig a little deeper to see what the hell happens inside. Read chapter &#8221;Client/Server Communication&#8221; of &#8220;Understanding MySQL Internals&#8221; carefully, the knowledge there is still updated (although it&#8217;s 6 years old already). Usually ppl are too lazy to read it by themselves, so I summarized it a little.</p>
<p style="text-align: left;">There are four kinds of packets sent from server to client:</p>
<ol style="text-align: left;">
<li>OK Packet</li>
<li>Error Packet</li>
<li>EOF Packet</li>
<li>Result Set Packets (NOTICE: plural)</li>
</ol>
<p style="text-align: left;">Result Set Packets contain field definition sequence of packets and data packets.</p>
<p style="text-align: left;">After server receives a query, it responses client with result Set packets as following sequence:</p>
<ol style="text-align: left;">
<li>A packet with the body consisting of the standard field-length specifier sequence</li>
<li>A group of field description packets, one for each field, in the field order of the result set</li>
<li>EOF packet</li>
<li>Row data packets, one packet per row</li>
<li>EOF packet</li>
</ol>
<p style="text-align: left;">Before finding out what&#8217;s inside every packet, we need to learn an important definition called &#8220;Data Field&#8221; first. Basicly, every field in MySQL packet is abstracted as &#8221;Data Field&#8221;, and the length of &#8220;Data Field&#8221; is like the following table:<br />

<table id="wp-table-reloaded-id-6-no-1" class="wp-table-reloaded wp-table-reloaded-id-6">
<thead>
	<tr class="row-1 odd">
		<th class="column-1">Length of Actual Data (N Byte)</th><th class="column-2">Length specifier sequence</th><th class="column-3">Length of Data Field</th>
	</tr>
</thead>
<tbody>
	<tr class="row-2 even">
		<td class="column-1">N < 251 Byte</td><td class="column-2">1 Byte<br />
</td><td class="column-3">(1 + N) Byte<br />
</td>
	</tr>
	<tr class="row-3 odd">
		<td class="column-1">N < 65536 Byte</td><td class="column-2">2 Byte</td><td class="column-3">(2 + N) Byte</td>
	</tr>
	<tr class="row-4 even">
		<td class="column-1">N < 16777216 Byte</td><td class="column-2">3 Byte</td><td class="column-3">(3 + N) Byte</td>
	</tr>
	<tr class="row-5 odd">
		<td class="column-1">N >= 16777216 Byte</td><td class="column-2">8 Byte</td><td class="column-3">(8 + N) Byte</td>
	</tr>
</tbody>
</table>
<br />
According to the table we define a function called &#8220;length_of_data_filed&#8221;:</p>
<pre class="brush: c; gutter: true">Function length_of_data_filed(data)
{
  If (length(data) &lt; 251)
    return (length(data)+1);
  else if (length(data) &lt; 65536)
    return (length(data)+2);
  else if (length(data) &lt; 16777216)
    return (length(data)+3);
  else
    return (length(data)+4);
}</pre>
<p style="text-align: left;">Here comes the length of packets:</p>
<ol style="text-align: left;">
<li>Standard Field-length Specifier Sequence Packet, 1 byte</li>
<li>Field Description Packet, 17 + length_of_data_filed(db_name) + length_of_data_filed(table_name) + length_of_data_filed(alias_table_name) + length_of_data_filed(column_name) + length_of_data_filed(alias_column_name) + length_of_data_filed(default_value)</li>
<li>Row Data Packet, length_of_data_filed(field1) + length_of_data_filed(field2) + … + length_of_data_filed(fieldn)</li>
<li>EOF Packet, 5 bytes</li>
</ol>
<p><span id="more-1571"></span><br />
To verify if the knowledge in  &#8221;Understanding MySQL Internals&#8221; is updated, I used Wireshark to analyze packets captured by tcpdump on Linux server. The whole analysis is shown as below:</p>
<p>Ethernet II protocol costs 14 byte, IP V4 costs 20 bytes, and TCP costs 20 bytes too</p>
<p><em id="__mceDel"> <a href="http://www.realzyy.com/wp-content/uploads/2013/03/ethernet.png"><img class="aligncenter size-full wp-image-1615" alt="ethernet" src="http://www.realzyy.com/wp-content/uploads/2013/03/ethernet.png" width="872" height="582" /></a></em></p>
<p><a href="http://www.realzyy.com/wp-content/uploads/2013/03/ipv4.png"><img class="aligncenter size-full wp-image-1616" alt="ipv4" src="http://www.realzyy.com/wp-content/uploads/2013/03/ipv4.png" width="1062" height="530" /></a></p>
<p style="text-align: left;">One TCP packet can contain several MySQL packets, but it depends on MySQL packet size. In my kv query case, one TCP packet is big enough to hold many MySQL packets. Usually it costs 4 bytes to delimit MySQL packets inside TCP packet. One byte is used to describe the sequence of MySQL packet, and the rest 3 bytes are used for delimiter.<br />
<a href="http://www.realzyy.com/wp-content/uploads/2013/03/packet_num.png"><img class="aligncenter size-full wp-image-1618" alt="packet_num" src="http://www.realzyy.com/wp-content/uploads/2013/03/packet_num.png" width="601" height="453" /></a><a href="http://www.realzyy.com/wp-content/uploads/2013/03/packet_delimiter.png"><img class="aligncenter size-full wp-image-1617" alt="packet_delimiter" src="http://www.realzyy.com/wp-content/uploads/2013/03/packet_delimiter.png" width="603" height="645" /></a></p>
<p style="text-align: left;">Standard Field-length Specifier Sequence Packet<br />
<a href="http://www.realzyy.com/wp-content/uploads/2013/03/Standard_Field-length_Specifier_Sequence_Packet.png"><img class="aligncenter size-full wp-image-1622" alt="Standard_Field-length_Specifier_Sequence_Packet" src="http://www.realzyy.com/wp-content/uploads/2013/03/Standard_Field-length_Specifier_Sequence_Packet.png" width="659" height="444" /></a></p>
<p style="text-align: left;">Field Description Packet</p>
<p style="text-align: left;"><a href="http://www.realzyy.com/wp-content/uploads/2013/03/Field_Description_Packet.png"><img class="aligncenter size-full wp-image-1620" alt="Field_Description_Packet" src="http://www.realzyy.com/wp-content/uploads/2013/03/Field_Description_Packet.png" width="606" height="390" /></a></p>
<p style="text-align: left;">Row Data Packet</p>
<p style="text-align: left;"><a href="http://www.realzyy.com/wp-content/uploads/2013/03/Row_Data_Packet.png"><img class="aligncenter size-full wp-image-1621" alt="Row_Data_Packet" src="http://www.realzyy.com/wp-content/uploads/2013/03/Row_Data_Packet.png" width="605" height="1367" /></a></p>
<p style="text-align: left;">EOF Packet</p>
<p style="text-align: left;"><a href="http://www.realzyy.com/wp-content/uploads/2013/03/EOF_Packet.png"><img class="aligncenter size-full wp-image-1619" alt="EOF_Packet" src="http://www.realzyy.com/wp-content/uploads/2013/03/EOF_Packet.png" width="600" height="786" /></a></p>
<p style="text-align: left;">Honestly speaking, it&#8217;s very hard to analyze network traffic precisely, because TCP  behavior varies greatly along with the change of MySQL packet&#8217;s size. However it&#8217;s easy if we assume that only one record will be returned for one query, which means kv query. Assuming the length of record is k bytes,  no alias name is used and no default vaule is set either, we get the formula of network traffic caused by kv query :</p>
<pre class="brush: c; gutter: true">Field definition sequence of packets + Data packets
= (21 + length_of_data_filed(db_name) + length_of_data_filed(table_name) + 1 + length_of_data_filed(column_name) + 1) * field_number + 68 + 4 + k + field_number + 63
= (24 + length_of_data_filed(db_name) + length_of_data_filed(table_name) + length_of_data_filed(column_name)) * field_number + k + 135</pre>
<p>That&#8217;s all, ^_^.<br />
But wait! why did I show you the experiment in the beginning of this post? Well, I left a little homework for ppl who want to know if the formula matches the network traffic in real life. So have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.realzyy.com/?feed=rss2&#038;p=1571</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Generate Globally Unique server_id for MySQL</title>
		<link>http://www.realzyy.com/?p=1589</link>
		<comments>http://www.realzyy.com/?p=1589#comments</comments>
		<pubDate>Mon, 25 Mar 2013 05:26:23 +0000</pubDate>
		<dc:creator>realzyy</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL Internals]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[global]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[server_id]]></category>
		<category><![CDATA[unique]]></category>

		<guid isPermaLink="false">http://www.realzyy.com/?p=1589</guid>
		<description><![CDATA[Let&#8217;s assume that you have a lot of machines running multiple MySQL instances. Is it a little troublesome to remember all the server_id in case of having a server_id confliction when we build a MySQL cluster? Which makes it even worse is that some of us have several IDC in different areas. Can we have an [...]]]></description>
				<content:encoded><![CDATA[<p>Let&#8217;s assume that you have a lot of machines running multiple MySQL instances. Is it a little troublesome to remember all the server_id in case of having a server_id confliction when we build a MySQL cluster? Which makes it even worse is that some of us have several IDC in different areas. Can we have an easy way to generate globally unique server_id based on IP address and port?</p>
<p>I am sorry to tell you, that&#8217;s not possible without limitation. So the problem becomes how can we generate server_id  most uniquely.<br />
server_id is a 32-bit int in MySQL, and IP address is represented as a 32-bit int in C too. To record port information into a 32-bit int, we need to ignore some bits from the head of IP address which are always the same to us. Here is my way to do it in Linux:</p>
<pre class="brush: shell; gutter: true">#!/bin/bash

hostip=`hostname -i`
a=`echo $hostip|cut -d\. -f1`
b=`echo $hostip|cut -d\. -f2`
c=`echo $hostip|cut -d\. -f3`
d=`echo $hostip|cut -d\. -f4`
port=65 #Change this in your code

echo &quot;${a}.${b}.${c}.${d}&quot;
serverid=`expr \( ${a} \* 256 \* 256 \* 256 + ${b} \* 256 \* 256 + ${c} \* 256 + ${d} \)`
echo ${serverid}

serverid=$((${serverid} &lt;&lt; 6))
serverid=`expr ${serverid} % 4294967296`
echo ${serverid}

serverid=`expr ${serverid} + \( ${port} % 64 \)`
echo ${serverid} #Yeah, here we go</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.realzyy.com/?feed=rss2&#038;p=1589</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>my.cnf for MySQL 5.5 on Linux 2.6.32</title>
		<link>http://www.realzyy.com/?p=1582</link>
		<comments>http://www.realzyy.com/?p=1582#comments</comments>
		<pubDate>Thu, 21 Mar 2013 22:18:32 +0000</pubDate>
		<dc:creator>realzyy</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL Performance]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[2.6.32]]></category>
		<category><![CDATA[5.5.18]]></category>
		<category><![CDATA[6.2]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[my.cnf]]></category>
		<category><![CDATA[Redhat]]></category>

		<guid isPermaLink="false">http://www.realzyy.com/?p=1582</guid>
		<description><![CDATA[Yeah, I am gonna do a good thing for all MySQL DBAs. Here  is a  configuration example for  multi MySQL instances running on Redhat or CentOS 6: [mysqld_safe] pid-file=/mysql/myPORT/run/mysqld.pid [mysql] port=PORT prompt=\\u@\\d \\r:\\m:\\s&#62; default-character-set=gbk [client] port=PORT socket=/mysql/myPORT/run/mysql.sock [mysqld] #dir basedir=/mysql/myPORT datadir=/mysql/myPORT/data tmpdir=/mysql/myPORT/tmp lc_messages_dir=/usr/share log-error=/mysql/myPORT/log/alert.log slow_query_log_file=/mysql/myPORT/log/slow.log socket=/mysql/myPORT/run/mysql.sock #innodb innodb_data_home_dir=/mysql/myPORT/log/iblog innodb_log_group_home_dir=/mysql/myPORT/log/iblog innodb_buffer_pool_size=INNODB_BUFFER_POOL_SIZE innodb_buffer_pool_instances=8 innodb_log_files_in_group=4 innodb_log_file_size=1G innodb_log_buffer_size=64M innodb_flush_log_at_trx_commit=1 innodb_additional_mem_pool_size=20M [...]]]></description>
				<content:encoded><![CDATA[<p>Yeah, I am gonna do a good thing for all MySQL DBAs.</p>
<p>Here  is a  configuration example for  multi MySQL instances running on Redhat or CentOS 6:</p>
<pre class="brush: bash; gutter: true">[mysqld_safe]
pid-file=/mysql/myPORT/run/mysqld.pid
[mysql]
port=PORT
prompt=\\u@\\d \\r:\\m:\\s&gt;
default-character-set=gbk

[client]
port=PORT
socket=/mysql/myPORT/run/mysql.sock

[mysqld]
#dir
basedir=/mysql/myPORT
datadir=/mysql/myPORT/data
tmpdir=/mysql/myPORT/tmp
lc_messages_dir=/usr/share
log-error=/mysql/myPORT/log/alert.log
slow_query_log_file=/mysql/myPORT/log/slow.log
socket=/mysql/myPORT/run/mysql.sock

#innodb
innodb_data_home_dir=/mysql/myPORT/log/iblog
innodb_log_group_home_dir=/mysql/myPORT/log/iblog
innodb_buffer_pool_size=INNODB_BUFFER_POOL_SIZE
innodb_buffer_pool_instances=8
innodb_log_files_in_group=4
innodb_log_file_size=1G
innodb_log_buffer_size=64M
innodb_flush_log_at_trx_commit=1
innodb_additional_mem_pool_size=20M
innodb_max_dirty_pages_pct=60
innodb_io_capacity=INNODB_IO_CAPACITY
innodb_thread_concurrency=THREADBY4
innodb_read_io_threads=THREAD
innodb_write_io_threads=THREAD
innodb_open_files=60000
innodb_file_format=Barracuda
innodb_file_per_table=1
innodb_flush_method=O_DIRECT
innodb_flush_neighbor_pages=0
innodb_change_buffering=inserts
innodb_adaptive_flushing=1
innodb_adaptive_flushing_method=keep_average
innodb_adaptive_hash_index_partitions=8
innodb_old_blocks_time=1000
innodb_fast_checksum=1
innodb_stats_on_metadata=0
innodb_lazy_drop_table=1
innodb_read_ahead=&quot;linear&quot;
innodb_use_native_aio=1
innodb_lock_wait_timeout=5
innodb_rollback_on_timeout=0
#innodb_strict_mode=1
transaction-isolation=READ-COMMITTED

#myisam
key_buffer=64M
myisam_sort_buffer_size=64M
concurrent_insert=2
delayed_insert_timeout=300

#replication
master-info-file=/mysql/myPORT/log/master.info
relay-log=/mysql/myPORT/log/relaylog
relay_log_info_file=/mysql/myPORT/log/relay-log.info
slave_load_tmpdir=/mysql/myPORT/tmp
slave_type_conversions=&quot;ALL_NON_LOSSY&quot;
slave_net_timeout=4
skip-slave-start

#binlog
log-bin=/mysql/myPORT/log/binlog
server_id=1153668
binlog_cache_size=32K
max_binlog_cache_size=2G
max_binlog_size=500M
binlog-format=ROW
sync_binlog=1
log-slave-updates
expire_logs_days=7

#server
default-storage-engine=INNODB
character-set-server=gbk
lower_case_table_names=1
skip-external-locking
open_files_limit=65536
safe-user-create
local-infile=0
#sqlmod=&quot;STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE&quot;
performance_schema=0
log_slow_admin_statements=1
log_slow_verbosity=full
log_warnings=1
long_query_time=1
slow_query_log=1
query_cache_type=0
query_cache_limit=1M
query_cache_min_res_unit=1K
table_definition_cache=65536
table_cache=65536
thread_stack=512K
thread_cache_size=256
read_rnd_buffer_size=128K
sort_buffer_size=256K
join_buffer_size=128K
read_buffer_size=128K
port=PORT
skip-name-resolve
skip-ssl
max_connections=8192
max_user_connections=8000
max_connect_errors=65536
max_allowed_packet=128M
max_long_data_size=128M
connect_timeout=8
net_read_timeout=30
net_write_timeout=60
back_log=1024</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.realzyy.com/?feed=rss2&#038;p=1582</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>毛豆的第一个月</title>
		<link>http://www.realzyy.com/?p=1550</link>
		<comments>http://www.realzyy.com/?p=1550#comments</comments>
		<pubDate>Wed, 19 Dec 2012 11:26:52 +0000</pubDate>
		<dc:creator>realzyy</dc:creator>
				<category><![CDATA[My Life]]></category>

		<guid isPermaLink="false">http://www.realzyy.com/?p=1550</guid>
		<description><![CDATA[2012年12月4号的下午三点半，毛豆小朋友在常熟第一人民医院出生了。 可怜的妈妈早上九点多就被推到产房，下午出来整个人都虚脱了。 出生的第一天，毛豆同学只张开了一只眼睛，样子看起来好挫哦！不过第二天一大早洗了澡之后，就变得稍微可爱了一些。 奇怪的是，怎么看起来像个男胖子呢？ 大家都说毛都长得像粑粑，但是为什么越看越像范伟呢………………………… 奶奶老是觉得毛豆很冷，于是穿上了麻麻小时候的花棉袄，一股乡土气息扑面而来………… 为什么看起来这么像村中一霸？！ 可怜的毛豆，穿得太多结果得了湿疹，于是又换上了gap的战袍~（还是一个小胖子！） 虽然只有两个星期大，但已经是一个赤果果的表情帝了~  18天，双眼皮已经很明显了。随访的阿姨说体重涨到了8斤。 再来两张！脸上肉多的挂不住了！ 再过两天就满三个月啦，天天要妈妈竖着抱，天天咿咿呀呀的小胖子。 妈妈最喜欢乖宝宝 每次醒来发现旁边没人，毛豆就会哭得很可怜。 四个半月啦，越来越像爸爸小时候了。 五个月啦！]]></description>
				<content:encoded><![CDATA[<p>2012年12月4号的下午三点半，毛豆小朋友在常熟第一人民医院出生了。</p>
<p style="text-align: left;">可怜的妈妈早上九点多就被推到产房，下午出来整个人都虚脱了。<br />
<a href="http://www.realzyy.com/wp-content/uploads/2012/12/cry_baby.jpg"><br />
</a><img class=" wp-image-1551 aligncenter" alt="delivery" src="http://www.realzyy.com/wp-content/uploads/2012/12/照片-001.jpg" width="384" height="512" /></p>
<p style="text-align: left;">出生的第一天，毛豆同学只张开了一只眼睛，样子看起来好挫哦！不过第二天一大早洗了澡之后，就变得稍微可爱了一些。<br />
奇怪的是，怎么看起来像个男胖子呢？<span id="more-1550"></span><br />
<a href="http://www.realzyy.com/wp-content/uploads/2012/12/照片-003.jpg"><img class="aligncenter  wp-image-1552" alt="second_day" src="http://www.realzyy.com/wp-content/uploads/2012/12/照片-003.jpg" width="384" height="287" /></a></p>
<p style="text-align: left;">大家都说毛都长得像粑粑，但是为什么越看越像范伟呢…………………………<br />
<a href="http://www.realzyy.com/wp-content/uploads/2012/12/照片-004.jpg"><img class="aligncenter  wp-image-1553" alt="fanwei" src="http://www.realzyy.com/wp-content/uploads/2012/12/照片-004-1024x764.jpg" width="430" height="321" /></a></p>
<p style="text-align: left;">奶奶老是觉得毛豆很冷，于是穿上了麻麻小时候的花棉袄，一股乡土气息扑面而来…………<br />
为什么看起来这么像村中一霸？！<br />
<a href="http://www.realzyy.com/wp-content/uploads/2012/12/-007-e1355915933537.jpg"><img class="aligncenter  wp-image-1554" alt="farmer" src="http://www.realzyy.com/wp-content/uploads/2012/12/-007-e1355915933537-1024x764.jpg" width="430" height="321" /></a></p>
<p style="text-align: left;">可怜的毛豆，穿得太多结果得了湿疹，于是又换上了gap的战袍~（还是一个小胖子！）</p>
<p style="text-align: center;"><a href="http://www.realzyy.com/wp-content/uploads/2012/12/照片-009.jpg"><img class="aligncenter  wp-image-1555" alt="eczema" src="http://www.realzyy.com/wp-content/uploads/2012/12/照片-009-764x1024.jpg" width="413" height="553" /></a></p>
<p style="text-align: left;">虽然只有两个星期大，但已经是一个赤果果的表情帝了~<a href="http://www.realzyy.com/wp-content/uploads/2012/12/照片-013.jpg"><br />
<img class="aligncenter  wp-image-1556" alt="smile" src="http://www.realzyy.com/wp-content/uploads/2012/12/-013-e1355916322480-764x1024.jpg" width="413" height="553" /></a></p>
<p style="text-align: left;"> 18天，双眼皮已经很明显了。随访的阿姨说体重涨到了8斤。<br />
<a href="http://www.realzyy.com/wp-content/uploads/2012/12/IMG_4011.jpg"><img class="aligncenter  wp-image-1561" alt="IMG_4011" src="http://www.realzyy.com/wp-content/uploads/2012/12/IMG_4011-e1356176826636-764x1024.jpg" width="458" height="614" /></a></p>
<p style="text-align: left;">再来两张！脸上肉多的挂不住了！<br />
<a href="http://www.realzyy.com/wp-content/uploads/2012/12/IMG_4009.jpg"><img class="aligncenter  wp-image-1564" alt="IMG_4009" src="http://www.realzyy.com/wp-content/uploads/2012/12/IMG_4009-e1356177271314-764x1024.jpg" width="458" height="614" /><br />
</a><a href="http://www.realzyy.com/wp-content/uploads/2012/12/IMG_40131.jpg"><img class="aligncenter  wp-image-1566" alt="IMG_4013" src="http://www.realzyy.com/wp-content/uploads/2012/12/IMG_40131-e1356177701466-764x1024.jpg" width="458" height="614" /></a></p>
<p style="text-align: left;">再过两天就满三个月啦，天天要妈妈竖着抱，天天咿咿呀呀的小胖子。<br />
<a href="http://www.realzyy.com/wp-content/uploads/2012/12/IMG_0024.jpg"><img class="aligncenter size-full wp-image-1575" alt="IMG_0024" src="http://www.realzyy.com/wp-content/uploads/2012/12/IMG_0024.jpg" width="458" height="609" /><br />
</a><a href="http://www.realzyy.com/wp-content/uploads/2012/12/IMG_0033.jpg"><img class="aligncenter size-full wp-image-1576" alt="IMG_0033" src="http://www.realzyy.com/wp-content/uploads/2012/12/IMG_0033.jpg" width="458" height="613" /></a></p>
<p style="text-align: left;">妈妈最喜欢乖宝宝<br />
<a href="http://www.realzyy.com/wp-content/uploads/2012/12/summer.jpg"><img class="aligncenter size-full wp-image-1578" alt="summer" src="http://www.realzyy.com/wp-content/uploads/2012/12/summer.jpg" width="458" height="613" /></a></p>
<p style="text-align: left;">每次醒来发现旁边没人，毛豆就会哭得很可怜。<br />
<a href="http://www.realzyy.com/wp-content/uploads/2012/12/cry_baby.jpg"><img class="aligncenter size-full wp-image-1596" alt="cry_baby" src="http://www.realzyy.com/wp-content/uploads/2012/12/cry_baby.jpg" width="458" height="612" /></a></p>
<p style="text-align: left;">四个半月啦，越来越像爸爸小时候了。<br />
<a href="http://www.realzyy.com/wp-content/uploads/2012/12/morning.jpg"><img class="aligncenter size-full wp-image-1646" alt="morning" src="http://www.realzyy.com/wp-content/uploads/2012/12/morning.jpg" width="458" height="613" /></a><a href="http://www.realzyy.com/wp-content/uploads/2012/12/bigface.jpg"><img class="aligncenter size-full wp-image-1645" alt="bigface" src="http://www.realzyy.com/wp-content/uploads/2012/12/bigface.jpg" width="458" height="589" /></a></p>
<p style="text-align: left;">
<p style="text-align: left;">五个月啦！<br />
<a href="http://www.realzyy.com/wp-content/uploads/2012/12/smile.jpg"><img class="aligncenter size-full wp-image-1649" alt="smile" src="http://www.realzyy.com/wp-content/uploads/2012/12/smile.jpg" width="458" height="611" /></a><a href="http://www.realzyy.com/wp-content/uploads/2012/12/smile3.jpg"><img class="aligncenter size-full wp-image-1650" alt="smile3" src="http://www.realzyy.com/wp-content/uploads/2012/12/smile3.jpg" width="481" height="640" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.realzyy.com/?feed=rss2&#038;p=1550</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HandlerSocket Errors and Solutions</title>
		<link>http://www.realzyy.com/?p=1538</link>
		<comments>http://www.realzyy.com/?p=1538#comments</comments>
		<pubDate>Thu, 04 Oct 2012 02:45:24 +0000</pubDate>
		<dc:creator>realzyy</dc:creator>
				<category><![CDATA[MySQL Error]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[167]]></category>
		<category><![CDATA[auto increment]]></category>
		<category><![CDATA[DDL]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[HandlerSocket]]></category>
		<category><![CDATA[HNDSOCK failed to lock tables]]></category>
		<category><![CDATA[timeout]]></category>

		<guid isPermaLink="false">http://www.realzyy.com/?p=1538</guid>
		<description><![CDATA[HandlerSocket is well known as a MySQL NoSQL plugin which provides user a much better performance without losing SQL features as some other NoSQL database do. But honestly speaking, not all the fancy software would have a lot of users. Most of the time people just forward posts and blogs without trying to use the [...]]]></description>
				<content:encoded><![CDATA[<p><a title="HandlerSocket" href="http://yoshinorimatsunobu.blogspot.sg/search/label/handlersocket" target="_blank">HandlerSocket</a> is well known as a MySQL NoSQL plugin which provides user a much better performance without losing SQL features as some other NoSQL database do.<br />
But honestly speaking, not all the fancy software would have a lot of users. Most of the time people just forward posts and blogs without trying to use the amazing thing first.<br />
The problem HandlerSocket has is that we can merely find any blogs talking about how to tune or troubleshoot it. Based on my little experience of HandlerSocket, today I would like to share some problems we had encountered. And this post will be updated according to the future usage.</p>
<p>1. MySQL error code 167: Failed to set row auto increment value<br />
This error is due to a HandlerSocket bug. If you can understand Chinese, please read <a title="HandlerSocket返回错误码167的bug分析" href="http://blog.zephyrleaves.net/?p=391" target="_blank">this post</a> written by Ruohui Huang.<br />
The solution here is very easy: set innodb_autoinc_lock_mode to 0.</p>
<p>2. HNDSOCK failed to lock tables<br />
If you try to use HandlerSocket API to update a read-only InnoDB table, this message will appear in the error log.</p>
<p>3. DDL timeout<br />
It is very hard to do DDL on HandlerSocket enabled tables beacause it keeps tables opened for reuse. Even HandlerSocket in <a title="Percona Server" href="http://www.percona.com/software/percona-server/downloads/" target="_blank">Percona server</a> would close tables when traffics become small, there is definitely no parameter to control this behaviour. If you are suffering from this DDL problem, maybe you can try HandlerSocket in <a title="Spider Server" href="http://spiderformysql.com/" target="_blank">Spider server</a>. There is a parameter named handlersocket_close_table_interval, hope it&#8217;s helpful to you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.realzyy.com/?feed=rss2&#038;p=1538</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How Many EBS Volumes Can We Attach?</title>
		<link>http://www.realzyy.com/?p=1529</link>
		<comments>http://www.realzyy.com/?p=1529#comments</comments>
		<pubDate>Fri, 28 Sep 2012 09:39:28 +0000</pubDate>
		<dc:creator>realzyy</dc:creator>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[attach]]></category>
		<category><![CDATA[best]]></category>
		<category><![CDATA[EBS]]></category>
		<category><![CDATA[mdadm]]></category>
		<category><![CDATA[MySQL Performance]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[RAID]]></category>

		<guid isPermaLink="false">http://www.realzyy.com/?p=1529</guid>
		<description><![CDATA[As we discussed here, A RAID built on many standard volumes can provide a much better performance than a provisioned IOPS volume. Now the question is, how many volumes can we attach to a single EC2 instance? Amazon&#8217;s EBS limitations are quoted here (Linux): 1. /dev/sd[a-z], except /dev/sd[b-e] 2. /dev/sd[a-z][1-15], except /dev/sda1 3. /dev/hd[a-z] 4. [...]]]></description>
				<content:encoded><![CDATA[<p>As we discussed <a href="http://www.realzyy.com/?p=1517" target="_blank">here</a>, A RAID built on many standard volumes can provide a much better performance than a provisioned IOPS volume. Now the question is, how many volumes can we attach to a single EC2 instance?<br />
Amazon&#8217;s EBS limitations are quoted <a title="EBS attach" href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/ebs-attaching-volume.html" target="_blank">here</a> (Linux):<br />
1. /dev/sd[a-z], except /dev/sd[b-e]<br />
2. /dev/sd[a-z][1-15], except /dev/sda1<br />
3. /dev/hd[a-z]<br />
4. /dev/hd[a-z][1-15]</p>
<p>But actually I fount that you cannot use /dev/sd[f-i] and /dev/sda1 only, and all of the EBS attached will be renamed by Redhat internally.<br />
So the conclusion is, we can attach 26-3+26*15-1+26+26*15=828 volumes!</p>
<p>But wait, even attaching many volumes will provide a better performance, do we need to attach so many volumes?<br />
Of course not! mdadm, the soft raid used in Ec2 instance, cannot deal with too many disks at the same time. Maybe mdadm does not support mutil-thread very well, or there is some other bottle necks in the soft RAID, the best performance will be gained if we use 16 or less volumes under soft RAID.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.realzyy.com/?feed=rss2&#038;p=1529</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amazon Provisioned IOPS Volume or Not?</title>
		<link>http://www.realzyy.com/?p=1517</link>
		<comments>http://www.realzyy.com/?p=1517#comments</comments>
		<pubDate>Thu, 27 Sep 2012 07:05:19 +0000</pubDate>
		<dc:creator>realzyy</dc:creator>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[EBS]]></category>
		<category><![CDATA[Provisioned IOPS]]></category>
		<category><![CDATA[standard]]></category>
		<category><![CDATA[volume]]></category>

		<guid isPermaLink="false">http://www.realzyy.com/?p=1517</guid>
		<description><![CDATA[Some people think provisioned IOPS volume is a saver of IO intense EC2 instance. But according to its price, I&#8217;d rather say it&#8217;s just pointless to use it. Check the performance/cost table here: Standard Volume can cost more money because Amazon charges 0.12$ per 1 million IO, but usually this is just a little money. [...]]]></description>
				<content:encoded><![CDATA[<p>Some people think provisioned IOPS volume is a saver of IO intense EC2 instance. But according to its <a title="EBS Price" href="http://aws.amazon.com/ebs/" target="_blank">price</a>, I&#8217;d rather say it&#8217;s just pointless to use it.<br />
Check the performance/cost table here:<br />

<table id="wp-table-reloaded-id-5-no-1" class="wp-table-reloaded wp-table-reloaded-id-5">
<thead>
	<tr class="row-1 odd">
		<th class="column-1">EC2 m2.xlarge instance</th><th class="column-2">16k random read 4 threads</th><th class="column-3">16k random read 8 threads</th><th class="column-4">16k random write 4 threads</th><th class="column-5">16k random write 8 threads</th><th class="column-6">Cost /$</th>
	</tr>
</thead>
<tbody>
	<tr class="row-2 even">
		<td class="column-1">Provisioned IOPS Volume<br />
200G + 600 IOPS</td><td class="column-2">605.97 Reqs/sec<br />
6.60ms  </td><td class="column-3">602.03 Reqs/sec<br />
13.29ms</td><td class="column-4">585.58 Reqs/sec<br />
6.68ms</td><td class="column-5">580.20 Reqs/sec<br />
13.35ms</td><td class="column-6">102</td>
	</tr>
	<tr class="row-3 odd">
		<td class="column-1">Standard Volume<br />
128G*12 RAID 10</td><td class="column-2">438.96 Reqs/sec<br />
9.11ms</td><td class="column-3">814.10 Reqs/sec<br />
9.82ms</td><td class="column-4">2369.65 Reqs/sec<br />
1.58ms</td><td class="column-5">3150.93 Reqs/sec<br />
2.36ms</td><td class="column-6">184+</td>
	</tr>
	<tr class="row-4 even">
		<td class="column-1">Standard Volume<br />
16G*12 RAID 0</td><td class="column-2">1421.77 Reqs/sec<br />
2.81ms</td><td class="column-3">1023.57 Reqs/sec<br />
7.81ms</td><td class="column-4">3007.20 Reqs/sec<br />
1.24ms</td><td class="column-5">4954.73 Reqs/sec<br />
1.44ms</td><td class="column-6">23+</td>
	</tr>
</tbody>
</table>
<br />
Standard Volume can cost more money because Amazon charges 0.12$ per 1 million IO, but usually this is just a little money.</p>
<p>This series of tests were conducted on m2.xlarge instance by SysBench.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.realzyy.com/?feed=rss2&#038;p=1517</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Idle MySQL Use 100% CPU (Leap Second)</title>
		<link>http://www.realzyy.com/?p=1495</link>
		<comments>http://www.realzyy.com/?p=1495#comments</comments>
		<pubDate>Wed, 19 Sep 2012 09:19:15 +0000</pubDate>
		<dc:creator>realzyy</dc:creator>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[MySQL Performance]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[cpu]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[idle]]></category>
		<category><![CDATA[leap second]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[pthread_cond_timedwait]]></category>

		<guid isPermaLink="false">http://www.realzyy.com/?p=1495</guid>
		<description><![CDATA[It&#8217;s quite funny because I have never seen MySQL like this. I set up a MySQL replication several months ago, and we don&#8217;t use these production servers yet. So you can imagine how surprised I was when I saw  the CPU usage. Load is minor but MySQL uses 100% CPU in top. top - 08:50:55 [...]]]></description>
				<content:encoded><![CDATA[<p>It&#8217;s quite funny because I have never seen MySQL like this.</p>
<p>I set up a MySQL replication several months ago, and we don&#8217;t use these production servers yet. So you can imagine how surprised I was when I saw  the CPU usage. Load is minor but MySQL uses 100% CPU in top.</p>
<pre class="brush: bash; gutter: false">top - 08:50:55 up 114 days,  5:46,  1 user,  load average: 0.00, 0.00, 0.00
Tasks: 140 total,   1 running, 139 sleeping,   0 stopped,   0 zombie
Cpu(s): 13.7%us,  0.5%sy,  0.0%ni, 85.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  35128056k total,  6323556k used, 28804500k free,   351320k buffers
Swap:        0k total,        0k used,        0k free,  2927496k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                                                       
28879 mysql     20   0 29.9g 2.2g 5732 S 105.0  6.5 117807:11 mysqld</pre>
<p>I tried to restart one of the MySQL, but it didn&#8217;t help. After I restarted one of the servers, things changed.</p>
<pre class="brush: bash; gutter: false">top - 08:55:10 up  7:09,  2 users,  load average: 0.00, 0.00, 0.00
Tasks: 142 total,   1 running, 141 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.3%us,  0.4%sy,  0.0%ni, 99.3%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  35128056k total,  3169936k used, 31958120k free,    86580k buffers
Swap:        0k total,        0k used,        0k free,   297368k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                                                       
 3382 mysql     20   0 29.0g 2.1g 5188 S  0.0  6.4   0:22.37 mysqld</pre>
<p><span id="more-1495"></span><br />
pstack usually will tell us what&#8217;s going on in such a situation, but I fount that the normal and abnormal instances have similar stack:</p>
<pre class="brush: bash; gutter: false">Thread 19 (Thread 0x7f34c4048700 (LWP 28887)):
#0  0x0000003a5ca00614 in ?? () from /lib64/libaio.so.1
#1  0x00000000008fe503 in os_aio_linux_handle ()
#2  0x00000000008b2d78 in fil_aio_wait ()
#3  0x0000000000833940 in io_handler_thread ()
#4  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#5  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 18 (Thread 0x7f2dde25d700 (LWP 28888)):
#0  0x0000003a5ca00614 in ?? () from /lib64/libaio.so.1
#1  0x00000000008fe503 in os_aio_linux_handle ()
#2  0x00000000008b2d78 in fil_aio_wait ()
#3  0x0000000000833940 in io_handler_thread ()
#4  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#5  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 17 (Thread 0x7f2ddd85c700 (LWP 28889)):
#0  0x0000003a5ca00614 in ?? () from /lib64/libaio.so.1
#1  0x00000000008fe503 in os_aio_linux_handle ()
#2  0x00000000008b2d78 in fil_aio_wait ()
#3  0x0000000000833940 in io_handler_thread ()
#4  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#5  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 16 (Thread 0x7f2ddce5b700 (LWP 28890)):
#0  0x0000003a5ca00614 in ?? () from /lib64/libaio.so.1
#1  0x00000000008fe503 in os_aio_linux_handle ()
#2  0x00000000008b2d78 in fil_aio_wait ()
#3  0x0000000000833940 in io_handler_thread ()
#4  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#5  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 15 (Thread 0x7f2ddc45a700 (LWP 28891)):
#0  0x0000003a5ca00614 in ?? () from /lib64/libaio.so.1
#1  0x00000000008fe503 in os_aio_linux_handle ()
#2  0x00000000008b2d78 in fil_aio_wait ()
#3  0x0000000000833940 in io_handler_thread ()
#4  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#5  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 14 (Thread 0x7f2ddba59700 (LWP 28892)):
#0  0x0000003a5ca00614 in ?? () from /lib64/libaio.so.1
#1  0x00000000008fe503 in os_aio_linux_handle ()
#2  0x00000000008b2d78 in fil_aio_wait ()
#3  0x0000000000833940 in io_handler_thread ()
#4  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#5  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 13 (Thread 0x7f2ddb058700 (LWP 28893)):
#0  0x0000003a5ca00614 in ?? () from /lib64/libaio.so.1
#1  0x00000000008fe503 in os_aio_linux_handle ()
#2  0x00000000008b2d78 in fil_aio_wait ()
#3  0x0000000000833940 in io_handler_thread ()
#4  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#5  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 12 (Thread 0x7f2dda657700 (LWP 28894)):
#0  0x0000003a5ca00614 in ?? () from /lib64/libaio.so.1
#1  0x00000000008fe503 in os_aio_linux_handle ()
#2  0x00000000008b2d78 in fil_aio_wait ()
#3  0x0000000000833940 in io_handler_thread ()
#4  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#5  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 11 (Thread 0x7f2dd9c56700 (LWP 28895)):
#0  0x0000003a5ca00614 in ?? () from /lib64/libaio.so.1
#1  0x00000000008fe503 in os_aio_linux_handle ()
#2  0x00000000008b2d78 in fil_aio_wait ()
#3  0x0000000000833940 in io_handler_thread ()
#4  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#5  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 10 (Thread 0x7f2dd9255700 (LWP 28896)):
#0  0x0000003a5ca00614 in ?? () from /lib64/libaio.so.1
#1  0x00000000008fe503 in os_aio_linux_handle ()
#2  0x00000000008b2d78 in fil_aio_wait ()
#3  0x0000000000833940 in io_handler_thread ()
#4  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#5  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 9 (Thread 0x7f2dd8854700 (LWP 28904)):
#0  0x000000000082eeb4 in srv_lock_timeout_thread ()
#1  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#2  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 8 (Thread 0x7f2dd7e53700 (LWP 28905)):
#0  0x0000003a5d60b75b in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00000000008ffd53 in os_event_wait_time_low ()
#2  0x000000000082ea15 in srv_error_monitor_thread ()
#3  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#4  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 7 (Thread 0x7f2dd7452700 (LWP 28906)):
#0  0x0000003a5d60b75b in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00000000008ffd53 in os_event_wait_time_low ()
#2  0x000000000083188b in srv_monitor_thread ()
#3  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#4  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 6 (Thread 0x7f2dd6a51700 (LWP 28907)):
#0  0x0000003a5cede2f3 in select () from /lib64/libc.so.6
#1  0x0000000000900baf in os_thread_sleep ()
#2  0x000000000082c7fa in srv_LRU_dump_restore_thread ()
#3  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#4  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 5 (Thread 0x7f2dd6050700 (LWP 28908)):
#0  0x0000003a5d60b3dc in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00000000008ffea1 in os_event_wait_low ()
#2  0x000000000082f4b1 in srv_master_thread ()
#3  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#4  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 4 (Thread 0x7f2dd564f700 (LWP 28911)):
#0  0x0000003a5d60f245 in sigwait () from /lib64/libpthread.so.0
#1  0x0000000000513bab in signal_hand ()
#2  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#3  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 3 (Thread 0x7f2dd560e700 (LWP 28912)):
#0  0x0000003a5d60e4ed in read () from /lib64/libpthread.so.0
#1  0x0000000000989402 in vio_read_buff ()
#2  0x000000000051c852 in my_real_read(st_net*, unsigned long*) ()
#3  0x000000000051cb5c in my_net_read ()
#4  0x00000000006637aa in cli_safe_read ()
#5  0x0000000000530d11 in handle_slave_io ()
#6  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#7  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 2 (Thread 0x7f2dd55cd700 (LWP 28913)):
#0  0x0000003a5d60b3dc in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x0000000000716e43 in MYSQL_BIN_LOG::wait_for_update_relay_log(THD*) ()
#2  0x000000000052de67 in exec_relay_log_event(THD*, Relay_log_info*) ()
#3  0x000000000052f059 in handle_slave_sql ()
#4  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#5  0x0000003a5cee570d in clone () from /lib64/libc.so.6
Thread 1 (Thread 0x7f34c404a700 (LWP 28879)):
#0  0x0000003a5cedc053 in poll () from /lib64/libc.so.6
#1  0x0000000000514cf4 in handle_connections_sockets() ()
#2  0x000000000051ad38 in mysqld_main(int, char**) ()
#3  0x0000003a5ce1ecdd in __libc_start_main () from /lib64/libc.so.6
#4  0x0000000000510099 in _start ()</pre>
<p>We can locate that thread 28905 uses the most CPU in this instance.</p>
<pre class="brush: bash; gutter: false">top - 09:07:55 up 114 days,  6:03,  1 user,  load average: 0.00, 0.00, 0.00
Tasks: 166 total,   2 running, 164 sleeping,   0 stopped,   0 zombie
Cpu(s): 14.9%us,  0.3%sy,  0.0%ni, 84.6%id,  0.0%wa,  0.0%hi,  0.0%si,  0.1%st
Mem:  35128056k total,  6323424k used, 28804632k free,   351320k buffers
Swap:        0k total,        0k used,        0k free,  2927504k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                                                       
28905 mysql     20   0 29.9g 2.2g 5732 S 62.4  6.5  5124100h mysqld</pre>
<p>What is this thread doing? Check pstack again, it seems to be a sleeping thread:</p>
<pre class="brush: bash; gutter: false">Thread 8 (Thread 0x7f2dd7e53700 (LWP 28905)):
#0  0x0000003a5d60b75b in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00000000008ffd53 in os_event_wait_time_low ()
#2  0x000000000082ea15 in srv_error_monitor_thread ()
#3  0x0000003a5d6077f1 in start_thread () from /lib64/libpthread.so.0
#4  0x0000003a5cee570d in clone () from /lib64/libc.so.6</pre>
<p>WTF? How come a sleeping thread eat up so much CPU? My previous colleague suggested me to use PMP. It is very convenient for me because we installed Percona toolkit.</p>
<pre class="brush: bash; gutter: false"># pt-pmp -p 28879 -s 5
Wed Sep 19 09:36:15 GMT 2012
     10 libaio::??,os_aio_linux_collect,os_aio_linux_handle,fil_aio_wait,io_handler_thread,start_thread,clone
      1 srv_lock_timeout_thread,start_thread,clone
      1 sigwait,signal_hand,start_thread,clone
      1 select,os_thread_sleep,srv_LRU_dump_restore_thread,start_thread,clone
      1 read,vio_read_buff,my_real_read,my_net_read,cli_safe_read,read_event,handle_slave_io,start_thread,clone
      1 pthread_cond_wait,os_cond_wait,os_event_wait_low,srv_master_thread,start_thread,clone
      1 pthread_cond_wait,inline_mysql_cond_wait,MYSQL_BIN_LOG::wait_for_update_relay_log,next_event,exec_relay_log_event,handle_slave_sql,start_thread,clone
      1 pthread_cond_timedwait,os_cond_wait_timed,os_event_wait_time_low,srv_monitor_thread,start_thread,clone
      1 pthread_cond_timedwait,os_cond_wait_timed,os_event_wait_time_low,srv_error_monitor_thread,start_thread,clone
      1 poll,handle_connections_sockets,mysqld_main,__libc_start_main,_start</pre>
<p>Here is a question that PMP&#8217;s result differs from top -H. That is because PMP order the result based on the times of function appeared in stack, when top -H only order the result by CPU usage. In our case, top -H seems more helpful. All of the information we know now indicate that Redhat 6.3 and EC2 instance are suspicious. Currently I am working on systemtap to make suer, and I will update this post if anything new discovered.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-UPDATE&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
<strong>This problem was solved!<br />
Check the post here: http://blog.mozilla.org/it/2012/06/30/mysql-and-the-leap-second-high-cpu-and-the-fix/</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.realzyy.com/?feed=rss2&#038;p=1495</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>离成功总有几步之遥</title>
		<link>http://www.realzyy.com/?p=1491</link>
		<comments>http://www.realzyy.com/?p=1491#comments</comments>
		<pubDate>Wed, 08 Aug 2012 16:59:58 +0000</pubDate>
		<dc:creator>realzyy</dc:creator>
				<category><![CDATA[My Life]]></category>

		<guid isPermaLink="false">http://www.realzyy.com/?p=1491</guid>
		<description><![CDATA[无可否认，我总是游离在成功的圈子之外。 就拿最自豪的小学成绩来说，我只拿过三年级的一次期终考全校第一。更多时候我需要和同班的毛霄雯班长、邵迪和张儒展开拉锯战，企图保住前三的宝座。而我在心里面认为，张儒肯定比我要强。至于课外的数学奥林匹克就更不用说了，全年级高手如云，我始终也只是中上水平。 很悲催的，老妈对我的课外投资都打了水漂。毛笔练得狗咬吕洞宾不说，数奥最后只得了个全国三等奖，搞得六中的老师打电话过来询问是否要买个名额的时候，语气仿佛是在买过夜的猪肉一般蔑视。老妈的梦想是送我上好的大学，而好的大学依赖于好的高中，而好的高中依赖于好的初中。当她含泪咬牙切齿问我要不要掏钱进六中的时候，年幼的我感到了莫大的压力，可耻地逃到了分配的十二中。 到了十二中后，大家依然疯狂地竞争着，而我依然游离在成功之外。数奥就不说了，像篮球这种纯爷们的运动，天天打也就只能凑个最佳第六人。更关键的是，这么青春的岁月里，我长得一点都不帅。实在是离成功非常遥远。不过感谢倒数第二次模拟考，考得太烂受到了刺激，终于每天晚上狂喝雀巢咖啡，最后一次模拟考获得了继小学三年级之后的又一次全校第一。不过真正的升学考试时，掉到了全校第六，不过美滋滋地挤进了全市最好的高中温州中学。 本以为到了温州中学，生活就会美好起来，事实证明这才是地狱。论天才程度，本班的虞冠驰同学无与伦比。论帅气，又非郑衡莫属。各门科目就别说了，各科猛人无数。这个情况还只限于我所在的六班是全校倒数。隔壁班的某个妹子是我家旁边面店老板的女儿，最烦的就是她老妈时不时过来问问考试成绩。虽然我没有loser的自觉，但是老爸老妈总会发发脾气。 等到文理分班，六班因为太烂被拆掉之后，我很荣幸地被分到了三班。更荣幸的是，这边有更加天才而且努力的张立中、耳凌宇。当时全年级600个人，排名下来我也只能排到100出头。到了高考前夕，突然有阵子就是什么都不想学。最后考试掉到了全年级200名，感觉真是人生最灰暗的时候。老妈天天叨叨上浙大，实际情况却是根本上不了了，只能背井离乡去了西电。 大学生活很快乐。不过尽管我比一般人努力那么一丝丝，也仍旧是比不过那些学霸们。我仍旧记得胡宁杭、葛小村、陈科等各科猛男。即使是我比较喜欢的编程，前面也有刘宇康等硕大的阴影笼罩。每次评奖学金，总是排在三等的前列，勉强成为三等残废中的领军人物。学校里的社团就更不用说了，拍马屁的功夫不到位，脸皮也没人那么厚，上不上下不下整个一苏打夹心饼干。 最后想考gre出国留学，累死累活看看太傻就泄气，那些学霸上来就说自己考了多少多少有几个论文，也不管潜水群众们受不受得了，末了还来一句自己觉得没戏。家里老妈要发疯，成天唧唧歪歪外国的美好生活，搞得留学了就能呼风唤雨年薪百万一样。作为一个loser，被密西根州立的教授抛弃也算是意料之中，获得IIT一个坑钱的doctor offer也属正常，比较幸运的是我选择留在淘宝工作。 2008年的淘宝并不拥挤，即使是没什么想法，没什么智商的我，依旧可以干得有滋有味。但是说起成功，连铭比我聪明，竹庄比我勤奋；而均量，则比我高。一年又一年过去，工资在涨，压力也在变大。新来的同事们更加勤奋和聪明，而此时的我，依旧离所谓的成功有四个p级那么远。有时候想想不免气馁，为什么自己就是没有想象中那么牛气。 如今我更是身在新加坡，过着每天被日本人监控的日子，住着豪华的佣人房，离成功已经需要用光年来计算。然而新加坡同事偶然的一句话让我感觉到自己其实还蛮幸福。他羡慕地说：＂30岁不到就娶到了老婆，你真行。＂ 突然之间，我想起了很多事情。 小学每天能吃到的烧饼、锅贴、糯米饭，初中每天半小时的篮球3v3，高中周三下午的闲暇时间，大学周末的钓鱼，工作后给爷爷的压岁钱，结婚后和老婆出去兜兜风，等等。很多平时容易遗忘的小幸福，在不成功的时候我也照样享受到了。如果说知足常乐的话，我想离成功远一些，也许会更加幸福。阿Q一点来说，反正成功追也追不到，保持那么点距离，貌似蛮好！]]></description>
				<content:encoded><![CDATA[<p>无可否认，我总是游离在成功的圈子之外。</p>
<p>就拿最自豪的小学成绩来说，我只拿过三年级的一次期终考全校第一。更多时候我需要和同班的毛霄雯班长、邵迪和张儒展开拉锯战，企图保住前三的宝座。而我在心里面认为，张儒肯定比我要强。至于课外的数学奥林匹克就更不用说了，全年级高手如云，我始终也只是中上水平。</p>
<p>很悲催的，老妈对我的课外投资都打了水漂。毛笔练得狗咬吕洞宾不说，数奥最后只得了个全国三等奖，搞得六中的老师打电话过来询问是否要买个名额的时候，语气仿佛是在买过夜的猪肉一般蔑视。老妈的梦想是送我上好的大学，而好的大学依赖于好的高中，而好的高中依赖于好的初中。当她含泪咬牙切齿问我要不要掏钱进六中的时候，年幼的我感到了莫大的压力，可耻地逃到了分配的十二中。<br />
<span id="more-1491"></span></p>
<p>到了十二中后，大家依然疯狂地竞争着，而我依然游离在成功之外。数奥就不说了，像篮球这种纯爷们的运动，天天打也就只能凑个最佳第六人。更关键的是，这么青春的岁月里，我长得一点都不帅。实在是离成功非常遥远。不过感谢倒数第二次模拟考，考得太烂受到了刺激，终于每天晚上狂喝雀巢咖啡，最后一次模拟考获得了继小学三年级之后的又一次全校第一。不过真正的升学考试时，掉到了全校第六，不过美滋滋地挤进了全市最好的高中温州中学。</p>
<p>本以为到了温州中学，生活就会美好起来，事实证明这才是地狱。论天才程度，本班的虞冠驰同学无与伦比。论帅气，又非郑衡莫属。各门科目就别说了，各科猛人无数。这个情况还只限于我所在的六班是全校倒数。隔壁班的某个妹子是我家旁边面店老板的女儿，最烦的就是她老妈时不时过来问问考试成绩。虽然我没有loser的自觉，但是老爸老妈总会发发脾气。</p>
<p>等到文理分班，六班因为太烂被拆掉之后，我很荣幸地被分到了三班。更荣幸的是，这边有更加天才而且努力的张立中、耳凌宇。当时全年级600个人，排名下来我也只能排到100出头。到了高考前夕，突然有阵子就是什么都不想学。最后考试掉到了全年级200名，感觉真是人生最灰暗的时候。老妈天天叨叨上浙大，实际情况却是根本上不了了，只能背井离乡去了西电。</p>
<p>大学生活很快乐。不过尽管我比一般人努力那么一丝丝，也仍旧是比不过那些学霸们。我仍旧记得胡宁杭、葛小村、陈科等各科猛男。即使是我比较喜欢的编程，前面也有刘宇康等硕大的阴影笼罩。每次评奖学金，总是排在三等的前列，勉强成为三等残废中的领军人物。学校里的社团就更不用说了，拍马屁的功夫不到位，脸皮也没人那么厚，上不上下不下整个一苏打夹心饼干。</p>
<p>最后想考gre出国留学，累死累活看看太傻就泄气，那些学霸上来就说自己考了多少多少有几个论文，也不管潜水群众们受不受得了，末了还来一句自己觉得没戏。家里老妈要发疯，成天唧唧歪歪外国的美好生活，搞得留学了就能呼风唤雨年薪百万一样。作为一个loser，被密西根州立的教授抛弃也算是意料之中，获得IIT一个坑钱的doctor offer也属正常，比较幸运的是我选择留在淘宝工作。</p>
<p>2008年的淘宝并不拥挤，即使是没什么想法，没什么智商的我，依旧可以干得有滋有味。但是说起成功，连铭比我聪明，竹庄比我勤奋；而均量，则比我高。一年又一年过去，工资在涨，压力也在变大。新来的同事们更加勤奋和聪明，而此时的我，依旧离所谓的成功有四个p级那么远。有时候想想不免气馁，为什么自己就是没有想象中那么牛气。</p>
<p>如今我更是身在新加坡，过着每天被日本人监控的日子，住着豪华的佣人房，离成功已经需要用光年来计算。然而新加坡同事偶然的一句话让我感觉到自己其实还蛮幸福。他羡慕地说：＂30岁不到就娶到了老婆，你真行。＂</p>
<p>突然之间，我想起了很多事情。<br />
小学每天能吃到的烧饼、锅贴、糯米饭，初中每天半小时的篮球3v3，高中周三下午的闲暇时间，大学周末的钓鱼，工作后给爷爷的压岁钱，结婚后和老婆出去兜兜风，等等。很多平时容易遗忘的小幸福，在不成功的时候我也照样享受到了。如果说知足常乐的话，我想离成功远一些，也许会更加幸福。阿Q一点来说，反正成功追也追不到，保持那么点距离，貌似蛮好！</p>
]]></content:encoded>
			<wfw:commentRss>http://www.realzyy.com/?feed=rss2&#038;p=1491</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The differences between Slot, Partial and Component in Symfony</title>
		<link>http://www.realzyy.com/?p=1485</link>
		<comments>http://www.realzyy.com/?p=1485#comments</comments>
		<pubDate>Wed, 01 Aug 2012 10:09:46 +0000</pubDate>
		<dc:creator>realzyy</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[Component]]></category>
		<category><![CDATA[difference]]></category>
		<category><![CDATA[Partial]]></category>
		<category><![CDATA[Slot]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.realzyy.com/?p=1485</guid>
		<description><![CDATA[I am starting to use Symfony to create server for Nubee&#8217;s applications. During the development, I feel very confused about the differences between slot, partial and component . After several hours&#8217; searching on Google, finally I found a clear definition in &#8220;A Gentle Introduction to symfony&#8221;. Symfony provides three alternative types of intelligent code fragments [...]]]></description>
				<content:encoded><![CDATA[<p>I am starting to use Symfony to create server for Nubee&#8217;s applications. During the development, I feel very confused about the differences between slot, partial and component .</p>
<p>After several hours&#8217; searching on Google, finally I found a clear definition in &#8220;A Gentle Introduction to symfony&#8221;.<br />
<strong>Symfony provides three alternative types of intelligent code fragments to replace includes:</strong><br />
<strong> • If the logic is lightweight, you will just want to include a template file to some data you pass to it. For that, you will use a partial.</strong><br />
<strong> • If the logic is heavier (for instance, if you need to access the data modify the content according to the session), you will prefer to presentation from the logic. For that, you will use a component.</strong><br />
<strong> • If the fragment is meant to replace a specific part of the layout, for content may already exist, you will use a slot.</strong></p>
<p>And the most important reason that we use a component instead of an action is, we cannot include an action in the template!<br />
Wish this will end the discussions on Stack Overflow. But I have another question for all the viewers: which layer should component belong to?</p>
<p>According to &#8220;A Gentle Introduction to symfony&#8221;, it should belong to view layer. However it is very weird to me that there is complicated business logic in view layer.<br />
Crazy to think about those questions&#8230; Maybe we should leave those questions behind, and start to focus on coding?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.realzyy.com/?feed=rss2&#038;p=1485</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
