V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  Tianpu  ›  全部回复第 17 页 / 共 25 页
回复总数  492
1 ... 9  10  11  12  13  14  15  16  17  18 ... 25  
哎呀 这几天刚做了个邮件列表的归档 才加到一天2000多封 你们邮件真多

可以看看www.xunsearch.com
2013-03-12 05:34:06 +08:00
回复了 Tianpu 创建的主题 Linode Is linode true unbeatable?
@Livid 我把它当中转的代理使了 流入流出是对等的
2013-03-12 04:40:42 +08:00
回复了 Tianpu 创建的主题 Linode Is linode true unbeatable?
@Livid 嗯 我的稳定跑到了10M 看流量是不够用 所以造了上面一楼的全部压缩传输吧
2013-03-12 04:39:30 +08:00
回复了 Tianpu 创建的主题 Linode Is linode true unbeatable?
@webflier @siw 搜索蜘蛛抓页面 无所谓啦 我user-agent都用bing的 抓取器终于支持gzip了 只考虑了chunked gzip 还有什么都没有的情况 暂时都能正常出人类可见文本

<code>
<?php
function dechunked($str){
$r = $t = '';
$t = $str;
while(trim($t)){
if(!preg_match('/^([\da-fA-F]+)[^\r\n]*\r\n/sm',$t,$m)) die('seem to be a chunked message');
$l = hexdec(trim($m[1]));
$c = strlen($m[0]);
$r.= substr($t,$c,$l);
$t = substr($t,$c+$l+2);
}
return $r;
}
function open($url){
$body = $head = $resp = '';
$temp = $temq = array();
$temp = parse_url($url);
$host = $temp['host'];
$file = $temp['path'];
if($temp['query']!='') $file = $file.'?'.$temp['query'];
$fp = fsockopen($host, 80, $errno, $errstr, 15);
if(!$fp) die('{gate_closed}');
else{
$head.= "GET $file HTTP/1.1\r\n";
$head.= "Host: $host\r\n";
$head.= "User-Agent: Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)\r\n";
$head.= "Referer: $url\r\n";
$head.= "Accept-Encoding: gzip,deflate\r\n";
$head.= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n";
$head.= "Connection: Close\r\n\r\n";
fwrite($fp, $head);
while(!feof($fp)){
$resp.= fgets($fp,4096);
}
fclose($fp);
}
if(empty($resp)) die('{gate_closed}');
$temq = explode("\r\n\r\n",$resp,2);
print_r($head);
print_r($temq[0]);
if(stristr($temq[0],'Transfer-Encoding: chunked')) $temq[1] = dechunked($temq[1]);
if(stristr($temq[0],'Content-Encoding: gzip')){
$body = gzinflate(substr($temq[1],10));
}
else $body = $temq[1];
return $body;
}
if(!empty($_GET['url'])) echo open($_GET['url']);
?>
</code>
2013-03-12 00:26:25 +08:00
回复了 Tianpu 创建的主题 Linode Is linode true unbeatable?
@webflier 到现在用了30多G流量了 还没全跑 在观察参数

流量肯定顶不住 我估计需要6T左右

待会得加上gzip了
纯技术讨论 图片的话 可以用nginx的image_filter 后端是gd 只要不是超大图 gd还是比imagik有优势的
2013-03-11 18:59:26 +08:00
回复了 Tianpu 创建的主题 PHP php human friendly time diff
@amirfish ==换成=
www.xunsearch.com

需要比较大量数据的案例私信我

右上角两厘米是感谢,我要金子
2013-03-10 22:12:27 +08:00
回复了 Tianpu 创建的主题 Linode Is linode true unbeatable?
@webflier 不用啊 本来我是想买几个$5的VPS跑的 LINODE很快啊

这会平均带宽有2M了 今天用3G流量了

过几天我继续反馈
2013-03-10 12:35:19 +08:00
回复了 Tianpu 创建的主题 音乐 推荐:S.H.E 《SUPER STAR》
@feiandxs 结了很多丝瓜 我不应该留个坑的 今年种一定全程记录
2013-03-10 12:22:29 +08:00
回复了 Tianpu 创建的主题 音乐 推荐:S.H.E 《SUPER STAR》
@MC 是啊
2013-03-09 10:26:17 +08:00
回复了 Tianpu 创建的主题 音乐 推荐:S.H.E 《SUPER STAR》
@olnyshe 是啊 是啊 我觉得还不错的 和t.A.t.u的有点类似风格 错乱中的平静感?
2013-02-18 08:38:54 +08:00
回复了 chunshuai 创建的主题 程序员 Google 的验证码 该如何破解
打码啊 很便宜的
2013-02-05 13:59:20 +08:00
回复了 Tianpu 创建的主题 NGINX 16G内存分配给nginx做前端加速后端,有什么建议吗?
@LazyZhu
1、这个是因为后面还有好多个站点的配置 大致是均匀的
2、冷热资源的确是个问题 这方面还没在考虑

感谢建议
2013-02-04 17:32:25 +08:00
回复了 Tianpu 创建的主题 NGINX 16G内存分配给nginx做前端加速后端,有什么建议吗?
配置稍微有点更新,我贴出来:

user www www;
worker_processes 16;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
client_header_buffer_size 4k;
client_body_buffer_size 128k;
large_client_header_buffers 4 4k;
server_names_hash_max_size 1280;
server_names_hash_bucket_size 128;
client_max_body_size 4m;
server_name_in_redirect off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
keepalive_timeout 60;
open_file_cache max=65536 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_errors on;
gzip on;
gzip_min_length 128;
gzip_buffers 32 4k;
gzip_http_version 1.0;
gzip_comp_level 3;
gzip_types text/plain text/css application/x-javascript application/xml;
gzip_vary on;
proxy_cache_path /www/zonea levels=1:2 keys_zone=zonea:256m inactive=3d max_size=32g;
proxy_cache_path /www/zoneb levels=1:2 keys_zone=zoneb:256m inactive=3d max_size=32g;
proxy_cache_path /www/zonec levels=1:2 keys_zone=zonec:256m inactive=3d max_size=32g;
proxy_cache_path /www/zoned levels=1:2 keys_zone=zoned:256m inactive=3d max_size=32g;
proxy_cache_path /www/zonee levels=1:2 keys_zone=zonee:256m inactive=3d max_size=32g;
upstream backend {
server 10.4.1.1:80;
server 8.8.8.8:80 backup;
keepalive 32;
}
server {
listen 80;
server_name www.v2ex.com v2ex.com;
location / {
proxy_pass http://backend;
proxy_cache zonea;
proxy_cache_key $scheme://$host$request_uri;
proxy_http_version 1.1;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 96k;
proxy_temp_file_write_size 256k;
proxy_cache_valid 200 301 302 2d;
proxy_cache_valid any 1m;
proxy_cache_use_stale error timeout updating invalid_header http_500 http_502 http_504 http_404;
proxy_set_header Connection '';
proxy_set_header Host $host;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ /purge(/.*) {
proxy_cache_purge zonea $scheme://$host$1;
}
access_log off;
}
}

主要是三点:
1、观察$request_method对于缓存结果没有影响,合并了HEAD和GET的缓存
2、后端不再负责gzip,交给前端来做
3、proxy_pass增加公网IP作为备份,仍旧以内网IP为主,同时设置32个持久连接
2013-02-04 17:25:00 +08:00
回复了 Tianpu 创建的主题 NGINX 16G内存分配给nginx做前端加速后端,有什么建议吗?
@Kvm keys_zone 考虑文件数会达到1000万左右 一个key占用128字节 一共需要1250M 那单个进程处理一个大内存块(1250M)会比多个小内存块(5*250)更好吗?

现在留下大量内存 是想让系统自动管理内存和硬盘间的缓存 具体就是top的cached指标

不知道是不是想的差的太远?
2013-02-04 17:19:46 +08:00
回复了 Tianpu 创建的主题 NGINX 16G内存分配给nginx做前端加速后端,有什么建议吗?
感谢诸位的建议 varnish我担心的就是全放到内存

>站点类型以搜索结果 还有缓存的缩略图 fastcgi生的网页比较多

>过去15个小时一共产生了230万个临时文件 使用了35G硬盘

>按照2天估计 会有1024万个文件 112G硬盘

>硬盘一共有256G 1300万个inodes

>如果放到内存一部分 会不会反而反复的交换内存和硬盘?
2013-02-03 05:21:30 +08:00
回复了 Tianpu 创建的主题 NGINX 16G内存分配给nginx做前端加速后端,有什么建议吗?
@chairo 天啊 这是必然的 我估计2天的缓存时间可以有1000来万个文件 512M应该足够了

proxy_pass部分使用upstream使用公网IP做了个backup,然后keepalive了下 速度有所提升

继续看别的
2013-02-02 23:46:01 +08:00
回复了 Tianpu 创建的主题 NGINX 16G内存分配给nginx做前端加速后端,有什么建议吗?
@Kvm


现在是分配了五个proxy_cache_path 然后每个分配1.25G内存 允许32G的缓存文件 缓存文件放在一块sansung 830的硬盘上

运行了15个小时了 缓存文件有300来万 改成缓存2天了 页面变化都不大 有修改的话API会自动刷新 再长时间inode好像不大够 这个得后续看 大体上还算稳定

worker_cpu_affinity 导致后端出现严重的问题 去掉了 增大进程了

配置大约是这个样子 压缩什么的都放后端了 前端就是负责输出:

###############################################
user www www;
worker_processes 32;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
http {
client_header_buffer_size 4k;
client_body_buffer_size 128k;
large_client_header_buffers 4 4k;
server_names_hash_max_size 1280;
server_names_hash_bucket_size 128;
client_max_body_size 4m;
server_name_in_redirect off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
keepalive_timeout 60;
open_file_cache max=65535 inactive=300s;
open_file_cache_valid 500s;
open_file_cache_errors on;
proxy_cache_path /www/zonea levels=1:2 keys_zone=zonea:1280m inactive=3d max_size=32g;
proxy_cache_path /www/zoneb levels=1:2 keys_zone=zoneb:1280m inactive=3d max_size=32g;
proxy_cache_path /www/zonec levels=1:2 keys_zone=zonec:1280m inactive=3d max_size=32g;
proxy_cache_path /www/zoned levels=1:2 keys_zone=zoned:1280m inactive=3d max_size=32g;
proxy_cache_path /www/zonee levels=1:2 keys_zone=zonee:1280m inactive=3d max_size=32g;
server {
listen 8.8.8.8:80;
server_name www.v2ex.com v2ex.com;
location / {
proxy_pass http://4.4.4.4:80;
proxy_cache zonea;
proxy_cache_key $request_method://$host$request_uri;
proxy_buffer_size 8k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 96k;
proxy_temp_file_write_size 256k;
proxy_cache_valid 200 301 302 1d;
proxy_cache_valid any 1m;
proxy_cache_use_stale error timeout updating invalid_header http_500 http_502 http_504 http_404;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header HTTP_CLIENT_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header X-Cached $upstream_cache_status;
}
location ~ /purge(/.*) {
proxy_cache_purge zonea $request_method://$host$1;
}
access_log off;
}
....
}

###############################################

现在有一个问题 在同一个局域网的前端和后端的机器互相ping是0.86ms 实际抓取网页测试 有时候会卡到1.2s 应该是后端对并发支持不佳吧 也可能是流氓msnbot造成的 整体上还在观察

下一步重点测试keepalive相关的参数
2013-01-30 20:38:48 +08:00
回复了 Tianpu 创建的主题 Linux Curl wget 会自动解压缩gzip压缩,怎么才可以得到原始文档?
@binux 非常感谢

>curl -H 'Accept-Encoding:gzip' www.domain.com > temp
>gzip -d temp
>cat temp

一次解压后看到全是明文 是不是表示只经过一次压缩了?
1 ... 9  10  11  12  13  14  15  16  17  18 ... 25  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2656 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 27ms · UTC 14:04 · PVG 22:04 · LAX 07:04 · JFK 10:04
Developed with CodeLauncher
♥ Do have faith in what you're doing.