<?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>swigger's BLOG &#187; alipay</title>
	<atom:link href="http://www.swigger.net/archives/tag/alipay/feed" rel="self" type="application/rss+xml" />
	<link>http://www.swigger.net</link>
	<description>醉卧沙场君莫笑 古来征战几人回</description>
	<lastBuildDate>Tue, 24 Jan 2012 05:34:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>支付宝为什么慢</title>
		<link>http://www.swigger.net/archives/17.html</link>
		<comments>http://www.swigger.net/archives/17.html#comments</comments>
		<pubDate>Sat, 05 Apr 2008 17:49:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[老当益愤]]></category>
		<category><![CDATA[alipay]]></category>
		<category><![CDATA[慢]]></category>
		<category><![CDATA[支付宝]]></category>
		<category><![CDATA[淘宝]]></category>

		<guid isPermaLink="false">http://www.swigger.net/?p=17</guid>
		<description><![CDATA[说说前面文章提到的为什么支付宝慢的原因吧。 起因：买域名需要用支付宝付款，但支付过程实在是太慢了。 其实支付宝慢我几个月前就发现了，只是那一次还可以用财富通付款，所以我就选财富通了。这次只有淘宝可以选了，没办法只有用它付。 首先是尝试等，等了几下出了几次错，都是超时。不能再等了，转钱是件重要的事，如果因为某个步骤超时导致事情办不了，钱又被扣了，就麻烦了。 没办法，研究一下为什么慢吧。 1. 首先是要找出一个慢的场景，这要才可以作下一步的分析， 我试了两下，整出一个场景来，就是访问这个URL很慢： http://bankacknowledge.alipay.com/payment/e_bank_payment.htm  刷新了数次，大部分慢，只有一两次快。（注：发现这个慢是本blog域名买之前的事，写本文时访问了此url几次，发现挺快的了，也许是跟时间有关系） 怀疑是IE问题，换ff上，这个页面全打开也是很慢。跟IE一样，刷新多次一两次快，其余慢。 慢的时候，状态栏显示正在等待 img.alipay.com 分析了一下页面结构，要访问多个img.alipay.com上的  url如： https://img.alipay.com/css/global/v2.0.css https://img.alipay.com/pimg/icon_fold_3.gif   2. 然后当然是google之，关键词： 淘宝 支付 慢，最后在yahoo找到一篇： http://ks.cn.yahoo.com/question/1390100028924.html 这里面提到了一件很重要的事，就是img.alipay.com。说要在host里指定一下IP。难道是这个站太慢？不至于马云这样的大财主不做IDC优化吧。 我试着ping 了一下：  C:\&#62;ping img.alipay.com Pinging img.alipay.com [121.0.26.16] with 32 bytes of data: Reply from 121.0.26.16: bytes=32 time=35ms TTL=246 Reply from 121.0.26.16: bytes=32 time=34ms TTL=246 Reply from 121.0.26.16: bytes=32 time=35ms TTL=246 [...]]]></description>
			<content:encoded><![CDATA[<p>说说前面文章提到的为什么支付宝慢的原因吧。</p>
<p>起因：买域名需要用支付宝付款，但支付过程实在是太慢了。</p>
<p>其实支付宝慢我几个月前就发现了，只是那一次还可以用财富通付款，所以我就选财富通了。这次只有淘宝可以选了，没办法只有用它付。</p>
<p>首先是尝试等，等了几下出了几次错，都是超时。不能再等了，转钱是件重要的事，如果因为某个步骤超时导致事情办不了，钱又被扣了，就麻烦了。</p>
<p>没办法，研究一下为什么慢吧。</p>
<p>1. 首先是要找出一个慢的场景，这要才可以作下一步的分析，</p>
<p>我试了两下，整出一个场景来，就是访问这个URL很慢：</p>
<p><a href="http://bankacknowledge.alipay.com/payment/e_bank_payment.htm">http://bankacknowledge.alipay.com/payment/e_bank_payment.htm</a></p>
<p> 刷新了数次，大部分慢，只有一两次快。（注：发现这个慢是本blog域名买之前的事，写本文时访问了此url几次，发现挺快的了，也许是跟时间有关系）</p>
<p>怀疑是IE问题，换ff上，这个页面全打开也是很慢。跟IE一样，刷新多次一两次快，其余慢。</p>
<p>慢的时候，状态栏显示正在等待 img.alipay.com</p>
<p>分析了一下页面结构，要访问多个img.alipay.com上的  url如：</p>
<pre id="line1">https://img.alipay.com/css/global/v2.0.css</pre>
<pre id="line45"><span class="attribute-value">https://img.alipay.com/pimg/icon_fold_3.gif</span></pre>
<p> </p>
<p>2. 然后当然是google之，关键词： 淘宝 支付 慢，最后在yahoo找到一篇：</p>
<p><a href="http://ks.cn.yahoo.com/question/1390100028924.html">http://ks.cn.yahoo.com/question/1390100028924.html</a></p>
<p>这里面提到了一件很重要的事，就是img.alipay.com。说要在host里指定一下IP。难道是这个站太慢？不至于马云这样的大财主不做IDC优化吧。</p>
<p>我试着ping 了一下：</p>
<blockquote><p> C:\&gt;ping img.alipay.com</p>
<p>Pinging img.alipay.com [121.0.26.16] with 32 bytes of data:</p>
<p>Reply from 121.0.26.16: bytes=32 time=35ms TTL=246<br />
Reply from 121.0.26.16: bytes=32 time=34ms TTL=246<br />
Reply from 121.0.26.16: bytes=32 time=35ms TTL=246<br />
Reply from 121.0.26.16: bytes=32 time=35ms TTL=246</p>
<p>Ping statistics for 121.0.26.16:<br />
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),<br />
Approximate round trip times in milli-seconds:<br />
    Minimum = 34ms, Maximum = 35ms, Average = 34ms</p></blockquote>
<p>应该说，速度挺快。又telnet img.alipay.com 443试了一下，立马连上，几次都如此，怀疑不是它的问题。</p>
<p>3. 尝试用wget 取url <span class="attribute-value"><a href="https://img.alipay.com/pimg/icon_fold_3.gif">https://img.alipay.com/pimg/icon_fold_3.gif</a> 查时间。发现手头的wget.exe版本太老，不支持https。</span></p>
<p><span class="attribute-value">懒得去开linux了，更没时间去找新版的wget.exe了。手头有一个以前练手写的sget.exe，就拿它来试吧。</span></p>
<blockquote><p><span class="attribute-value">C:\&gt;sget <a href="https://img.alipay.com/pimg/icon_fold_3.gif">https://img.alipay.com/pimg/icon_fold_3.gif</a> aa.gif<br />
OK<br />
HTTP code: 200<br />
Date: Sat, 05 Apr 2008 17:28:57 GMT<br />
Server: Apache<br />
Last-Modified: Wed, 16 Jan 2008 14:17:01 GMT<br />
ETag: “1f014c-271-90127140&#8243;<br />
Accept-Ranges: bytes<br />
Content-Length: 625<br />
Cache-Control: max-age=604800<br />
Expires: Sat, 12 Apr 2008 17:28:57 GMT<br />
Keep-Alive: timeout=50, max=264<br />
Connection: Keep-Alive<br />
Content-Type: image/gif</span></p></blockquote>
<p><span class="attribute-value"><span class="attribute-value">还挺快的啊，一下就出来结果了，又运行一次，这次出情况了，一直没有出结果，卡住了，为什么呢？</span></span></p>
<p><span class="attribute-value"><span class="attribute-value">打开VC编译一把源码开始调试，发现连接函数处：</span></span></p>
<blockquote><p><span class="attribute-value"><span class="attribute-value">  if (connect(sock, name, namelen) == 0 &amp;&amp;<br />
   SSL_set_fd(ssl, (int)sock) &amp;&amp;<br />
   SSL_connect(ssl) &gt; 0)<br />
  {<br />
   return true;<br />
  }</span></span></p></blockquote>
<p><span class="attribute-value"><span class="attribute-value">SSL_connect函数一直没有返回，这下问题就找到了：</span></span></p>
<p><span class="attribute-value"><span class="attribute-value"><span style="color: #888888;"><strong>img.alipay.com要么是压力大了承受不了了，要么是有潜在的BUG，在ssl握手时会出现问题，</strong></span></span></span></p>
<p><span class="attribute-value"><span class="attribute-value"><span style="color: #888888;"><strong>导致客户端一直要等。导致淘宝ping起来很快，但某些页面访问起来很慢。</strong></span></span></span></p>
<p><span class="attribute-value"><span class="attribute-value">而tcp连接还是很快，所以我之前telnet img.alipay.com 443不能发现问题。</span></span></p>
<p><span class="attribute-value"></span> </p>
<p><span class="attribute-value"><span class="attribute-value">4. 原因查明了，方案就容易做了。先看了一下img.alipay.com要拉什么东西，其中.js和.css比较重要，图片就算了。</span></span></p>
<p><span class="attribute-value"><span class="attribute-value">反复连接img.alipay.com，因为有一定机率很快连接成功，所以可以把它们都下载回来。</span></span></p>
<p><span class="attribute-value"><span class="attribute-value">下回来后按目录结构放在本地一个文件夹里面。然后配置一下host:</span></span></p>
<p><span class="attribute-value"><span class="attribute-value">127.0.0.1 img.alipay.com</span></span></p>
<p><span class="attribute-value"><span class="attribute-value">再配了一下本地的apache，在这个文件夹启用hostname为img.alipay.com的https访问。</span></span></p>
<p><span class="attribute-value"><span class="attribute-value">尝试访问一下本地的 <a href="https://img.alipay.com/css/global/v2.0.css">https://img.alipay.com/css/global/v2.0.css</a></span></span></p>
<p><span class="attribute-value"><span class="attribute-value">发现可以成功，唯独变的就是img.alipay.com是127.0.0.1了，还有就是ie会给一个证书错误的警告，选继续就好了。</span></span></p>
<p><span class="attribute-value"><span class="attribute-value">然后重新刷了下 <a href="http://bankacknowledge.alipay.com/payment/e_bank_payment.htm">http://bankacknowledge.alipay.com/payment/e_bank_payment.htm</a></span></span></p>
<p><span class="attribute-value"><span class="attribute-value">虽然有几个图不能显示，但是挺快的了。这样可以开始付款了。</span></span></p>
<p><span class="attribute-value"><span class="attribute-value">打开淘宝付款流程，除了一些图片没有，一切正常，很快就成功打开招行专业版付了款。</span></span></p>
<p><span class="attribute-value"><span class="attribute-value">搞定收功。可以买下域名了。</span></span></p>
<p><span class="attribute-value"></span> </p>
<p><span class="attribute-value"><span class="attribute-value">后记： 付款是大事，我敢这么做是因为我知道img.alipay.com不会影响付款逻辑。看官们谨慎点，最安全的办法还是等几个小时等到半夜好点。比如现在img.alipay.com就很快。</span></span></p>
<p><span class="attribute-value"><span class="attribute-value">另外，yahoo上的回答说明已经有人知道这件事情了，虽然那里没有详细说明技术原因。yahoo现在也是马云管，马云应该也知道了，为什么就不做好一下img.alipay.com呢？</span></span></p>
<p><span class="attribute-value"><span class="attribute-value">最后，像图片这样的东西完全没有必要通过https拉嘛，用http就行了，我知道alipay是为了照顾ie用户，因为混合https和http在一个页面内，IE会给出一个安全警告。</span></span></p>
<p><span class="attribute-value"><span class="attribute-value">但是，既然你的img.alipay.com都承受不了压力了，这些图片css什么的，为什么就不直接从http拉呢？ie给个警告总比用户付不了款，等几次都超时出问题强吧。</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.swigger.net/archives/17.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

