开心网(kaixin001.com)服务器架构的一点猜想

    开心网(也就是kaixin001.com,以下同)是我经常使用的一个SNS服务,它是采用比较流行的LAMP组合,同时它的alexa排名在134名左右(实际数据可能与这个有点差别),出于好奇,我用cURL看了一个它的Header,而且抓取了3次Header,我在 Header中发现一个名为SERVERID的Cookie,而且每次的值不一样,三次分别是_srv101-121_、_srv101-142_及 _srv134-47_,而且这个Cookie的名称故名思义应该是服务器ID的意思,我猜测应该是三台服务器的代号吧,然后我接着分别ping上述三个id+kaixin001.com,它们均可以ping通,说明我的猜测是正确的。

    我对开心网服务器的架构猜测如下:用户访问www.kaixin001.com时从开心网的服务器集群里面随机分配一台服务器,然后把服务器的ID值通过Cookie保存在用户的浏览器中,用户下次访问时仍然使用这台服务器,直到Cookie失效(通过我的测试,此Cookie应该只是基于浏览器内存的,也就是说如果你下次再次打开浏览器后应该会重新随机分配一个服务器ID,既然是随机的,当然也有可能与上一次分配的服务器相同)。 怎样让用户访问www.kaixin001.com时重定向到另外一台服务器呢(主要是为了负载均衡),一是可以用LVS来处理,另外由于Header中有Apache的字样,所以也有可能是用Apache的Rewrite功能重定向到另外一台服务器的(不过此时地址栏是没有任何变化的,还是原来的地址),以前我曾经做过类似这样的应用。 抛开开心网的架构来说,用Nginx也可以做负载均衡,也可以用F5 BIG-IP负载均衡交换机,当然这些在此就不细说了,大家有时间可以在网上找资料详细看看。

    我的一点看法,我也不是什么架构方面的专家,说得有不对之处欢迎大家多提建议及意见!

三次抓取开心网Header时的结果
C:/>curl -I www.kaixin001.com
HTTP/1.1 200 OK
Date: Wed, 10 Dec 2008 16:57:27 GMT
Server: Apache/2.2.6 (Unix) PHP/5.2.4
X-Powered-By: PHP/5.2.4
Cache-Control: max-age=1; private
Expires: Wed, 10 Dec 2008 16:57:28 GMT
Last-Modified: Wed, 10 Dec 2008 16:57:27 GMT
ETag: app-1228928247
Set-Cookie: _user=deleted; expires=Tue, 11-Dec-2007 16:57:26 GMT; path=/; domain
=.kaixin001.com
Vary: Accept-Encoding,User-Agent
Connection: close
Content-Type: text/html; charset=UTF-8
Set-Cookie: SERVERID=_srv101-121_; path=/

C:/>curl -I www.kaixin001.com
HTTP/1.1 200 OK
Date: Wed, 10 Dec 2008 16:57:48 GMT
Server: Apache/2.2.6 (Unix) PHP/5.2.4
X-Powered-By: PHP/5.2.4
Cache-Control: max-age=1; private
Expires: Wed, 10 Dec 2008 16:57:49 GMT
Last-Modified: Wed, 10 Dec 2008 16:57:48 GMT
ETag: app-1228928268
Set-Cookie: _user=deleted; expires=Tue, 11-Dec-2007 16:57:47 GMT; path=/; domain
=.kaixin001.com
Vary: Accept-Encoding,User-Agent
Connection: close
Content-Type: text/html; charset=UTF-8
Set-Cookie: SERVERID=_srv101-142_; path=/

C:/>curl -I www.kaixin001.com
HTTP/1.1 200 OK
Date: Wed, 10 Dec 2008 16:58:01 GMT
Server: Apache/2.2.6 (Unix) PHP/5.2.4
X-Powered-By: PHP/5.2.4
Cache-Control: max-age=1; private
Expires: Wed, 10 Dec 2008 16:58:02 GMT
Last-Modified: Wed, 10 Dec 2008 16:58:01 GMT
ETag: app-1228928281
Set-Cookie: _user=deleted; expires=Tue, 11-Dec-2007 16:58:00 GMT; path=/; domain
=.kaixin001.com
Vary: Accept-Encoding,User-Agent
Connection: close
Content-Type: text/html; charset=UTF-8
Set-Cookie: SERVERID=_srv134-47_; path=/

 
Ping Web服务器的结果

分别ping“服务器id + kaixin001.com”的结果,ping的内容中出现了CDN的字样,不知这个CDN系统是开心网自己开发的还是用的别的公司的服务。像ChinaCache,CDNUnion都可以提供CDN加速的服务,不过费用应该不会太便宜。

C:/>ping _srv101-121.kaixin001.com

Pinging www2.kaixin001.z.cdn20.com [119.161.132.21] with 32 bytes of data:

Reply from 119.161.132.21: bytes=32 time=60ms TTL=48
Reply from 119.161.132.21: bytes=32 time=70ms TTL=48
Reply from 119.161.132.21: bytes=32 time=60ms TTL=48
Reply from 119.161.132.21: bytes=32 time=60ms TTL=48

Ping statistics for 119.161.132.21:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 60ms, Maximum = 70ms, Average = 62ms

C:/>ping _srv101-142.kaixin001.com

Pinging www2.kaixin001.z.cdn20.com [119.161.132.24] with 32 bytes of data:

Reply from 119.161.132.24: bytes=32 time=60ms TTL=47
Reply from 119.161.132.24: bytes=32 time=70ms TTL=47
Reply from 119.161.132.24: bytes=32 time=61ms TTL=47
Reply from 119.161.132.24: bytes=32 time=60ms TTL=47

Ping statistics for 119.161.132.24:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 60ms, Maximum = 70ms, Average = 62ms

C:/>ping _srv134-47.kaixin001.com

Pinging www2.kaixin001.z.cdn20.com [119.161.132.21] with 32 bytes of data:

Reply from 119.161.132.21: bytes=32 time=70ms TTL=48
Reply from 119.161.132.21: bytes=32 time=60ms TTL=48
Request timed out.
Reply from 119.161.132.21: bytes=32 time=70ms TTL=48

Ping statistics for 119.161.132.21:
Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
Minimum = 60ms, Maximum = 70ms, Average = 50ms

你可能感兴趣的:(AIX)