能自动生成ajax loading图标的网站 http://ajaxload.info/

 

posted @ 2010-05-18 23:29 web-backend 阅读(110) 评论(0) 编辑

浏览器默认对同一域下的资源,只保持一定的连接数,会阻塞过多的连接。rfc2616建议不超过2个:

Clients that use persistent connections SHOULD limit the number of simultaneous connections that they maintain to a given server. A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy. A proxy SHOULD use up to 2*N connections to another server or proxy, where N is the number of simultaneously active users. These guidelines are intended to improve HTTP response times and avoid congestion.

不同浏览器的默认值不一样,对于不同的HTTP协议其值也不一样。见下表。
 

浏览器默认最大并发连接数
浏览器 HTTP 1.1 HTTP 1.0
IE 6,7 2 4
IE 8 6 6
Firefox 2 2 8
Firefox 3 6 6
Safari 3, 4 4 4
Chrome 1,2 6 ?
Chrome 3 4 4
Opera 9.63,10.00alpha 4 4

上表数据来自Steve Souders

总的来看,HTTP1.0下允许的连接数普遍大于HTTP1.1协议下的,是因为HTTP1.1是保持连接的,本身对同域下资源的获取就是优化的,且对资源的消耗要大于HTTP1.0。在rfc2616中说到,限制连接数的目的在于提高响应速度和避免拥塞

修改浏览器最大连接数

1. Firefox

在文件 X:\Program Files\Mozilla Firefox\greprefs\all.js中,有如下的参数:

//​ ​i​f​ ​n​e​t​w​o​r​k​.​h​t​t​p​.​k​e​e​p​-​a​l​i​v​e​ ​i​s​ ​t​r​u​e​,​ ​a​n​d​ ​i​f​ ​N​O​T​ ​c​o​n​n​e​c​t​i​n​g​ ​v​i​a​ ​a​ ​p​r​o​x​y​,​ ​t​h​e​n​
​/​/​ ​a​ ​n​e​w​ ​c​o​n​n​e​c​t​i​o​n​ ​w​i​l​l​ ​o​n​l​y​ ​b​e​ ​a​t​t​e​m​p​t​e​d​ ​i​f​ ​t​h​e​ ​n​u​m​b​e​r​ ​o​f​ ​a​c​t​i​v​e​ ​p​e​r​s​i​s​t​e​n​t​
/​/​ ​c​o​n​n​e​c​t​i​o​n​s​ ​t​o​ ​t​h​e​ ​s​e​r​v​e​r​ ​i​s​ ​l​e​s​s​ ​t​h​e​n​ ​m​a​x​-​p​e​r​s​i​s​t​e​n​t​-​c​o​n​n​e​c​t​i​o​n​s​-​p​e​r​-​s​e​r​v​e ​r​.​
​p​r​e​f​(​"​n​e​t​w​o​r​k​.​h​t​t​p​.​m​a​x​-​p​e​r​s​i​s​t​e​n​t​-​c​o​n​n​e​c​t​i​o​n​s​-​p​e​r​-​s​e​r​v​e​r​"​,​ ​6​)​;​

/​/​ ​i​f​ ​n​e​t​w​o​r​k​.​h​t​t​p​.​k​e​e​p​-​a​l​i​v​e​ ​i​s​ ​t​r​u​e​,​ ​a​n​d​ ​i​f​ ​c​o​n​n​e​c​t​i​n​g​ ​v​i​a​ ​a​ ​p​r​o​x​y​,​ ​t​h​e​n​ ​a​
/​/​ ​n​e​w​ ​c​o​n​n​e​c​t​i​o​n​ ​w​i​l​l​ ​o​n​l​y​ ​b​e​ ​a​t​t​e​m​p​t​e​d​ ​i​f​ ​t​h​e​ ​n​u​m​b​e​r​ ​o​f​ ​a​c​t​i​v​e​ ​p​e​r​s​i​s​t​e​n​t​
/​/​ ​c​o​n​n​e​c​t​i​o​n​s​ ​t​o​ ​t​h​e​ ​p​r​o​x​y​ ​i​s​ ​l​e​s​s​ ​t​h​e​n​ ​m​a​x​-​p​e​r​s​i​s​t​e​n​t​-​c​o​n​n​e​c​t​i​o​n​s​-​p​e​r​-​p​r​o​x​y ​.​
​p​r​e​f​(​"​n​e​t​w​o​r​k​.​h​t​t​p​.​m​a​x​-​p​e​r​s​i​s​t​e​n​t​-​c​o​n​n​e​c​t​i​o​n​s​-​p​e​r​-​p​r​o​x​y​"​,​ ​8​)​;


2. IE

需要修改注册表或组策略,详情见微软的技术支持

posted @ 2010-05-03 23:01 web-backend 阅读(561) 评论(0) 编辑

    sendmail是linux/unix系统下用来发送邮件的客户端。sendmail使用SMTP协议将邮件发送到目的SMTP服务器。其工作流程大概如下:

    首先要说一下DNS的MX记录:SMTP服务器基于DNS中的MX(mail exchange)记录来路由电子邮件,MX记录注册了域名和相关的SMTP中继主机,属于该域的电子邮件都应向该主机发送。

   (1)Sendmail 请求DNS给出主机sh.abc.com的CNAME 记录,如有,假若CNAME(别名记录)到shmail.abc.com,则再次请求shmail.abc.com的CNAME记录,直到没有为止。
   (2)假定被CNAME到shmail.abc.com,然后sendmail请求@abc.com 域的DNS给出shmail.abc.com的MX记录(邮件路由及记录),shmail MX 5 shmail.abc.com 10 shmail2.abc.com。
   (3)Sendmail组合请求DNS给出shmail.abc.com的A记录(主机名(或域名)对应的IP地址记录),即IP地址,若返回值为10.0.0.4(假设值)。
   (4)Sendmail与10.0.0.4连接,传送这封给user@sh.abc.com 的信到1.2.3.4 这台服务器的SMTP后台程序。

 

1. 构造邮件

    在使用sendmail发送邮件之前,首先需要按邮件格式构造一封邮件。包括邮件头,邮件消息体。邮件格式在RFC5322:internet message format(http://tools.ietf.org/html/rfc5322)中有详细说明。

代码
From: John Doe <jdoe@machine.example>
Sender: Michael Jones 
<mjones@machine.example>
To: Mary Smith 
<mary@example.net>
Subject: Saying Hello
Date: Fri, 21 Nov 1997 09:55:06 -0600
Message-ID: 
<1234@local.machine.example>

This is a message just to say hello.
So, "Hello".

   可以暂不指定date头(邮件发送时间)和messageid,这个信息将由sendmail程序填写。

 

 

2. 使用sendmail发送邮件

    将邮件构造好之后,保存到一个本地文件,如/data/mail_content。然后调用sendmail发送,发送时指定接收邮箱地址:

    cat /data/mail_content | sendmail user@163.com

 

3. 发送HTML格式的邮件

    如果要发送html格式的邮件, 就是说,邮件的消息体为一个html文件,需要在邮件头中指定 content-type为 text/html。如果不指定,默认情况下,content-type为text/plain,即普通文本。 

 

From: John Doe <jdoe@machine.example>
Sender: Michael Jones <mjones@machine.example>
To: Mary Smith <mary@example.net>
Content-type: text/html
Subject: Saying Hello

<div style="border:solid 1px #1D448C;">
<h1>This is a message just to say hello.</h1>
<p>So, "Hello".</p>
</div>


 4. 字符编码

    在发送中文邮件中,字符编码是一个比较重要的问题,如果设置不正确,会导致邮件标题或邮件内容显示乱码。

 

    邮件内容的编码可以在邮件头content-type中设置,如设置邮件内容为utf-8编码:

    Content-type: text/html;charset=utf-8

   

    邮件头中,如From,To,Subject等,如果需要用到中文,可以这样设置:

    =?UTF-8?B?”+base64encode(内容UTF8编码)+"?="

   

邮件支持中文编码
From: =?UTF-8?B?5L2g5aW9?= <jdoe@machine.example>
Sender: Michael Jones 
<mjones@machine.example>
To: Mary Smith 
<mary@example.net>
Content-type: text/html;charset=utf-8
Subject: =?UTF-8?B?5L2g5aW9?=

<div style="border:solid 1px #1D448C;">
<h1>This is a message just to say hello.</h1>
<p>So, "Hello".</p>
</div>


posted @ 2010-04-16 12:14 web-backend 阅读(4143) 评论(0) 编辑

 

   很多时候,我们需要通过system这个函数在程序内部来执行系统命令。

   比如:

  int  rv = system("mount /mnt/hgfs");

 

  

   最近有同事发现system调用返回-1,但事实上外部命令已成功执行。

  

   经调查发现,原来是server在启动后将自己设置为daemon时,屏蔽了SIGCHLD信号导致的。在某些linux内核版本下,屏蔽SIGCHLD信号会导致system调用返回-1(经查,linux2.6内核以上无此问题)。system调用执行的流程应该是: fork->execve->waitpid,在某些内核实现中,可能没有恢复SIGCHLD信号,由此导致waitpid失败。

   在system调用之前,应该手工恢复SIGCHLD信号:

 

signal(SIGCHLD, SIG_DFL);
int  rv = system("mount /mnt/hgfs");

 

 

posted @ 2010-04-06 11:13 web-backend 阅读(421) 评论(0) 编辑
摘要: 原文地址:http://ucdchina.com/snap/6082(一)回顾facebook之前的SNS社会化网络服务(SNS)不是facebook开创的,在Facebook之前,“交友”和“社区” (尤其BBS社区)这两类互联网应用都具有SNS属性。特别是前者交友网站,几乎完全归属于SNS。为便于下面的讨论,在本文中把处理“人R...阅读全文
posted @ 2010-03-18 12:49 web-backend 阅读(34) 评论(0) 编辑
摘要: 本文译自:http://www.evanmiller.org/nginx-modules-guide.html 下载链接:/Files/web-backend/Emiller的nginx模块开发指引.zip 要非常感谢nginx,它帮助我更加了解蝙蝠侠这个喜剧角色。蝙蝠侠很快,nginx也很快。蝙蝠侠在与罪恶斗争,nginx在与浪费CPU、内存泄漏等现象做斗争。蝙蝠侠在压力下能保持良好状态,ngi...阅读全文
posted @ 2010-03-17 11:19 web-backend 阅读(1431) 评论(0) 编辑
摘要: 又有机会爆料国内 Web 2.0 网站的架构了。这次是 Yupoo! 。非正式的采访了一下 Yupoo!(又拍网) 的创建人之一的 阿华(沈志华)同学,了解了一些小道消息。作为国内最大的图片服务提供商之一,Yupoo! 的 Alexa 排名大约在 5300 左右。同时收集到的一些数据如下:带宽:4000M/S (参考)服务器数量:60 台左右Web服务器:Lighttpd, Apache, ngi...阅读全文
posted @ 2010-01-26 00:56 web-backend 阅读(347) 评论(0) 编辑
摘要: Fixing Twitter。 Improving the Performance and scalability of the world's most popular micro-blogging site presentation/Files/web-backend/Fixing_Twitter.pdf阅读全文
posted @ 2010-01-26 00:44 web-backend 阅读(126) 评论(0) 编辑
摘要: 移动互联网将成为下一个热点。看摩根士丹利对全球移动互联网的分析。 /Files/web-backend/Mobile_Internet_Report_Setup_Chinese.pdf阅读全文
posted @ 2010-01-21 18:44 web-backend 阅读(42) 评论(0) 编辑