What is PacketShader?

PacketShader is a high-performance PC-based software router platform that accelerates the core packet processing with Graphics Processing Units (GPUs). Based on our observation that the CPU is the typical performance bottleneck in high-speed sofware routers, we scale the computing power in a cost-effective manner with massively-parallel GPU. PacketShader offloads computation and memory-intensive router applications to GPUs while optimizing the packet reception and transmission path on Linux. With extensive batch processing and pipelining, PacketShader achieves an unprecedented IP packet forwarding performance of 40 Gbps on an eight-core Nehalem server even for 64-byte packet size.

http://shader.kaist.edu/packetshader/

nginx配置文件中的location详解

[不指定 2011/08/21 18:45 | by ipaddr ]

location
语法:location [=|~|~*|^~] /uri/ { … }
默认:否

上下文:server

这个指令随URL不同而接受不同的结构。你可以配置使用常规字符串和正则表达式。如果使用正则表达式,你必须使用 ~* 前缀选择不区分大小写的匹配或者 ~ 选择区分大小写的匹配。

确定 哪个location 指令匹配一个特定指令,常规字符串第一个测试。常规字符串匹配请求的开始部分并且区分大小写,最明确的匹配将会被使用(查看下文明白 nginx 怎么确定它)。然后正则表达式按照配置文件里的顺序测试。找到第一个比配的正则表达式将停止搜索。如果没有找到匹配的正则表达式,使用常规字符串的结果。

有两个方法修改这个行为。第一个方法是使用 “=”前缀,将只执行严格匹配。如果这个查询匹配,那么将停止搜索并立即处理这个请求。例子:如果经常发生”/”请求,那么使用 “location = /” 将加速处理这个请求。

第二个是使用 ^~ 前缀。如果把这个前缀用于一个常规字符串那么告诉nginx 如果路径匹配那么不测试正则表达式。

而且它重要在于 NGINX 做比较没有 URL 编码,所以如果你有一个 URL 链接’/images/%20/test’ , 那么使用 “images/ /test” 限定location。

总结,指令按下列顺序被接受:
1. = 前缀的指令严格匹配这个查询。如果找到,停止搜索。
2. 剩下的常规字符串,长的在前。如果这个匹配使用 ^~ 前缀,搜索停止。
3. 正则表达式,按配置文件里的顺序。
4. 如果第三步产生匹配,则使用这个结果。否则使用第二步的匹配结果。

例子:

location = / {
# 只匹配 / 查询。
[ configuration A ]
}

location / {
# 匹配任何查询,因为所有请求都已 / 开头。但是正则表达式规则和长的块规则将被优先和查询匹配。
[ configuration B ]
}

location ^~ /images/ {
# 匹配任何已 /images/ 开头的任何查询并且停止搜索。任何正则表达式将不会被测试。
[ configuration C ]
}

location ~* \.(gif|jpg|jpeg)$ {
# 匹配任何已 gif、jpg 或 jpeg 结尾的请求。然而所有 /images/ 目录的请求将使用 Configuration C。
[ configuration D ]
}

例子请求:

/ -> configuration A

/documents/document.html -> configuration B

/images/1.gif -> configuration C

/documents/1.jpg -> configuration D

注意:按任意顺序定义这4个配置结果将仍然一样。

(location =) > (location 完整路径 ) >(location ^~ 路径) >(location ~*, ~ 正则) >(location 部分起始路径)
正则表达式根据配置文件中的前后顺序影响匹配, 前面的优先匹配. 其它则根据匹配长度来优先匹配.

参考:
http://wiki.nginx.org/NginxHttpCoreModule#location

This directive allows different configurations depending on the URI. It can be configured using both literal strings and regular expressions. To use regular expressions, you must use a prefix:

  1. "~" for case sensitive matching
  2. "~*" for case insensitive matching

To determine which location directive matches a particular query, the literal strings are checked first. Literal strings match the beginning portion of the query - the most specific match will be used. Afterwards, regular expressions are checked in the order defined in the configuration file. The first regular expression to match the query will stop the search. If no regular expression matches are found, the result from the literal string search is used.

For case insensitive operating systems, like Mac OS X or Windows with Cygwin, literal string matching is done in a case insensitive way (0.7.7). However, comparison is limited to single-byte locale's only.

Regular expression may contain captures (0.7.40), which can then be used in other directives.

It is possible to disable regular expression checks after literal string matching by using "^~" prefix. If the most specific match literal location has this prefix: regular expressions aren't checked.

By using the "=" prefix we define the exact match between request URI and location. When matched search stops immediately. E.g., if the request "/" occurs frequently, using "location = /" will speed up processing of this request a bit as search will stop after first comparison.

On exact match with literal location without "=" or "^~" prefixes search is also immediately terminated.

To summarize, the order in which directives are checked is as follows:

  1. Directives with the "=" prefix that match the query exactly. If found, searching stops.
  2. All remaining directives with conventional strings. If this match used the "^~" prefix, searching stops.
  3. Regular expressions, in the order they are defined in the configuration file.
  4. If #3 yielded a match, that result is used. Otherwise, the match from #2 is used.

It is important to know that nginx does the comparison against decoded URIs. For example, if you wish to match "/images/%20/test", then you must use "/images/ /test" to determine the location.


Nginx内置变量: http://wiki.nginx.org/HttpCoreModule

Google开源Key-Value数据库LevelDB

[不指定 2011/08/01 10:54 | by ipaddr ]

Google宣布将LevelDB开源,并且遵守New BSD许可证。LevelDB是一个嵌入式的key-value数据库。它的键和关联值可以是任意的字节数组,并且按照键值排序,排序机制是可以被重载的。数据存储机制非常简单,仅仅支持Put,Get和Delete命令,然后还有前向和后向迭代遍历。

数据会自动使用Snappy压缩,这是一个压缩库,Google将其用于BigTable,MapReduce和RPC中,并且在四月份宣布开源。LevelDB也有一些局限:不支持SQL查询和索引,支持多线程单进程访问,并且可以用于嵌入式设备,这将使某些项目收益,但是也会给其他的项目来带麻烦。

LevelDB优化了批量写操作。它将多个修改请求有序缓存在内存中,在累计到配置文件预设置的阈值之后再写入到磁盘中。对于顺序和随机写操作,以及顺序读操作来说,它的性能非常优秀,根据Google的性能基准测试,它能在某些测试项目中得分领先SQLite两个数量级。SQLite在随机读操作中比LevelDB稍好,而在写入较大数据的时候速度两倍快于LevelDB。LevelDB同样也表现得比Kyoto Cabinet优秀,Kyoto Cabinet也是一个key-value数据库,不过Google并没有像SQLite那样在所有测试项目中均进行比较。同样,Riak进行了一些测试对比LevelDB和InnoDB,在一些测试项目中,Google的LevelDB要比InnoDB要优秀或者能达到相同性能。

LevelDB是使用C++编写,一些外部的依赖库已经成功地移植到Windows、Mac OS X、Android和各种Unix上。在实际的应用中,Chrome的一些实验性版本中已经使用了LevelDB,将其作为IndexDB API的实现。而Riak则将其用于节点级的存储。不仅如此,一家开发3D地图软件的公司UpNext也使用了这套系统。

分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]